Changed the way to call the history of foreign objects

This commit is contained in:
Roberto Rosario
2011-05-28 16:28:39 -04:00
parent 6c3aa1f37b
commit e14dfc5c46
3 changed files with 13 additions and 6 deletions

View File

@@ -53,6 +53,7 @@ document_find_all_duplicates = {'text': _(u'find all duplicates'), 'view': 'docu
document_clear_transformations = {'text': _(u'clear all transformations'), 'view': 'document_clear_transformations', 'args': 'object.id', 'famfam': 'page_paintbrush', 'permissions': [PERMISSION_DOCUMENT_TRANSFORM]}
document_multiple_clear_transformations = {'text': _(u'clear all transformations'), 'view': 'document_multiple_clear_transformations', 'famfam': 'page_paintbrush', 'permissions': [PERMISSION_DOCUMENT_TRANSFORM]}
document_print = {'text': _(u'print'), 'view': 'document_print', 'args': 'object.id', 'famfam': 'printer', 'permissions': [PERMISSION_DOCUMENT_VIEW]}
document_history_view = {'text': _(u'history'), 'view': 'history_for_object', 'args': ['"documents"', '"document"', 'object.id'], 'famfam': 'book_go', 'permissions': [PERMISSION_DOCUMENT_VIEW]}
document_page_transformation_list = {'text': _(u'page transformations'), 'class': 'no-parent-history', 'view': 'document_page_transformation_list', 'args': 'object.id', 'famfam': 'pencil_go', 'permissions': [PERMISSION_DOCUMENT_TRANSFORM]}
document_page_transformation_create = {'text': _(u'create new transformation'), 'class': 'no-parent-history', 'view': 'document_page_transformation_create', 'args': 'object.id', 'famfam': 'pencil_add', 'permissions': [PERMISSION_DOCUMENT_TRANSFORM]}
@@ -83,7 +84,7 @@ upload_document_from_user_staging = {'text': _(u'user staging'), 'view': 'upload
staging_file_preview = {'text': _(u'preview'), 'class': 'fancybox-noscaling', 'view': 'staging_file_preview', 'args': ['source', 'object.id'], 'famfam': 'drive_magnify'}
staging_file_delete = {'text': _(u'delete'), 'view': 'staging_file_delete', 'args': ['source', 'object.id'], 'famfam': 'drive_delete'}
register_links(Document, [document_view_simple, document_view_advanced, document_edit, document_print, document_delete, document_download, document_find_duplicates, document_clear_transformations])
register_links(Document, [document_view_simple, document_view_advanced, document_edit, document_print, document_delete, document_download, document_find_duplicates, document_clear_transformations, document_history_view])
register_links(Document, [document_create_siblings], menu_name='sidebar')
register_multi_item_links(['search', 'results', 'document_group_view', 'document_list', 'document_list_recent'], [document_multiple_clear_transformations, document_multiple_delete])

View File

@@ -2,6 +2,7 @@ from django.conf.urls.defaults import patterns, url
urlpatterns = patterns('history.views',
url(r'^list/$', 'history_list', (), 'history_list'),
url(r'^list/for_object/(?P<content_type_id>\d+)/(?P<object_id>\d+)/$', 'history_for_object', (), 'history_for_object'),
url(r'^list/for_object/(?P<app_label>[\w\-]+)/(?P<module_name>[\w\-]+)/(?P<object_id>\d+)/$', 'history_for_object', (), 'history_for_object'),
url(r'^(?P<object_id>\d+)/$', 'history_view', (), 'history_view'),
)

View File

@@ -7,6 +7,7 @@ from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.utils.http import urlencode
from django.contrib.contenttypes.models import ContentType
from django.db.models.loading import get_model
from permissions.api import check_permissions
@@ -42,15 +43,19 @@ def history_list(request):
context_instance=RequestContext(request))
def history_for_object(request, content_type_id, object_id):
def history_for_object(request, app_label, module_name, object_id):
check_permissions(request.user, [PERMISSION_HISTORY_VIEW])
content_type = get_object_or_404(ContentType, pk=content_type_id)
content_object = get_object_or_404(content_type.model_class(), pk=object_id)
model = get_model(app_label, module_name)
if not model:
raise Http404
content_object = get_object_or_404(model, pk=object_id)
content_type = ContentType.objects.get_for_model(model)
context = {
'object_list': History.objects.filter(content_type=content_type_id, object_id=object_id),
'object_list': History.objects.filter(content_type=content_type, object_id=object_id),
'title': _(u'history for: %s') % content_object,
'object': content_object,
'extra_columns': [
{
'name': _(u'date and time'),