# -*- coding: utf-8 -*- from django.db import models from django.utils.translation import ugettext_lazy as _ from hvad.models import TranslatableModel, TranslatedFields from bitfield import BitField class Theme(TranslatableModel): """ Create Theme model Uses hvad.TranslatableModel which is child of django.db.models class """ FLAGS = ( ('exposition', 'Выставка'), ('conference', 'Конференция'), ('seminar', 'Семинар'), ('webinar', 'Вебинар'), ) types = BitField([k for k, v in FLAGS]) #translated fields translations = TranslatedFields( name = models.CharField(max_length=100), main_title = models.CharField(max_length=100), description = models.TextField(blank=True), #-----meta data title = models.CharField(max_length=250, blank=True), descriptions = models.CharField(max_length=250, blank=True), keywords = models.CharField(max_length=250, blank=True), ) #fields saves information about creating and changing model #created = models.DateTimeField(auto_now_add=True) #modified = models.DateTimeField(auto_now=True) def __unicode__(self): return self.lazy_translation_getter('name', unicode(self.pk)) class Tag(TranslatableModel): """ Create Tag model Uses hvad.TranslatableModel which is child of django.db.models class """ theme = models.ForeignKey(Theme, related_name='themes') #translated fields translations = TranslatedFields( name = models.CharField(max_length=100), main_title = models.CharField(max_length=100), description = models.TextField(blank=True), #-----meta data title = models.CharField(max_length=250, blank=True), descriptions = models.CharField(max_length=250, blank=True), keywords = models.CharField(max_length=250, blank=True), ) #fields saves information about creating and changing model #created = models.DateTimeField(auto_now_add=True) #modified = models.DateTimeField(auto_now=True) def __unicode__(self): return self.lazy_translation_getter('name', unicode(self.pk))