Style updates.
This commit is contained in:
@@ -36,14 +36,6 @@ class MetadataType(models.Model):
|
|||||||
Define a type of metadata
|
Define a type of metadata
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def comma_splitter(string):
|
|
||||||
splitter = shlex.shlex(string.encode('utf-8'), posix=True)
|
|
||||||
splitter.whitespace = ','.encode('utf-8')
|
|
||||||
splitter.whitespace_split = True
|
|
||||||
splitter.commenters = ''.encode('utf-8')
|
|
||||||
return list(splitter)
|
|
||||||
|
|
||||||
name = models.CharField(
|
name = models.CharField(
|
||||||
max_length=48,
|
max_length=48,
|
||||||
help_text=_(
|
help_text=_(
|
||||||
@@ -94,6 +86,19 @@ class MetadataType(models.Model):
|
|||||||
def natural_key(self):
|
def natural_key(self):
|
||||||
return (self.name,)
|
return (self.name,)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
ordering = ('label',)
|
||||||
|
verbose_name = _('Metadata type')
|
||||||
|
verbose_name_plural = _('Metadata types')
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def comma_splitter(string):
|
||||||
|
splitter = shlex.shlex(string.encode('utf-8'), posix=True)
|
||||||
|
splitter.whitespace = ','.encode('utf-8')
|
||||||
|
splitter.whitespace_split = True
|
||||||
|
splitter.commenters = ''.encode('utf-8')
|
||||||
|
return list(splitter)
|
||||||
|
|
||||||
def get_default_value(self):
|
def get_default_value(self):
|
||||||
template = Template(self.default)
|
template = Template(self.default)
|
||||||
context = Context()
|
context = Context()
|
||||||
@@ -134,11 +139,6 @@ class MetadataType(models.Model):
|
|||||||
|
|
||||||
return value
|
return value
|
||||||
|
|
||||||
class Meta:
|
|
||||||
ordering = ('label',)
|
|
||||||
verbose_name = _('Metadata type')
|
|
||||||
verbose_name_plural = _('Metadata types')
|
|
||||||
|
|
||||||
|
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
class DocumentMetadata(models.Model):
|
class DocumentMetadata(models.Model):
|
||||||
@@ -146,6 +146,7 @@ class DocumentMetadata(models.Model):
|
|||||||
Link a document to a specific instance of a metadata type with it's
|
Link a document to a specific instance of a metadata type with it's
|
||||||
current value
|
current value
|
||||||
"""
|
"""
|
||||||
|
|
||||||
document = models.ForeignKey(
|
document = models.ForeignKey(
|
||||||
Document, related_name='metadata', verbose_name=_('Document')
|
Document, related_name='metadata', verbose_name=_('Document')
|
||||||
)
|
)
|
||||||
@@ -181,17 +182,17 @@ class DocumentMetadata(models.Model):
|
|||||||
document_type=self.document.document_type, value=self.value
|
document_type=self.document.document_type, value=self.value
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
unique_together = ('document', 'metadata_type')
|
||||||
|
verbose_name = _('Document metadata')
|
||||||
|
verbose_name_plural = _('Document metadata')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_required(self):
|
def is_required(self):
|
||||||
return self.metadata_type.get_required_for(
|
return self.metadata_type.get_required_for(
|
||||||
document_type=self.document.document_type
|
document_type=self.document.document_type
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
|
||||||
unique_together = ('document', 'metadata_type')
|
|
||||||
verbose_name = _('Document metadata')
|
|
||||||
verbose_name_plural = _('Document metadata')
|
|
||||||
|
|
||||||
|
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
class DocumentTypeMetadataType(models.Model):
|
class DocumentTypeMetadataType(models.Model):
|
||||||
|
|||||||
@@ -24,16 +24,16 @@ class Tag(models.Model):
|
|||||||
Document, related_name='tags', verbose_name=_('Documents')
|
Document, related_name='tags', verbose_name=_('Documents')
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
|
||||||
verbose_name = _('Tag')
|
|
||||||
verbose_name_plural = _('Tags')
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.label
|
return self.label
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('tags:tag_tagged_item_list', args=(str(self.pk),))
|
return reverse('tags:tag_tagged_item_list', args=(str(self.pk),))
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
verbose_name = _('Tag')
|
||||||
|
verbose_name_plural = _('Tags')
|
||||||
|
|
||||||
def get_document_count(self, user):
|
def get_document_count(self, user):
|
||||||
queryset = self.documents
|
queryset = self.documents
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user