Expand bulk_accept to generic bulk_update

Allows for bulk rejection/undecided/standby in addition to bulk accept.
This commit is contained in:
James Polley 2017-09-17 12:49:28 +10:00
parent fa18ef68fb
commit ecd4bc97bc
4 changed files with 19 additions and 6 deletions

View file

@ -58,8 +58,18 @@ class BulkPresentationForm(forms.Form):
required_css_class = 'label-required'
status = forms.ChoiceField(
choices=(
('accepted', 'accepted'),
('rejected', 'rejected'),
('undecided', 'undecided'),
('standby', 'standby')
),
label="Set status to:",
help_text="Status to apply to the listed talk ids"
)
talk_ids = forms.CharField(
label=_("Talk ids"),
max_length=500,
help_text=_("Provide a comma seperated list of talk ids to accept.")
help_text=_("Provide a comma seperated list of talk ids to update.")
)

View file

@ -5,7 +5,7 @@ from .views import (
review_status,
review_list,
review_admin,
review_bulk_accept,
review_bulk_update,
result_notification,
result_notification_prepare,
result_notification_send,
@ -27,7 +27,8 @@ urlpatterns = [
url(r"^section/(?P<section_slug>[\w\-]+)/status/(?P<key>\w+)/$", review_status, name="review_status"),
url(r"^section/(?P<section_slug>[\w\-]+)/list_reviewer/(?P<user_pk>\d+)/$", review_list, name="review_list_user"),
url(r"^section/(?P<section_slug>[\w\-]+)/admin/$", review_admin, name="review_admin"),
url(r"^section/(?P<section_slug>[\w\-]+)/admin/accept/$", review_bulk_accept, name="review_bulk_accept"),
url(r"^section/(?P<section_slug>[\w\-]+)/admin/accept/$", review_bulk_update, name="review_bulk_accept"),
url(r"^section/(?P<section_slug>[\w\-]+)/admin/update/$", review_bulk_update, name="review_bulk_update"),
url(r"^section/(?P<section_slug>[\w\-]+)/notification/(?P<status>\w+)/$", result_notification, name="result_notification"),
url(r"^section/(?P<section_slug>[\w\-]+)/notification/(?P<status>\w+)/prepare/$", result_notification_prepare, name="result_notification_prepare"),
url(r"^section/(?P<section_slug>[\w\-]+)/notification/(?P<status>\w+)/send/$", result_notification_send, name="result_notification_send"),

View file

@ -529,22 +529,24 @@ def review_assignment_opt_out(request, pk):
@login_required
def review_bulk_accept(request, section_slug):
@transaction.atomic
def review_bulk_update(request, section_slug):
if not request.user.has_perm("reviews.can_manage_%s" % section_slug):
return access_not_permitted(request)
if request.method == "POST":
form = BulkPresentationForm(request.POST)
if form.is_valid():
talk_ids = form.cleaned_data["talk_ids"].split(",")
status = form.cleaned_data["status"] or "accepted"
talks = ProposalBase.objects.filter(id__in=talk_ids).select_related("result")
for talk in talks:
talk.result.status = "accepted"
talk.result.status = status
talk.result.save()
return redirect("review_section", section_slug=section_slug)
else:
form = BulkPresentationForm()
return render(request, "symposion/reviews/review_bulk_accept.html", {
return render(request, "symposion/reviews/review_bulk_update.html", {
"form": form,
})