-
Notifications
You must be signed in to change notification settings - Fork 4
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
adds ability to self publish workbaskets via the django admin workbasket view #1292
base: master
Are you sure you want to change the base?
adds ability to self publish workbaskets via the django admin workbasket view #1292
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1292 +/- ##
==========================================
- Coverage 93.11% 93.08% -0.04%
==========================================
Files 620 642 +22
Lines 47329 48324 +995
Branches 3343 5201 +1858
==========================================
+ Hits 44070 44980 +910
- Misses 2619 2688 +69
- Partials 640 656 +16 ☔ View full report in Codecov by Sentry. |
if "_self-publish" in request.POST: | ||
# check if user is super user | ||
if not request.user.is_superuser: | ||
self.message_user(request, "You do not have permission to perform this action.", level=messages.ERROR) | ||
return HttpResponseRedirect(request.get_full_path()) | ||
|
||
# check if workbasket status is 'editing' | ||
if obj.status != 'EDITING': | ||
messages.error(request, "The workbasket is not in EDITING status.") | ||
return HttpResponseRedirect(request.get_full_path()) | ||
|
||
# check if rule checks have passed | ||
if obj.unchecked_or_errored_transactions.exists(): | ||
messages.error(request, "Rule checks have not passed on the current contents of this workbasket.") | ||
return HttpResponseRedirect(request.get_full_path()) | ||
|
||
obj.full_clean() | ||
obj.approve(user=request.user.id, scheme_name=settings.TRANSACTION_SCHEMA) | ||
obj.status = "PUBLISHED" | ||
obj.save() | ||
return HttpResponseRedirect(request.get_full_path()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has the potential to make important and far reaching changes to published data. I think it probably needs accompanying unit tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This workbasket transition to PUBLISHED
is probably better placed on the WorkBasket
model to make it less of a back channel approach to workbasket state management and publishing. Probably a new transition (using the django_fsm.transition
decorator), that more or less combines queue
and cds_confirmed
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It also sounds as though these changes are to support a very specific quotas workflow. To reduce the chances of incorrectly publishing data, validation should ensure only specific data types are present in the workbasket. Were validation to fail, then that'd involve disabling the capability in the UI and preventing the publish
transition when implemented on the workbasket.
TP2000-1494
Adds ability to self publish workbaskets via the django admin workbasket view
Why
We need a method to self publish workbaskets (i.e. publish workbaskets only for TAP and not any downstream consumers like HMRC or the Channel Islands) via the UI. Currently it can only be done through scripts.
What
This PR adds a button to Django admin workbasket view to enable self publishing. It will only show to super users and it will only be clickable if the workbasket in question is in EDITING state and with all transactions having passed rules checks.