Exemple #1
0
 def history_view(self, request, object_id, extra_context=None):
     object_id = unquote(object_id)
     opts = self.model._meta
     latest_approved_id = Version.objects.latest_approved(self.content_type, object_id).id
     action_list = [
         {
             'revision': version.revision,
             'edit_url': version_edit_url(version.object_id, version.id, self.admin_site.name, opts),
             'view_url': version_view_changes_url(version.object_id, version.id, self.admin_site.name, opts),
             'approve_url': version_approve_url(version.object_id, version.id, self.admin_site.name, opts),
             'reject_url': version_reject_url(version.object_id, version.id, self.admin_site.name, opts),
             'recover_url': reverse('%s:%s_%s_recover' % (
                 self.admin_site.name, opts.app_label, opts.module_name
             ), args=[version.id]),
             'is_current': version.id == latest_approved_id,
             'children_pks': version.revision.children.all().values_list('id', flat=True),
             'pending': version.revision.status == VERSION_STATUS_NEED_ATTENTION,
         }
         for version in Version.objects.filter(
             object_id=object_id,
             content_type=self.content_type
         ).select_related('revision', 'revision__changed_by', 'revision__moderated_by')
     ]
     context = {
         'action_list': action_list
         , 'is_admin': is_user_content_admin(request.user)
     }
     context.update(extra_context or {})
     return super(WorkflowAdmin, self).history_view(request, object_id, context)
Exemple #2
0
    def changelist_view(self, request, extra_context=None):
        action_list = []

        for version in Version.objects.filter(
            revision__status=VERSION_STATUS_NEED_ATTENTION,
        ).select_related('revision', 'revision__created_by'):
            url_params = (version.object_id, version.id, self.admin_site.name, version.object_version.object._meta)
            try:
                action_list.append({
                    'version': version,
                    'edit_url': version_edit_url(*url_params),
                    'view_url': version_view_changes_url(*url_params),
                    'approve_url': version_approve_url(*url_params),
                    'reject_url': version_reject_url(*url_params),
                })
            except:
                pass
        context = {
            'title': force_unicode(self.model._meta.verbose_name_plural),
            'action_list': action_list,
        }
        context.update(extra_context or {})
        return render_to_response(
            self.changelist_view_template, context, template.RequestContext(request))