Пример #1
0
class DocumentPageTransformation(models.Model):
    """
    Model that stores the transformation and transformation arguments
    for a given document page
    """
    document_page = models.ForeignKey(DocumentPage,
                                      verbose_name=_(u'document page'))
    order = models.PositiveIntegerField(default=0,
                                        blank=True,
                                        null=True,
                                        verbose_name=_(u'order'),
                                        db_index=True)
    transformation = models.CharField(
        choices=get_available_transformations_choices(),
        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: %s') %
        u'{\'degrees\':90}',
        validators=[ArgumentsValidator()])
    objects = DocumentPageTransformationManager()

    def __unicode__(self):
        return self.get_transformation_display()

    class Meta:
        ordering = ('order', )
        verbose_name = _(u'document page transformation')
        verbose_name_plural = _(u'document page transformations')
Пример #2
0
class QueueTransformation(models.Model):
    '''
    Model that stores the transformation and transformation arguments
    for a given document queue
    '''
    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField()
    content_object = generic.GenericForeignKey('content_type', 'object_id')
    order = models.PositiveIntegerField(default=0,
                                        blank=True,
                                        null=True,
                                        verbose_name=_(u'order'),
                                        db_index=True)
    transformation = models.CharField(
        choices=get_available_transformations_choices(),
        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: %s') %
        u'{\'degrees\':90}',
        validators=[ArgumentsValidator()])

    objects = models.Manager()
    transformations = SourceTransformationManager()

    def __unicode__(self):
        return self.get_transformation_display()

    class Meta:
        ordering = ('order', )
        verbose_name = _(u'document queue transformation')
        verbose_name_plural = _(u'document queue transformations')