Ejemplo n.º 1
0
    metadata_type = models.ForeignKey(MetadataType, verbose_name=_(u'metadata type'), help_text=_(u'This represents the metadata of all other documents.'))
    operator = models.CharField(max_length=16, choices=OPERATOR_CHOICES)
    expression = models.CharField(max_length=128,
        verbose_name=_(u'expression'), help_text=_(u'This expression will be evaluated against the current seleted document.  The document metadata is available as variables of the same name but with the "metadata_" prefix added their name.'))
    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'))
    
    def __unicode__(self):
        return '[%s] %s %s %s %s %s' % ('x' if self.enabled else ' ', self.get_inclusion_display(), self.metadata_type, _(u'not') if self.negated else '', self.get_operator_display(), self.expression)

    class Meta:
        verbose_name = _(u'metadata group item')
        verbose_name_plural = _(u'metadata group items')


available_transformations = ([(name, data['label']) for name, data in AVAILABLE_TRANSFORMATIONS.items()]) if AVAILABLE_MODELS else []

    
class DocumentPageTransformation(models.Model):
    document_page = models.ForeignKey(DocumentPage, verbose_name=_(u'document page'))
    order = models.PositiveIntegerField(default=0, blank=True, null=True, verbose_name=_(u'order'))
    transformation = models.CharField(choices=available_transformations, max_length=128, verbose_name=_(u'transformation'))
    arguments = models.TextField(blank=True, null=True, verbose_name=_(u'arguments'), help_text=_(u'Use dictionaries to indentify arguments, example: {\'degrees\':90}'))

    def __unicode__(self):
        return '%s - %s' % (unicode(self.document_page), self.get_transformation_display())

    class Meta:
        ordering = ('order',)
        verbose_name = _(u'document page transformation')
        verbose_name_plural = _(u'document page transformations')
Ejemplo n.º 2
0
        help_text=_(u'Inverts the logic of the operator.'))
    enabled = models.BooleanField(default=True, verbose_name=_(u'enabled'))

    def __unicode__(self):
        return '[%s] %s %s %s %s %s' % (
            'x' if self.enabled else ' ', self.get_inclusion_display(),
            self.metadata_type, _(u'not') if self.negated else '',
            self.get_operator_display(), self.expression)

    class Meta:
        verbose_name = _(u'metadata group item')
        verbose_name_plural = _(u'metadata group items')


available_transformations = ([
    (name, data['label']) for name, data in AVAILABLE_TRANSFORMATIONS.items()
]) if AVAILABLE_MODELS else []


class DocumentPageTransformation(models.Model):
    document_page = models.ForeignKey(DocumentPage,
                                      verbose_name=_(u'document page'))
    order = models.PositiveIntegerField(default=0,
                                        blank=True,
                                        null=True,
                                        verbose_name=_(u'order'))
    transformation = models.CharField(choices=available_transformations,
                                      max_length=128,
                                      verbose_name=_(u'transformation'))
    arguments = models.TextField(
        blank=True,