def get_context_data(self, *args, **kwargs): kwargs = super().get_context_data(*args, **kwargs) kwargs['reviews'] = self.get_item().review_requests.filter( status=MDR.REVIEW_STATES.submitted).all() kwargs['status_matrix'] = json.dumps( generate_visibility_matrix(self.request.user)) return kwargs
def get_context_data(self, form, **kwargs): item = self.item status_matrix = json.dumps( generate_visibility_matrix(self.request.user)) context = super().get_context_data(form, **kwargs) context.update({'item': item, 'status_matrix': status_matrix}) return context
def get_context_data(self, **kwargs): from aristotle_mdr.views.utils import generate_visibility_matrix kwargs = super(ReviewAcceptView, self).get_context_data(**kwargs) import json kwargs['status_matrix'] = json.dumps( generate_visibility_matrix(self.request.user)) return kwargs
def get_context_data(self, *args, **kwargs): kwargs = super().get_context_data(*args, **kwargs) kwargs['status_matrix'] = json.dumps( generate_visibility_matrix(self.request.user)) kwargs['review'] = self.get_review() if self.show_supersedes: kwargs['supersedes'] = self.get_supersedes_context() kwargs['show_supersedes'] = self.show_supersedes return kwargs
def get_context_data(self, **kwargs): from aristotle_mdr.views.utils import generate_visibility_matrix kwargs = super(ReviewAcceptView, self).get_context_data(**kwargs) import json kwargs['status_matrix'] = json.dumps(generate_visibility_matrix(self.request.user)) forminstance = kwargs['form'] forminstance.fields['state'].initial = self.review.state forminstance.fields['registrationAuthorities'].checked = [1] # set registration authority return kwargs
def changeStatus(request, iid): item = get_object_or_404(MDR._concept, pk=iid).item if not (item and user_can_change_status(request.user, item)): if request.user.is_anonymous(): return redirect(reverse('friendly_login') + '?next=%s' % request.path) else: raise PermissionDenied # There would be an else here, but both branches above return, # so we've chopped it out to prevent an arrow anti-pattern. if request.method == 'POST': # If the form has been submitted... form = MDRForms.ChangeStatusForm(request.POST, user=request.user) # A form bound to the POST data if form.is_valid(): # process the data in form.cleaned_data as required ras = form.cleaned_data['registrationAuthorities'] state = form.cleaned_data['state'] regDate = form.cleaned_data['registrationDate'] cascade = form.cleaned_data['cascadeRegistration'] changeDetails = form.cleaned_data['changeDetails'] with transaction.atomic(), reversion.revisions.create_revision(): reversion.revisions.set_user(request.user) for ra in ras: if cascade: register_method = ra.cascaded_register else: register_method = ra.register register_method( item, state, request.user, changeDetails=changeDetails, registrationDate=regDate, ) # TODO: notification and message on success/failure return HttpResponseRedirect(url_slugify_concept(item)) else: form = MDRForms.ChangeStatusForm(user=request.user) import json return render( request, "aristotle_mdr/actions/changeStatus.html", { "item": item, "form": form, "status_matrix": json.dumps(generate_visibility_matrix(request.user)), } )
def changeStatus(request, iid): item = get_object_or_404(MDR._concept, pk=iid).item if not (item and user_can_change_status(request.user, item)): if request.user.is_anonymous(): return redirect(reverse("friendly_login") + "?next=%s" % request.path) else: raise PermissionDenied # There would be an else here, but both branches above return, # so we've chopped it out to prevent an arrow anti-pattern. if request.method == "POST": # If the form has been submitted... form = MDRForms.ChangeStatusForm(request.POST, user=request.user) # A form bound to the POST data if form.is_valid(): # process the data in form.cleaned_data as required ras = form.cleaned_data["registrationAuthorities"] state = form.cleaned_data["state"] regDate = form.cleaned_data["registrationDate"] cascade = form.cleaned_data["cascadeRegistration"] changeDetails = form.cleaned_data["changeDetails"] with transaction.atomic(), reversion.revisions.create_revision(): reversion.revisions.set_user(request.user) for ra in ras: if cascade: register_method = ra.cascaded_register else: register_method = ra.register register_method(item, state, request.user, changeDetails=changeDetails, registrationDate=regDate) # TODO: notification and message on success/failure return HttpResponseRedirect(url_slugify_concept(item)) else: form = MDRForms.ChangeStatusForm(user=request.user) import json return render( request, "aristotle_mdr/actions/changeStatus.html", {"item": item, "form": form, "status_matrix": json.dumps(generate_visibility_matrix(request.user))}, )
def get_context_data(self, form, **kwargs): item = self.item status_matrix = json.dumps(generate_visibility_matrix(self.request.user)) context = super().get_context_data(form, **kwargs) context.update({'item': item, 'status_matrix': status_matrix}) return context
def get_context_data(self, *args, **kwargs): kwargs = super(ReviewAcceptView, self).get_context_data(*args, **kwargs) kwargs['status_matrix'] = json.dumps( generate_visibility_matrix(self.request.user)) return kwargs
def get_context_data(self, **kwargs): from aristotle_mdr.views.utils import generate_visibility_matrix kwargs = super(ReviewAcceptView, self).get_context_data(**kwargs) import json kwargs['status_matrix'] = json.dumps(generate_visibility_matrix(self.request.user)) return kwargs
def get_context_data(self, *args, **kwargs): kwargs = super().get_context_data(*args, **kwargs) kwargs['status_matrix'] = json.dumps(generate_visibility_matrix(self.request.user)) kwargs['review'] = self.get_review() return kwargs