def redeliver(self, request, queryset, auto=False): """ Redeliver undelivered mails """ opts = self.model._meta # Check that the user has change permission for the actual model if not self.has_change_permission(request): raise PermissionDenied Form = get_fk_form_class(self.model, 'request', self.admin_site) # User has already chosen the other req if request.POST.get('obj'): f = Form(request.POST) if f.is_valid(): req = f.cleaned_data['obj'] for deferred in queryset: deferred.redeliver(req) self.message_user(request, _("Successfully triggered redelivery.")) return None else: f = Form() context = { 'opts': opts, 'queryset': queryset, 'media': self.media, 'action_checkbox_name': helpers.ACTION_CHECKBOX_NAME, 'form': f, 'applabel': opts.app_label } # Display the confirmation page return TemplateResponse(request, 'foirequest/admin_redeliver.html', context)
def add_to_project(self, request, queryset): """ Mark selected requests as same as the one we are choosing now. """ opts = self.model._meta # Check that the user has change permission for the actual model if not self.has_change_permission(request): raise PermissionDenied queryset = queryset.filter(project__isnull=True) Form = get_fk_form_class(self.model, 'project', self.admin_site) # User has already chosen the other req if request.POST.get('obj'): f = Form(request.POST) if f.is_valid(): project = f.cleaned_data['obj'] project.add_requests(queryset) self.message_user(request, _("Successfully added requests to project.")) # Return None to display the change list page again. return None else: f = Form() context = { 'opts': opts, 'queryset': queryset, 'media': self.media, 'action_checkbox_name': helpers.ACTION_CHECKBOX_NAME, 'form': f, 'applabel': opts.app_label } # Display the confirmation page return TemplateResponse( request, 'foirequest/admin/add_to_project.html', context )
def mark_same_as(self, request, queryset): """ Mark selected requests as same as the one we are choosing now. """ opts = self.model._meta # Check that the user has change permission for the actual model if not self.has_change_permission(request): raise PermissionDenied Form = get_fk_form_class(self.model, 'same_as', self.admin_site) # User has already chosen the other req if request.POST.get('obj'): f = Form(request.POST) if f.is_valid(): req = f.cleaned_data['obj'] queryset.update(same_as=req) count = FoiRequest.objects.filter(same_as=req).count() FoiRequest.objects.filter(id=req.id).update( same_as_count=count ) self.message_user(request, _("Successfully marked requests as identical.")) # Return None to display the change list page again. return None else: f = Form() context = { 'opts': opts, 'queryset': queryset, 'media': self.media, 'action_checkbox_name': helpers.ACTION_CHECKBOX_NAME, 'form': f, 'applabel': opts.app_label } # Display the confirmation page return TemplateResponse(request, 'foirequest/admin/mark_same_as.html', context)
def mark_same_as(self, request, queryset): """ Mark selected requests as same as the one we are choosing now. """ opts = self.model._meta # Check that the user has change permission for the actual model if not self.has_change_permission(request): raise PermissionDenied Form = get_fk_form_class(self.model, 'same_as', self.admin_site) # User has already chosen the other req if request.POST.get('obj'): f = Form(request.POST) if f.is_valid(): req = f.cleaned_data['obj'] queryset.update(same_as=req) count = FoiRequest.objects.filter(same_as=req).count() FoiRequest.objects.filter(id=req.id).update( same_as_count=count) update_foirequest_index(queryset) self.message_user( request, _("Successfully marked requests as identical.")) # Return None to display the change list page again. return None else: f = Form() context = { 'opts': opts, 'queryset': queryset, 'media': self.media, 'action_checkbox_name': helpers.ACTION_CHECKBOX_NAME, 'form': f, 'applabel': opts.app_label } # Display the confirmation page return TemplateResponse(request, 'foirequest/admin/mark_same_as.html', context)
def add_to_project(self, request, queryset): """ Mark selected requests as same as the one we are choosing now. """ opts = self.model._meta # Check that the user has change permission for the actual model if not self.has_change_permission(request): raise PermissionDenied queryset = queryset.filter(project__isnull=True) Form = get_fk_form_class(self.model, 'project', self.admin_site) # User has already chosen the other req if request.POST.get('obj'): f = Form(request.POST) if f.is_valid(): project = f.cleaned_data['obj'] project.add_requests(queryset) self.message_user(request, _("Successfully added requests to project.")) # Return None to display the change list page again. return None else: f = Form() context = { 'opts': opts, 'queryset': queryset, 'media': self.media, 'action_checkbox_name': helpers.ACTION_CHECKBOX_NAME, 'form': f, 'applabel': opts.app_label } # Display the confirmation page return TemplateResponse(request, 'foirequest/admin/add_to_project.html', context)
def _get_assign_action_form_class(self, fieldname): return get_fk_form_class(PublicBody, 'root', self.admin_site)
def _get_assign_action_form_class(self, fieldname): return get_fk_form_class(Guidance, 'action', self.admin_site)