예제 #1
0
class ReplyPost(AbstractPost):
    mainpost = models.ForeignKey(MainPost, related_name="replies", null=False)
    current_revision = models.OneToOneField('ReplyPostRevision',
                                            blank=True,
                                            null=True,
                                            verbose_name=_('current revision'),
                                            related_name="revision_post")
    best_answer = models.BooleanField(default=False)

    reply_post_comments = GenericRelation("utils.Comment")

    replypost_votes = GenericRelation("utils.Vote")

    def __unicode__(self):
        return "reply to:" + self.mainpost.title

    def get_absolute_url(self):
        return reverse('posts:post-detail', kwargs={'pk': self.mainpost.pk})

    def get_vote_count(self):
        return self.replypost_votes.filter(
            choice=1).count() - self.replypost_votes.filter(choice=-1).count()

    def get_comments(self):
        return self.reply_post_comments.all()
예제 #2
0
class Food(models.Model):
    name = models.CharField(max_length=100)

    ratings = GenericRelation(Rating)
    char_gfk = GenericRelation(CharFieldGFK)

    def __unicode__(self):
        return self.name
예제 #3
0
class Tool(models.Model):
    # other than the tool specific information, the other parts are the same as the wiki page. 
    page = models.OneToOneField("wiki.Page", related_name="software")
    # tool information
    name = models.CharField(max_length=255, blank=True, unique=True)
    image = models.ImageField(upload_to='software',null=True,blank=True)
    url = models.URLField(max_length=255,blank=True)
    language = models.CharField(max_length=255,blank=True)
    OS = models.CharField(max_length=255,blank=True)
    # license
    citation = models.CharField(max_length=255, blank=True)
    availability = models.CharField(max_length=255, blank=True)
    # author information
    author_name = models.CharField(max_length=255,blank=True)
    author_affiliation = models.CharField(max_length=255, blank=True)
    ## how the author prefer to be contacted wtih the tool problems.
    author_contacts = models.CharField(max_length=255, blank=True)
    #### we can add the author to the model if the author is using this website. 
    # author = models.ForeignKey('users.User')
    # release information
    first_release_date = models.DateField(null=True)
    latest_release_date = models.DateField(null=True)
    # feedbacks
    tool_votes = GenericRelation("utils.Vote")
    tool_comment = GenericRelation("utils.Comment")
    
    vote_count = models.IntegerField(default=0)
    bug_count = models.IntegerField(default=0)
    
    # status
    PUBLIC, PROTECTED, FREEZED = range(3)
    STATUS_CHOICE = [(PUBLIC,'open to public'), (PROTECTED,'protected'), (FREEZED,'freezed')]
    #status = models.IntergerField(choices=STATUS_CHOICE,default=0)

    def get_absolute_url(self):
        return reverse('software:software-detail', kwargs={'name':self.name})

    def get_vote_count(self):
        return self.tool_votes.filter(choice=1).count() - self.tool_votes.filter(choice=-1).count()

    @classmethod
    def create(cls, name, author):
        wiki_page, created = Page.objects.get_or_create(title=name)
        if created == True: 
            new_revision = PageRevision(content='', revision_summary='',page=wiki_page, author=author)
            new_revision.save()
            wiki_page.current_revision = new_revision
            wiki_page.save()
        tag, created = Tag.objects.get_or_create(wiki_page=wiki_page)
        if created == True: 
            tag.name = name
            tag.categories = 2
            tag.save()
        tool = cls(name=name, page=wiki_page)
        return tool
예제 #4
0
class Task(Model):
    """An abstract class that represents something to be executed."""
    
    __metaclass__ = MetaTask
    class Meta:
        app_label = 'core'
        abstract = True
    
    name = CharField(max_length=128, unique=True, null=True)
    description = CharField(max_length=512, blank=True, default='')
    date_added = DateTimeField(default=datetime.utcnow)
    timeout = PositiveIntegerField(default=0)
    instances = GenericRelation('Instance',
        content_type_field='task_type', object_id_field='task_id')
    
    schedules = GenericRelation('Schedule',
        content_type_field='task_type', object_id_field='task_id')
    cronschedules = GenericRelation('CronSchedule',
        content_type_field='task_type', object_id_field='task_id')
    
    def start(self, instance):
        """ A hook function for easily changing the parameters to run().
        
        This is useful because some types of task (such as Job) need access
        to the instance object that is currently running, but we don't want
        to make run have any parameters by default.
        
        """
        return self.run()
    
    def run(self):
        """The actual work of the Task should be done in this function."""
        raise NotImplementedError
    
    def get_name(self):
        return self.name or ("#%s" % self.id if self.id
            else False) or "(nameless)"
    
    def get_revision(self):
        """ Hook to provide revision tracking functionality for instances.
        
        The value returned by this function will be retrieved and set for
        each instance of the task that is run.
        
        """
        return None
    
    def __unicode__(self):
        return u"[%s %s]" % (type(self).__name__, self.get_name())
    
    __repr__ = __unicode__
예제 #5
0
class Company(models.Model):
    """Company model."""
    name = models.CharField(_('name'), max_length=200)
    nickname = models.CharField(_('nickname'), max_length=50, blank=True,
        null=True)
    slug = models.SlugField(_('slug'), max_length=50, unique=True)
    about = models.TextField(_('about'), blank=True, null=True)
    logo = models.ImageField(_('photo'), upload_to='contacts/companies/', blank=True)   

    phone_number = GenericRelation('PhoneNumber')
    email_address = GenericRelation('EmailAddress')
    #instant_messenger = GenericRelation('InstantMessenger')
    web_site = GenericRelation('WebSite')
    street_address = GenericRelation('StreetAddress')
    special_date = GenericRelation('SpecialDate')

    date_added = models.DateTimeField(_('date added'), auto_now_add=True)
    date_modified = models.DateTimeField(_('date modified'), auto_now=True)

    class Meta:
        abstract = True
        #db_table = 'contacts_companies'
        ordering = ('name',)
        verbose_name = _('company')
        verbose_name_plural = _('companies')

    def __unicode__(self):
        return u"%s" % self.name

    @permalink
    def get_absolute_url(self):
        return ('contacts_company_detail', None, {
            'pk': self.pk,
            'slug': self.slug,
        })

    @permalink
    def get_update_url(self):
        return ('contacts_company_update', None, {
            'pk': self.pk,
            'slug': self.slug,
        })
    
    @permalink
    def get_delete_url(self):
        return ('contacts_company_delete', None, {
            'pk': self.pk,
            'slug': self.slug,
        })
예제 #6
0
class Comment(models.Model):
    content = models.TextField(max_length=600,
                               null=False,
                               verbose_name=_("content"))
    author = models.ForeignKey(settings.AUTH_USER_MODEL,
                               verbose_name=_("author"))
    vote_count = models.IntegerField(default=0)
    comment_votes = GenericRelation("Vote")
    created = models.DateTimeField(verbose_name=_("created time"))
    last_modified = models.DateTimeField()
    ## enable generic foreign key relationship with other classes, such as Page, MainPost, ReplyPost.
    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField()
    content_object = GenericForeignKey('content_type', 'object_id')

    def __unicode__(self):
        return self.content[:25]

    def save(self, *args, **kwargs):
        ''' On save, update timestamps '''
        if not self.created:
            self.created = timezone.now()
        self.last_modified = timezone.now()
        return super(Comment, self).save(*args, **kwargs)

    def get_vote_count(self):
        return self.comment_votes.filter(
            choice=1).count() - self.comment_votes.filter(choice=-1).count()

    class Meta:
        get_latest_by = "-last_modified"
예제 #7
0
class Timesheet(models.Model):
    job = models.CharField(_('job'), max_length=200)
    date = models.DateField(_('date'))
    time = models.TimeField(_('time'))
    person = models.ForeignKey(User)
    hours = models.DecimalField(_('hours'), max_digits=4, decimal_places=2)

    pceo = models.IntegerField(_('Printable CEO'),
                               blank=True,
                               null=True,
                               choices=PRINTABLE_CEO_CHOICES,
                               help_text=_('When is something Worth Doing?'))
    note = GenericRelation(Comment, object_id_field='object_pk')

    content_type = models.ForeignKey(ContentType, blank=True, null=True)
    object_id = models.PositiveIntegerField(blank=True, null=True)
    content_object = generic.GenericForeignKey('content_type', 'object_id')

    date_added = models.DateTimeField(_('date added'), auto_now_add=True)
    date_modified = models.DateTimeField(_('date modified'), auto_now=True)

    class Meta:
        verbose_name = _('timesheet')
        verbose_name_plural = _('timesheets')
        db_table = 'timesheets'
        ordering = ('-date', 'hours')

    def __unicode__(self):
        return u"%s %s - %s" % (self.person.first_name, self.person.last_name,
                                self.date)
예제 #8
0
 def post_through_setup(self, cls):
     self.use_gfk = (self.through is None
                     or issubclass(self.through, GenericTaggedItemBase))
     self.rel.to = self.through._meta.get_field("tag").rel.to
     if self.use_gfk:
         tagged_items = GenericRelation(self.through)
         tagged_items.contribute_to_class(cls, "tagged_items")
예제 #9
0
class ModelWithAuthor(models.Model):
    name = models.CharField(max_length=50)
    author = models.ForeignKey(User)
    flagged = GenericRelation(FlaggedContent)

    def __unicode__(self):
        return self.name
예제 #10
0
class Thread(models.Model):
    creator = models.ForeignKey(User)
    title = models.CharField(max_length=256)
    text = models.TextField()
    comments_enabled = models.BooleanField(default=True)
    tags = models.ManyToManyField(Tag, blank=True, null=True)
    category = models.ForeignKey(
        Category,
        on_delete=models.PROTECT)  #perhaps try a query with Models.SET()
    date_posted = models.DateTimeField(auto_now_add=True)
    date_published = models.DateTimeField(default=now)
    is_public = models.BooleanField(default=True, blank=True)
    is_removed = models.BooleanField(default=False, blank=True)
    comments = GenericRelation(Comment, object_id_field="object_pk")
    #needs date_modified
    #managers
    objects = ThreadManager()
    public = PublicSetManager()

    #private = PrivateThreadManager()
    #removed = RemovedThreadManager()
    def clean(self):
        if self.is_public == True and self.is_removed == True:
            raise ValidationError('Removed threads cannot also be public.')
        super(Thread, self).clean()

    def __unicode__(self):
        return self.title

    def get_absolute_url(self):
        return reverse('thread:view', kwargs={'pk': str(self.pk)})

    def is_published(self):
        return (self.date_published.replace(tzinfo=utc) -
                now()).total_seconds() <= 0  #is today >= date_published
예제 #11
0
class Music(models.Model):
    name = models.CharField(max_length=20)
    album = models.ForeignKey(Album)
    tags = GenericRelation(Tag)

    def __str__(self):
        return self.name
예제 #12
0
class MyBaseModel(models.Model):
    # basic value fields
    name = models.CharField(default=None, max_length=128, verbose_name=u'名称')
    abbrev = models.CharField(max_length=128, verbose_name=u'Abbrev')
    eng_name = models.CharField(max_length=256,
                                null=True,
                                blank=True,
                                verbose_name=u'Name (eng)')
    description = models.TextField(null=True, blank=True, verbose_name=u'描述')

    # help text
    help_text = models.CharField(max_length=64,
                                 null=True,
                                 blank=True,
                                 verbose_name=u'帮助提示')

    # Optional reference URL where this record's
    # information is obtained.
    ref = models.URLField(null=True, blank=True)

    # attachments
    attachments = GenericRelation('Attachment')

    # this is an Abstract model
    class Meta:
        abstract = True

    def __unicode__(self):
        return self.name
예제 #13
0
class Player(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    attributes = GenericRelation('Attribute')
    game = models.ForeignKey(Game)

    def __str__(self):
        return self.user.username
예제 #14
0
class LayoutBlock(ContentBlock):
    BOOTSTRAP_MAX_WIDTH = 12
    containers = GenericRelation('fancypages.Container')

    class Meta:
        abstract = True
        app_label = 'fancypages'
예제 #15
0
class Temporary(Model):
    class Meta:
        verbose_name = _('temporary')
        verbose_name_plural = _('temporary')

    attachments = GenericRelation(Attachment)
    created = DateTimeField(_('created'), auto_now_add=True)
    modified = DateTimeField(_('modified'), auto_now=True)
예제 #16
0
class Person(models.Model):
	"""Person model."""
	first_name = models.CharField(_('first name'), max_length=100)
	last_name = models.CharField(_('last name'), max_length=200)
	middle_name = models.CharField(_('middle name'), max_length=200, blank=True, null=True)
	suffix = models.CharField(_('suffix'), max_length=50, blank=True, null=True)
	nickname = models.CharField(_('nickname'), max_length=100, blank=True)
	slug = models.SlugField(_('slug'), max_length=50, unique=True)
	title = models.CharField(_('title'), max_length=200, blank=True)
	company = models.ForeignKey(Company, blank=True, null=True)
	about = models.TextField(_('about'), blank=True)
	photo = models.ImageField(_('photo'), upload_to='contacts/person/', blank=True)
	
	user = models.OneToOneField(settings.AUTH_USER_MODEL, blank=True, null=True,
		verbose_name=_('user'))
	
	phone_number = GenericRelation('PhoneNumber')
	email_address = GenericRelation('EmailAddress')
	instant_messenger = GenericRelation('InstantMessenger')
	web_site = GenericRelation('WebSite')
	street_address = GenericRelation('StreetAddress')
	special_date = GenericRelation('SpecialDate')
	note = GenericRelation(Comment, object_id_field='object_pk')
	
	date_added = models.DateTimeField(_('date added'), auto_now_add=True)
	date_modified = models.DateTimeField(_('date modified'), auto_now=True)
	
	class Meta:
		db_table = 'contacts_people'
		ordering = ('last_name', 'first_name')
		verbose_name = _('person')
		verbose_name_plural = _('people')
	
	def __unicode__(self):
		return self.fullname
	
	@property
	def fullname(self):
		return u"%s %s" % (self.first_name, self.last_name)
	
	@permalink
	def get_absolute_url(self):
		return ('contacts_person_detail', None, {
		    'pk': self.pk,
			'slug': self.slug,
		})
	
	@permalink
	def get_update_url(self):
		return ('contacts_person_update', None, {
		    'pk': self.pk,
			'slug': self.slug,
		})
	
	@permalink
	def get_delete_url(self):
		return ('contacts_person_delete', None, {
		    'pk': self.pk,
			'slug': self.slug,
		})
예제 #17
0
class Bookmark(models.Model):
    """
    A URL bookmark that may have multiple tags attached.
    """
    url = models.URLField()
    tags = GenericRelation(Tag)

    def __str__(self):
        return 'Bookmark: %s' % self.url
예제 #18
0
class Note(models.Model):
    """
    A textual note that may have multiple tags attached.
    """
    text = models.TextField()
    tags = GenericRelation(Tag)

    def __str__(self):
        return 'Note: %s' % self.text
예제 #19
0
class TaggedModel(models.Model):
    tags = GenericRelation(Tag)

    @denormalized(models.TextField)
    @depend_on_related(Tag)
    def tags_string(self):
        return ', '.join(sorted([t.name for t in self.tags.all()]))

    class Meta:
        abstract = True
예제 #20
0
파일: models.py 프로젝트: yaznagv/fi-admin
class Event(Generic):

    class Meta:
        verbose_name = _("Event")
        verbose_name_plural = _("Events")

    STATUS_CHOICES = (
        (0, _('Pending')),
        (1, _('Admitted')),
        (2, _('Refused')),
        (3, _('Deleted')),
    )

    status = models.SmallIntegerField(_('Status'), choices=STATUS_CHOICES, null=True, default=0)
    not_regional_event = models.BooleanField(_('Do not publish in the regional event directory'), default=False)

    title = models.CharField(_('Title'), max_length=455, blank=False, help_text=_("Enter the full name of the event, as it appears and in the same language. Ex: XIX Congresso Brasileiro de Arritmias Cardiacas. XVII Simposio Nacional do DECS-SBCC"))
    start_date = models.DateField(_('Start date'), help_text='DD/MM/YYYY')
    end_date = models.DateField(_('End date'), help_text='DD/MM/YYYY')

    link = models.URLField(_('Link'), max_length=255, help_text=_("Enter the link of event portal"), blank=True)

    address = models.CharField(_('Address'), max_length=255, blank=True, help_text=_("Enter full address of the local of the event to present it in a Google map"))
    city = models.CharField(_('City'), max_length=125, blank=True)
    country = models.ForeignKey(Country, verbose_name=_('Country'), blank=True, null=True)

    event_type = models.ManyToManyField(EventType, verbose_name=_("Event type"), blank=False)
    official_language = models.ManyToManyField('main.SourceLanguage', verbose_name=_("Official languages"), blank=True)

    contact_email = models.EmailField(_('Contact email'), blank=True)
    contact_info = models.TextField(_("Information for contact"), blank=True)
    observations = models.TextField(_("Observations"), help_text=_("Enter information about institutions that organize and/or sponsor the event, deadline for submission of papers, simultaneous translation service, event program, etc."), blank=True)
    target_groups = models.TextField(_("Target groups"), blank=True)

    # responsible cooperative center
    cooperative_center_code = models.CharField(_('Cooperative center'), max_length=55, blank=True)

    # relations
    error_reports = GenericRelation(ErrorReport)
    thematics = GenericRelation(ResourceThematic)

    def __unicode__(self):
        return self.title
예제 #21
0
class Article(models.Model):
    title = models.CharField(max_length=100)
    content = models.TextField()
    attachments = GenericRelation(Attachment)

    def __unicode__(self):
        return self.title

    def get_absolute_url(self):
        return reverse('article', kwargs={'pk': str(self.pk)})
예제 #22
0
class Deck(models.Model):
    #information
    title = models.CharField(max_length=128)
    creator = models.ForeignKey(User)
    tags = models.ManyToManyField(Tag, blank=True, null=True)
    text = models.TextField(blank=True, null=True)

    #record
    date_posted = models.DateField(auto_now_add=True)
    challenge = models.ForeignKey(Challenge,
                                  null=True,
                                  blank=True,
                                  on_delete=models.SET_NULL)  #just one
    is_public = models.BooleanField(blank=True, default=True)
    is_removed = models.BooleanField(blank=True, default=False)

    #data
    deck_image = models.ImageField(upload_to="img/%Y/%m/%d")
    comments = GenericRelation(Comment, object_id_field="object_pk")
    polls = GenericRelation(BinaryPoll, object_id_field="object_id")
    deck_length_coefficient = models.SmallIntegerField()
    deck_width_coefficient = models.SmallIntegerField()

    #managers
    objects = models.Manager()
    public = PublicSetManager()

    class Meta():
        get_latest_by = 'date_posted'

    #methods
    def clean(self):
        #needs to check that any attached challenges are not expired
        if self.is_public == True and self.is_removed == True:
            raise ValidationError('Removed entries cannot also be public.')
        super(Deck, self).clean()

    def __unicode__(self):
        return self.title

    def get_absolute_url(self):
        return reverse('deck:view', kwargs={'pk': str(self.pk)})
예제 #23
0
class LegislatorDetail(models.Model):

    objects = LegislatorDetailManager()

    legislator = models.OneToOneField(Politician)

    on_bill = models.CharField(max_length=1,
                               choices=ON_BILL_CHOICES,
                               default='U')
    on_amendment = models.NullBooleanField(default=None)
    call_goal = models.SmallIntegerField(default=10)

    calls = GenericRelation(AnswerSet)

    def __unicode__(self):
        return u' '.join([
            self.legislator.get_title_display(),
            self.good_fname(), self.legislator.lastname
        ])

    def good_fname(self):
        return self.legislator.nickname or self.legislator.firstname

    def is_cosponsor(self):
        return self.on_bill == 'C'

    def supports_bill(self):
        if self.on_bill in ('C', 'S'):
            return True
        elif self.on_bill == 'O':
            return False
        else:
            return None

    def he_or_she(self):
        if self.legislator.gender == 'F':
            return 'she'
        else:
            return 'he'

    def his_or_her(self):
        if self.legislator.gender == 'F':
            return 'her'
        else:
            return 'his'

    def him_or_her(self):
        if self.legislator.gender == 'F':
            return 'her'
        else:
            return 'him'

    def needs_more_calls(self):
        return self.calls.count() < self.call_goal
예제 #24
0
class ItemInstance(ActionInstance):
    """
    An instance of a single item
    """
    owner = models.ForeignKey(Player, on_delete=models.CASCADE)
    itype = models.ForeignKey(Item, on_delete=models.CASCADE)
    attributes = GenericRelation(Attribute)

    def transfer(self, newowner):
        self.owner = newowner
        self.save()
        return "You have successfully transfered the item " + self.itype.name
예제 #25
0
class PurchaseItem(models.Model):
    invoice = models.ForeignKey(PurchaseInvoice,
                                verbose_name=_(u'Purchase invoice'))
    material = models.ForeignKey(Material, verbose_name=_(u'Material'))
    material_cluster = models.OneToOneField(
        MaterialCluster, verbose_name=_(u'Created material cluster'))
    movement = GenericRelation('MaterialMovement')
    quantity = models.PositiveIntegerField(_(u'Quantity'))
    unit_cost = models.DecimalField(_(u'Unit cost'),
                                    max_digits=20,
                                    decimal_places=2)

    @property
    def total_cost(self):
        return self.unit_cost * self.quantity

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

    def __unicode__(self):
        return _(
            u"%(quantity)s %(measure_unit)s of %(material)s (invoice nr. %(number)s-%(serie)s:)"
        ) % {
            'quantity': self.quantity,
            'measure_unit': self.material.measure_unit,
            'material': self.material.description,
            'number': self.invoice.number,
            'serie': self.invoice.serie
        }

    def save(self, *args, **kwargs):
        if self.pk is None:
            # Create a new MaterialCluster
            mc = MaterialCluster.objects.create(
                material=self.material,
                quantity=self.quantity,
                unit_cost=self.unit_cost,
                creation_date=self.invoice.input_date,
                last_change=self.invoice.input_date)
            # Links the MaterialCluster with this PurchaseItem
            self.material_cluster = mc
            # Call the super.save() method
            super(PurchaseItem, self).save(*args, **kwargs)
            # Create a new MaterialMovement
            mm = MaterialMovement.objects.create(
                material_cluster=mc,
                type='E',
                qty_before_mov=0,
                quantity=self.quantity,
                mov_date=self.invoice.input_date,
                unit_cost=self.unit_cost,
                origin=self)
예제 #26
0
파일: models.py 프로젝트: Terysa/listable
class AbstractGeneric(models.Model):

    name = models.CharField(max_length=255)
    description = models.TextField()

    staff = GenericRelation(
        "Staff",
        content_type_field="content_type",
        object_id_field="object_id",
    )

    class Meta:
        abstract = True
예제 #27
0
class ChildModel(ParentModel):

    child_name = models.CharField(max_length=255)

    file = models.FileField(upload_to="test", blank=True)

    genericrelatedmodel_set = GenericRelation("test_app.GenericRelatedModel")

    def __str__(self):
        return "%s > %s" % (self.parent_name, self.child_name)

    class Meta:
        verbose_name = _("child model")
        verbose_name_plural = _("child models")
예제 #28
0
class InstalledMeasure(models.Model):
    measure = models.ForeignKey(Measure)
    cost = models.IntegerField(null=True, blank=True)
    disruption = models.IntegerField(null=True, blank=True)
    house = models.ForeignKey(House,
                              null=True,
                              blank=True,
                              related_name='measures')

    report_text = models.TextField(null=True, blank=True)
    supplier = models.CharField(max_length=1024, null=True, blank=True)
    supplier_urls = GenericRelation(RelatedTrackableURL,
                                    null=True,
                                    blank=True,
                                    related_name='supplier_urls')
    product = models.CharField(max_length=1024, null=True, blank=True)
    product_urls = GenericRelation(RelatedTrackableURL,
                                   null=True,
                                   blank=True,
                                   related_name='product_urls')

    def __unicode__(self):
        return u'%s' % (self.measure.short, )
예제 #29
0
class Game(models.Model):
    """
    Defines a game within the website
    """

    name = models.CharField(max_length=200, default="Game", unique=True)
    items = models.ManyToManyField(Item, blank=True)
    abilities = models.ManyToManyField(Ability, blank=True)
    rules = models.CharField(max_length=2047, blank=True)
    attributes = GenericRelation('Attribute')
    active = models.BooleanField(default=False)

    def __str__(self):
        return self.name
예제 #30
0
class FileStorageMixin(models.Model):
    file_set = GenericRelation(RelativeFileStorage)

    class Meta:
        abstract = True

    def get_documents(self):
        return self.file_set \
            .exclude(document__extension__in=ImageThumbnailMixin.IMAGE_EXTENSIONS) \
            .filter(languages__contains=translation.get_language())

    def get_images(self):
        return self.file_set \
            .filter(document__extension__in=ImageThumbnailMixin.IMAGE_EXTENSIONS) \
            .filter(languages__contains=translation.get_language())