def checkout_info(request, document_pk): document = get_object_or_404(Document, pk=document_pk) try: Permission.check_permissions( request.user, ( permission_document_checkout, permission_document_checkin ) ) except PermissionDenied: AccessControlList.objects.check_access( (permission_document_checkout, permission_document_checkin), request.user, document ) paragraphs = [ _('Document status: %s') % STATE_LABELS[document.checkout_state()] ] if document.is_checked_out(): checkout_info = document.checkout_info() paragraphs.append( _('User: %s') % ( checkout_info.user.get_full_name() or checkout_info.user ) ) paragraphs.append( _( 'Check out time: %s' ) % render_date_object(checkout_info.checkout_datetime) ) paragraphs.append( _( 'Check out expiration: %s' ) % render_date_object(checkout_info.expiration_datetime) ) paragraphs.append( _( 'New versions allowed: %s' ) % (_('Yes') if not checkout_info.block_new_version else _('No')) ) return render_to_response( 'appearance/generic_template.html', { 'paragraphs': paragraphs, 'object': document, 'title': _('Check out details for document: %s') % document }, context_instance=RequestContext(request) )
def get_form(self): document = self.get_object() document_fields = [ { 'label': _('Date added'), 'field': lambda document: render_date_object(document.date_added) }, { 'label': _('UUID'), 'field': 'uuid' }, ] if document.latest_version: document_fields.extend([ { 'label': _('File mimetype'), 'field': lambda x: document.file_mimetype or _('None') }, { 'label': _('File encoding'), 'field': lambda x: document.file_mime_encoding or _('None') }, { 'label': _('File size'), 'field': lambda document: filesizeformat(document.size) if document.size else '-' }, { 'label': _('Exists in storage'), 'field': 'exists' }, { 'label': _('File path in storage'), 'field': 'latest_version.file' }, { 'label': _('Checksum'), 'field': 'checksum' }, { 'label': _('Pages'), 'field': 'page_count' }, ]) return DocumentPropertiesForm(instance=document, extra_fields=document_fields)
def get_form(self): document = self.get_object() document_fields = [ { 'label': _('Date added'), 'field': lambda document: render_date_object( document.date_added ) }, {'label': _('UUID'), 'field': 'uuid'}, ] if document.latest_version: document_fields.extend([ { 'label': _('File mimetype'), 'field': lambda x: document.file_mimetype or _('None') }, { 'label': _('File encoding'), 'field': lambda x: document.file_mime_encoding or _( 'None' ) }, { 'label': _('File size'), 'field': lambda document: filesizeformat( document.size ) if document.size else '-' }, {'label': _('Exists in storage'), 'field': 'exists'}, { 'label': _('File path in storage'), 'field': 'latest_version.file' }, {'label': _('Checksum'), 'field': 'checksum'}, {'label': _('Pages'), 'field': 'page_count'}, ]) return DocumentPropertiesForm( instance=document, extra_fields=document_fields )