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

View File

@@ -398,10 +398,12 @@ class DocumentVersion(models.Model):
verbose_name=_('File')
)
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(
blank=True, editable=False, max_length=64, null=True
blank=True, editable=False, max_length=64, null=True,
verbose_name=_('Encoding')
)
checksum = models.CharField(
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)
class TagAdmin(admin.ModelAdmin):
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
)
from .search import tag_search # NOQA
from .widgets import widget_document_tags, widget_single_tag
from .widgets import widget_document_tags
class TagsApp(MayanAppConfig):
@@ -73,8 +73,10 @@ class TagsApp(MayanAppConfig):
)
SourceColumn(
source=DocumentTag, label=_('Preview'),
func=lambda context: widget_single_tag(context['object'])
source=DocumentTag, attribute='label'
)
SourceColumn(
source=DocumentTag, attribute='get_preview_widget'
)
SourceColumn(
@@ -93,8 +95,10 @@ class TagsApp(MayanAppConfig):
)
SourceColumn(
source=Tag, label=_('Preview'),
func=lambda context: widget_single_tag(context['object'])
source=Tag, attribute='label'
)
SourceColumn(
source=Tag, attribute='get_preview_widget'
)
SourceColumn(
source=Tag, label=_('Documents'),

View File

@@ -12,6 +12,7 @@ from documents.models import Document
from documents.permissions import permission_document_view
from .events import event_tag_attach, event_tag_remove
from .widgets import widget_single_tag
@python_2_unicode_compatible
@@ -48,6 +49,10 @@ class Tag(models.Model):
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):
self.documents.remove(document)
event_tag_remove.commit(

View File

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