Move get_object_name from common.utils to the only place it is used: checkouts.
This commit is contained in:
@@ -13,7 +13,7 @@ from documents.models import Document
|
|||||||
from documents.views import DocumentListView
|
from documents.views import DocumentListView
|
||||||
|
|
||||||
from acls.models import AccessControlList
|
from acls.models import AccessControlList
|
||||||
from common.utils import encapsulate, get_object_name
|
from common.utils import encapsulate
|
||||||
from common.views import SingleObjectCreateView
|
from common.views import SingleObjectCreateView
|
||||||
from permissions import Permission
|
from permissions import Permission
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ class CheckoutListView(DocumentListView):
|
|||||||
'title': _('Documents checked out'),
|
'title': _('Documents checked out'),
|
||||||
'hide_links': True,
|
'hide_links': True,
|
||||||
'extra_columns': [
|
'extra_columns': [
|
||||||
{'name': _('User'), 'attribute': encapsulate(lambda document: get_object_name(document.checkout_info().user))},
|
{'name': _('User'), 'attribute': encapsulate(lambda document: document.checkout_info().user.get_full_name() or document.checkout_info().user)},
|
||||||
{'name': _('Checkout time and date'), 'attribute': encapsulate(lambda document: document.checkout_info().checkout_datetime)},
|
{'name': _('Checkout time and date'), 'attribute': encapsulate(lambda document: document.checkout_info().checkout_datetime)},
|
||||||
{'name': _('Checkout expiration'), 'attribute': encapsulate(lambda document: document.checkout_info().expiration_datetime)},
|
{'name': _('Checkout expiration'), 'attribute': encapsulate(lambda document: document.checkout_info().expiration_datetime)},
|
||||||
],
|
],
|
||||||
@@ -91,7 +91,7 @@ def checkout_info(request, document_pk):
|
|||||||
|
|
||||||
if document.is_checked_out():
|
if document.is_checked_out():
|
||||||
checkout_info = document.checkout_info()
|
checkout_info = document.checkout_info()
|
||||||
paragraphs.append(_('User: %s') % get_object_name(checkout_info.user))
|
paragraphs.append(_('User: %s') % (checkout_info.user.get_full_name() or checkout_info.user))
|
||||||
paragraphs.append(_('Check out time: %s') % checkout_info.checkout_datetime)
|
paragraphs.append(_('Check out time: %s') % checkout_info.checkout_datetime)
|
||||||
paragraphs.append(_('Check out expiration: %s') % checkout_info.expiration_datetime)
|
paragraphs.append(_('Check out expiration: %s') % checkout_info.expiration_datetime)
|
||||||
paragraphs.append(_('New versions allowed: %s') % (_('Yes') if not checkout_info.block_new_version else _('No')))
|
paragraphs.append(_('New versions allowed: %s') % (_('Yes') if not checkout_info.block_new_version else _('No')))
|
||||||
|
|||||||
@@ -69,15 +69,6 @@ def get_descriptor(file_input, read=True):
|
|||||||
return file_input
|
return file_input
|
||||||
|
|
||||||
|
|
||||||
def get_object_name(obj):
|
|
||||||
if isinstance(obj, User):
|
|
||||||
label = obj.get_full_name() if obj.get_full_name() else obj
|
|
||||||
else:
|
|
||||||
label = unicode(obj)
|
|
||||||
|
|
||||||
return '%s' % (label)
|
|
||||||
|
|
||||||
|
|
||||||
# http://snippets.dzone.com/posts/show/5434
|
# http://snippets.dzone.com/posts/show/5434
|
||||||
# http://snippets.dzone.com/user/jakob
|
# http://snippets.dzone.com/user/jakob
|
||||||
def pretty_size(size, suffixes=None):
|
def pretty_size(size, suffixes=None):
|
||||||
@@ -124,7 +115,7 @@ def return_attrib(obj, attrib, arguments=None):
|
|||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
return 'Attribute error: %s; %s' % (attrib, exception)
|
return 'Attribute error: %s; %s' % (attrib, exception)
|
||||||
else:
|
else:
|
||||||
pass
|
return unicode(exception)
|
||||||
|
|
||||||
|
|
||||||
def urlquote(link=None, get=None):
|
def urlquote(link=None, get=None):
|
||||||
|
|||||||
Reference in New Issue
Block a user