Remove some label argument from the apps module and move them to the model.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2018-04-16 15:20:16 -04:00
parent 6839f1b529
commit 6a65544fb7
6 changed files with 36 additions and 25 deletions

View File

@@ -212,7 +212,7 @@ class DocumentsApp(MayanAppConfig):
) )
) )
SourceColumn( SourceColumn(
source=Document, label=_('Type'), attribute='document_type' source=Document, attribute='document_type'
) )
SourceColumn( SourceColumn(
source=Document, label=_('Pages'), source=Document, label=_('Pages'),
@@ -263,11 +263,10 @@ class DocumentsApp(MayanAppConfig):
) )
SourceColumn( SourceColumn(
source=DeletedDocument, label=_('Type'), attribute='document_type' source=DeletedDocument, attribute='document_type'
) )
SourceColumn( SourceColumn(
source=DeletedDocument, label=_('Date time trashed'), source=DeletedDocument, attribute='deleted_date_time'
attribute='deleted_date_time'
) )
# DocumentVersion # DocumentVersion
@@ -278,8 +277,7 @@ class DocumentsApp(MayanAppConfig):
) )
) )
SourceColumn( SourceColumn(
source=DocumentVersion, label=_('Time and date'), source=DocumentVersion, attribute='timestamp'
attribute='timestamp'
) )
SourceColumn( SourceColumn(
source=DocumentVersion, label=_('Pages'), source=DocumentVersion, label=_('Pages'),
@@ -288,16 +286,13 @@ class DocumentsApp(MayanAppConfig):
) )
) )
SourceColumn( SourceColumn(
source=DocumentVersion, label=_('MIME type'), source=DocumentVersion, attribute='mimetype'
attribute='mimetype'
) )
SourceColumn( SourceColumn(
source=DocumentVersion, label=_('Encoding'), source=DocumentVersion, attribute='encoding'
attribute='encoding'
) )
SourceColumn( SourceColumn(
source=DocumentVersion, label=_('Comment'), source=DocumentVersion, attribute='comment'
attribute='comment'
) )
# DuplicatedDocument # DuplicatedDocument

View File

@@ -398,10 +398,12 @@ class DocumentVersion(models.Model):
verbose_name=_('File') verbose_name=_('File')
) )
mimetype = models.CharField( mimetype = models.CharField(
blank=True, editable=False, max_length=255, null=True blank=True, editable=False, max_length=255, null=True,
verbose_name=_('MIME type')
) )
encoding = models.CharField( encoding = models.CharField(
blank=True, editable=False, max_length=64, null=True blank=True, editable=False, max_length=64, null=True,
verbose_name=_('Encoding')
) )
checksum = models.CharField( checksum = models.CharField(
blank=True, db_index=True, editable=False, max_length=64, null=True, blank=True, db_index=True, editable=False, max_length=64, null=True,

View File

@@ -8,4 +8,4 @@ from .models import Tag
@admin.register(Tag) @admin.register(Tag)
class TagAdmin(admin.ModelAdmin): class TagAdmin(admin.ModelAdmin):
filter_horizontal = ('documents',) filter_horizontal = ('documents',)
list_display = ('label', 'color') list_display = ('label', 'color', 'get_preview_widget')

View File

@@ -25,7 +25,7 @@ from .permissions import (
permission_tag_remove, permission_tag_view permission_tag_remove, permission_tag_view
) )
from .search import tag_search # NOQA from .search import tag_search # NOQA
from .widgets import widget_document_tags, widget_single_tag from .widgets import widget_document_tags
class TagsApp(MayanAppConfig): class TagsApp(MayanAppConfig):
@@ -73,8 +73,10 @@ class TagsApp(MayanAppConfig):
) )
SourceColumn( SourceColumn(
source=DocumentTag, label=_('Preview'), source=DocumentTag, attribute='label'
func=lambda context: widget_single_tag(context['object']) )
SourceColumn(
source=DocumentTag, attribute='get_preview_widget'
) )
SourceColumn( SourceColumn(
@@ -93,8 +95,10 @@ class TagsApp(MayanAppConfig):
) )
SourceColumn( SourceColumn(
source=Tag, label=_('Preview'), source=Tag, attribute='label'
func=lambda context: widget_single_tag(context['object']) )
SourceColumn(
source=Tag, attribute='get_preview_widget'
) )
SourceColumn( SourceColumn(
source=Tag, label=_('Documents'), source=Tag, label=_('Documents'),

View File

@@ -12,6 +12,7 @@ from documents.models import Document
from documents.permissions import permission_document_view from documents.permissions import permission_document_view
from .events import event_tag_attach, event_tag_remove from .events import event_tag_attach, event_tag_remove
from .widgets import widget_single_tag
@python_2_unicode_compatible @python_2_unicode_compatible
@@ -48,6 +49,10 @@ class Tag(models.Model):
return queryset.count() return queryset.count()
def get_preview_widget(self):
return widget_single_tag(tag=self)
get_preview_widget.short_description = _('Preview')
def remove_from(self, document, user=None): def remove_from(self, document, user=None):
self.documents.remove(document) self.documents.remove(document)
event_tag_remove.commit( event_tag_remove.commit(

View File

@@ -181,6 +181,7 @@ class TagListView(SingleObjectListView):
def get_extra_context(self): def get_extra_context(self):
return { return {
'hide_link': True, 'hide_link': True,
'hide_object': True,
'title': _('Tags'), 'title': _('Tags'),
} }
@@ -224,11 +225,15 @@ class DocumentTagListView(TagListView):
) )
def get_extra_context(self): def get_extra_context(self):
return { context = super(DocumentTagListView, self).get_extra_context()
'hide_link': True, context.update(
'object': self.document, {
'title': _('Tags for document: %s') % self.document, 'hide_link': True,
} 'object': self.document,
'title': _('Tags for document: %s') % self.document,
}
)
return context
def get_tag_queryset(self): def get_tag_queryset(self):
return self.document.attached_tags().all() return self.document.attached_tags().all()