Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow team editors to download a zip of application data from the editor submissions log #3750

Merged
merged 4 commits into from
Oct 3, 2024

Conversation

jessicamcinchak
Copy link
Member

@jessicamcinchak jessicamcinchak commented Oct 1, 2024

Folks using the existing Uniform connector have been having issues accessing application files in their DMS and more often requesting that a zip be sent to them via Slack, etc - this should make application data easier to self-serve from the editor ! See this thread for more context: https://opensystemslab.slack.com/archives/C5Q59R3HB/p1727791569016769

Changes:

  • Shows a download button in the submissions log (if it's a sucessful submission within last 28 days, you have team editor privileges to this team, a submission email has been set in team settings)
    • This button downloads the same zip that folks access if using "Send to email" - it includes standard PlanX documents (application.csv, application.json, overview.html, redactedOverview.html, locationPlan.html, locationPlan.geojson) as well as any user-uploaded files

Test flow:

Screenshot from 2024-10-01 20-23-48

Copy link

github-actions bot commented Oct 1, 2024

Removed vultr server and associated DNS entries

externalPlanningSiteName: external_planning_site_name
externalPlanningSiteUrl: external_planning_site_url
submissionEmail: submission_email
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to re-use the existing /download-application-files/:sessionId endpoint, we need team settings like submissionEmail to be available in the editor when the team store is initialised - is this okay? Am I forgetting any specific reasons that settings were omitted from this query and not initialised?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is cool, I remember I had a bit of trouble with the query, but think that was due to an issue on timing of changes with submissionEmail than anything code related that would stop this happening. All the settings should be defined in the database and able to be read, nothing gets generated after this... unless you edit a setting.

}/download-application-files/${
submission.sessionId
}?localAuthority=${teamSlug}&email=${submissionEmail}`;
window.open(zipUrl, "_blank");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really simple! Is window.open() actually too simple / let's get council folks to test on staging to confirm that their council browser settings won't block this?

We also know that we want to "harden" /download-application-files/:sessionId endpoint in the near future (this Trello ticket) - so we'll ideally want a solution that works for both places here so that we can ensure send to email & submission log zips are totally consistent for end uers ! I've attached this PR to the Trello ticket for future reference.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one way to find out! This is the approach I would have gone with initially also 👍

@jessicamcinchak
Copy link
Member Author

const showDownloadButton =
canUserEditTeam(teamSlug) &&
submission.status === "Success" &&
submissionEmail &&
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's admittedly a bit of a weird requirement that submissionEmail needs to be set to be able to download application data that was originally sent to any back-office system (because submissionEmail is "send to email" specific) - but now that this is self-service in the editor, I think it's ultimately okay and won't be a blocker?

This MVP re-uses the /download-application-files/:sessionId endpoint, but as other comments here also say we know we want to change/"harden" this soon so will be able to theoretically drop this requirement in next iteration!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's a bit odd as it stands but I totally get it!

I think a better approach would be to hit the API and use the user's JWT permissions to control access as opposed to the fact they have access to the submission_email column.

The reason for this is that team_settings doesn't have access controls between teams, but the lowcal_sessions table could / should.

What I think this would look like -

  • Set up permissions on lowcal_sessions table so that teamEditors can access sessions from their team
  • Make a new route, with middleware to check it's an authenticated request, but use the same controller (might need to look at which client is making the request?)
  • Hit the new route here
router.get("/download-submission-files/:sessionId", useTeamEditorAuth, downloadApplicationFiles);

This works fine for now, but when we revisit this I think it's worth tightening this up a little 👍

@jessicamcinchak jessicamcinchak marked this pull request as ready for review October 2, 2024 10:22
@jessicamcinchak jessicamcinchak requested a review from a team October 2, 2024 10:22
@ianjon3s
Copy link
Contributor

ianjon3s commented Oct 2, 2024

Possible quick usability win here: wrapping the download icon in a tooltip. I'll branch off to add this.

Copy link
Contributor

@RODO94 RODO94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as expected for me, although it is hard for me to review the quality of the files, only testing the initialising of the team settings, and the use of the button to trigger a download.

@jessicamcinchak do you think that's something I should do before approving or it's unrelated to the PR?

externalPlanningSiteName: external_planning_site_name
externalPlanningSiteUrl: external_planning_site_url
submissionEmail: submission_email
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is cool, I remember I had a bit of trouble with the query, but think that was due to an issue on timing of changes with submissionEmail than anything code related that would stop this happening. All the settings should be defined in the database and able to be read, nothing gets generated after this... unless you edit a setting.

const showDownloadButton =
canUserEditTeam(teamSlug) &&
submission.status === "Success" &&
submissionEmail &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's a bit odd as it stands but I totally get it!

I think a better approach would be to hit the API and use the user's JWT permissions to control access as opposed to the fact they have access to the submission_email column.

The reason for this is that team_settings doesn't have access controls between teams, but the lowcal_sessions table could / should.

What I think this would look like -

  • Set up permissions on lowcal_sessions table so that teamEditors can access sessions from their team
  • Make a new route, with middleware to check it's an authenticated request, but use the same controller (might need to look at which client is making the request?)
  • Hit the new route here
router.get("/download-submission-files/:sessionId", useTeamEditorAuth, downloadApplicationFiles);

This works fine for now, but when we revisit this I think it's worth tightening this up a little 👍

@jessicamcinchak jessicamcinchak merged commit 4411696 into main Oct 3, 2024
12 checks passed
@jessicamcinchak jessicamcinchak deleted the jess/submissions-log-download branch October 3, 2024 08:36
@jessicamcinchak
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants