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

Add submission withdrawal workflow #3298

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

frankduncan
Copy link
Contributor

Fixes #3296

What it says on the tin. When applicants have edit permissions (requires a change to workflow.py, see #3297), they can withdraw applications that have been submitted. This adds that as a new status for submissions.

Copy link
Contributor

@frjo frjo left a comment

Choose a reason for hiding this comment

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

Overall approach ok but implementation needs work.

hypha/apply/funds/workflow.py Outdated Show resolved Hide resolved
},
'display': _('Need screening'),
'public': _('Application Received'),
'stage': RequestExt,
'permissions': default_permissions,
'permissions': applicant_edit_permissions,
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 withdraw permissions should be separate from edit permissions.

We do not allow applicants to edit submissions that are in review for obvious reasons.

But if we allow an applicant to withdraw an application they should be able to do that in any state up until the submission is approved/declined.

Copy link
Contributor

Choose a reason for hiding this comment

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

In progress.

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 f4ae001 resolves this, let me know what you think.

hypha/public/utils/context_processors.py Outdated Show resolved Hide resolved
@frankduncan
Copy link
Contributor Author

Thanks for the feedback! Patches incoming

frankduncan pushed a commit that referenced this pull request Apr 15, 2023
Based on Review in #3298, the decision was made that an applicant can
withdraw at any time, without edit permissions, and edit permissions
should not be to applicants for their own submissions.
@frankduncan frankduncan force-pushed the enhancement/gh-3296-add-withdraw branch from 0861d24 to 6f8d05d Compare April 15, 2023 14:07
@frankduncan
Copy link
Contributor Author

Ok! I believe I've made the correct updates. I did testing on all the different workflows, but I'm not as familiar with some of the ones we don't use with ARDC, so there may be edge cases I'm not aware of. Especially the Concept/Proposal, which I believe I did in line with the spirit of those workflows.

frjo pushed a commit that referenced this pull request Jul 26, 2023
Based on Review in #3298, the decision was made that an applicant can
withdraw at any time, without edit permissions, and edit permissions
should not be to applicants for their own submissions.
@frjo frjo force-pushed the enhancement/gh-3296-add-withdraw branch from 6f8d05d to 5d0405e Compare July 26, 2023 08:09
@frjo frjo force-pushed the enhancement/gh-3296-add-withdraw branch from 4fa0e41 to 1d7b829 Compare July 26, 2023 13:01
@frjo frjo added Status: Needs testing Tickets that need testing/qa Type: Feature This is something new (not an enhancement of an existing thing). Type: Minor Minor change, used in release drafter labels Jul 26, 2023
@fourthletter
Copy link
Contributor

fourthletter commented Sep 5, 2023

A 'withdraw' button has been added

image

@frjo frjo removed the Status: Needs testing Tickets that need testing/qa label Sep 12, 2023
@bickelj
Copy link
Contributor

bickelj commented Jul 23, 2024

@frjo What would we need to do to get this one in? I was about to make an issue and PR but found this existing one.

@frjo
Copy link
Contributor

frjo commented Jul 24, 2024

@bickelj Rebase of current main and address the issues above. I think it makes perfect sense to allow applicants to withdraw an application. If this should be the default or optional I'm not sure but make it optional for now.

bickelj pushed a commit that referenced this pull request Jul 24, 2024
Based on Review in #3298, the decision was made that an applicant can
withdraw at any time, without edit permissions, and edit permissions
should not be to applicants for their own submissions.

Issue #3296
@bickelj bickelj force-pushed the enhancement/gh-3296-add-withdraw branch 4 times, most recently from cacfc93 to f63f0b2 Compare July 25, 2024 18:10
@bickelj
Copy link
Contributor

bickelj commented Jul 25, 2024

@frjo I think this is ready for testing again.

Copy link
Contributor

@frjo frjo left a comment

Choose a reason for hiding this comment

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

Nice work! Some questions around implementation details.

Good improvement of Hypha.

hypha/apply/funds/workflow.py Outdated Show resolved Hide resolved
hypha/apply/funds/workflow.py Outdated Show resolved Hide resolved
hypha/apply/funds/workflow.py Outdated Show resolved Hide resolved
@@ -1579,6 +1583,45 @@ def form_valid(self, form):
return super().form_valid(form)


class SubmissionWithdrawView(SingleObjectTemplateResponseMixin, BaseDetailView):
Copy link
Contributor

Choose a reason for hiding this comment

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

Add

@method_decorator(login_required, name="dispatch")

Copy link
Contributor

Choose a reason for hiding this comment

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

Is the SingleObjectTemplateResponseMixin needed?

Copy link
Contributor

Choose a reason for hiding this comment

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

🤷 I suppose I could try without once the other issues are resolved.

hypha/apply/funds/views.py Outdated Show resolved Hide resolved
frjo pushed a commit that referenced this pull request Aug 7, 2024
Based on Review in #3298, the decision was made that an applicant can
withdraw at any time, without edit permissions, and edit permissions
should not be to applicants for their own submissions.

Issue #3296
@frjo frjo force-pushed the enhancement/gh-3296-add-withdraw branch from 5b656bb to a41caec Compare August 7, 2024 19:10
@frjo
Copy link
Contributor

frjo commented Aug 7, 2024

@bickelj I rebased of main and added some permission fixes that seems to work. (I hope it doesn't mess it up for you.)

Please try it out and see how it behaves.

@bickelj
Copy link
Contributor

bickelj commented Aug 8, 2024

@frjo Thank you for making the change, it didn't mess anything up for me! It looks great!

From a user perspective, applicants cannot withdraw right after submitting the application as expected. If I add withdraw=[applicant_can] to default_permissions, this problem goes away. I assume we need to add it to most of the others in order for applicants to withdraw from most states, right?

From a programmer perspective, the permissions in transitions seems to now be honored. Good, except the reason it's honored is it is explicitly looked up in a view. I hoped that the django-fsm library (or the Hypha extensions of django-fsm) would somehow honor the permissions declared in the workflow even when not explicitly referenced from the view. I mean I thought one of get_transition, can_proceed, or transition in the perform_transition method would cause a PermissionDenied but it does not. While I think that specifying permissions in the workflow itself is a more sustainable design, it was not clear to me that additional implementation in the view was a requirement. I still am not sure what "method" does there or where else the permissions object in the workflow is used.

frjo pushed a commit that referenced this pull request Aug 8, 2024
Based on Review in #3298, the decision was made that an applicant can
withdraw at any time, without edit permissions, and edit permissions
should not be to applicants for their own submissions.

Issue #3296
@frjo frjo force-pushed the enhancement/gh-3296-add-withdraw branch from a41caec to 2b72a80 Compare August 8, 2024 15:17
@frjo
Copy link
Contributor

frjo commented Aug 8, 2024

I have added withdraw=[applicant_can] to default_permissions, makes total sense.

Unsure of adding it to other places. Can we put this on test and see what people think of it?

@bickelj
Copy link
Contributor

bickelj commented Aug 8, 2024

@frjo Sure, yes, sorry for the delay!

@frjo frjo requested a review from theskumar August 9, 2024 08:48
@bickelj
Copy link
Contributor

bickelj commented Aug 13, 2024

@frjo While looking at django-fsm docs I noticed django FSM was deprecated in favor of a new viewflow API earlier this year. It probably doesn't affect this PR but I wanted to note it somewhere before I forgot.

@frjo
Copy link
Contributor

frjo commented Aug 13, 2024

Created this #4090

@bickelj
Copy link
Contributor

bickelj commented Oct 8, 2024

@frjo Do you think this one can be in the next release?

frjo pushed a commit that referenced this pull request Oct 9, 2024
Based on Review in #3298, the decision was made that an applicant can
withdraw at any time, without edit permissions, and edit permissions
should not be to applicants for their own submissions.

Issue #3296
@frjo frjo force-pushed the enhancement/gh-3296-add-withdraw branch from afd1ef6 to 709f218 Compare October 9, 2024 12:23
@frjo
Copy link
Contributor

frjo commented Oct 9, 2024

I just rebased the PR. It will go to test late this week or next week. So probably the release after the next one.

chriszs and others added 14 commits October 18, 2024 13:26
This only affects about enabling them, not whether they are in the
system.  That means that if the configuration is changed over the
lifetime of a system, things that were withdrawn when it was enabled
retain that status.

Issue #3296
Based on Review in #3298, the decision was made that an applicant can
withdraw at any time, without edit permissions, and edit permissions
should not be to applicants for their own submissions.

Issue #3296
This creates a single withdrawn status for each workflow, living at the
end (next to accepted/rejected), and adds transistions for all the
different workflow types.

Issue #3296
This affected different calculating pages, like the open round
percentage completions.

Issue #3296
Withdrawn status needs to be added to a mapping, apparently :)

Issue #3296
Removed a redeclared variable and reformatted.

Issue #3296
Add distinct withdrawal permissions within stages of workflows. By
default, let the applicant withdraw at any stage. On the submission
page, display the Withdraw button assuming the setting
`ENABLE_SUBMISSION_WITHDRAWAL` is true and the withdrawal permissions
are met.

Issue #3296
Add a heroicon to "Withdraw" button and style it similar to "Delete".

Issue #3296
The permissions on the `*withdraw` items should be `no_permissions`.
After a submission is withdrawn, nothing further should happen to it.

When `perform_transition` is called in the View, that function will
already check for valid transitions and raise an exception if needed.
So do not bother looking into the transitions, instead look directly
for the withdraw action. And expect exactly one of those, otherwise
raise an exception with details of expectations.

Issue #3296
@frjo frjo force-pushed the enhancement/gh-3296-add-withdraw branch from 709f218 to 42d5918 Compare October 18, 2024 11:26
"display": _("Withdraw"),
"permissions": {UserPermissions.APPLICANT},
"method": "withdraw",
},
Copy link
Contributor

@bickelj bickelj Oct 18, 2024

Choose a reason for hiding this comment

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

The previous was more concise. What is the advantage of this repetition?

Copy link
Contributor

Choose a reason for hiding this comment

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

To give the applicant permission to perform the action.

Copy link
Contributor

Choose a reason for hiding this comment

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

I could have sworn I tested with applicants but I guess you mean in the context of putting the permissions in a single place rather than multiple places.

@@ -204,7 +204,7 @@ def make_permissions(edit=None, review=None, view=None, withdraw=None):
reviewer_can,
partner_can,
],
"withdraw": withdraw or [applicant_can],
Copy link
Contributor

Choose a reason for hiding this comment

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

This is where I was thinking it avoided the repetition but is that incorrect? Perhaps it was the former 1753 in the view that was duplicative/incorrect before?

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant to say "Line 1753 in the view."

@frjo frjo added the Status: RTBC Internal Dev use only label Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: RTBC Internal Dev use only Type: Feature This is something new (not an enhancement of an existing thing). Type: Minor Minor change, used in release drafter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow Applicants to Withdraw a submission
5 participants