Close issue #105, Tie smart links setups to document types
This commit is contained in:
@@ -3,6 +3,8 @@ from __future__ import absolute_import
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from documents.models import DocumentType
|
||||
|
||||
from .literals import INCLUSION_AND, INCLUSION_CHOICES, OPERATOR_CHOICES
|
||||
from .managers import SmartLinkManager
|
||||
|
||||
@@ -11,9 +13,13 @@ class SmartLink(models.Model):
|
||||
title = models.CharField(max_length=96, verbose_name=_(u'Title'))
|
||||
dynamic_title = models.CharField(blank=True, max_length=96, verbose_name=_(u'Dynamic title'), help_text=_(u'This expression will be evaluated against the current selected document. The document metadata is available as variables `metadata` and document properties under the variable `document`.'))
|
||||
enabled = models.BooleanField(default=True, verbose_name=_(u'Enabled'))
|
||||
document_types = models.ManyToManyField(DocumentType, verbose_name=_(u'Document types'))
|
||||
|
||||
objects = SmartLinkManager()
|
||||
|
||||
def get_document_types_not_selected(self):
|
||||
return DocumentType.objects.exclude(pk__in=self.document_types.all())
|
||||
|
||||
def __unicode__(self):
|
||||
return self.title
|
||||
|
||||
@@ -25,9 +31,9 @@ class SmartLink(models.Model):
|
||||
class SmartLinkCondition(models.Model):
|
||||
smart_link = models.ForeignKey(SmartLink, verbose_name=_(u'Smart link'))
|
||||
inclusion = models.CharField(default=INCLUSION_AND, max_length=16, choices=INCLUSION_CHOICES, help_text=_(u'The inclusion is ignored for the first item.'))
|
||||
foreign_document_data = models.CharField(max_length=32, verbose_name=_(u'Foreign document data'), help_text=_(u'This represents the metadata of all other documents. Available objects: `document.<attribute>` and `metadata.<metadata_type_name>`.'))
|
||||
foreign_document_data = models.CharField(max_length=32, verbose_name=_(u'Foreign document attribute'), help_text=_(u'This represents the metadata of all other documents.'))
|
||||
operator = models.CharField(max_length=16, choices=OPERATOR_CHOICES)
|
||||
expression = models.TextField(verbose_name=_(u'Expression'), help_text=_(u'This expression will be evaluated against the current selected document. The document metadata is available as variables `metadata` and document properties under the variable `document`.'))
|
||||
expression = models.TextField(verbose_name=_(u'Expression'), help_text=_(u'This expression will be evaluated against the current selected document.'))
|
||||
negated = models.BooleanField(default=False, verbose_name=_(u'Negated'), help_text=_(u'Inverts the logic of the operator.'))
|
||||
enabled = models.BooleanField(default=True, verbose_name=_(u'Enabled'))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user