You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
2.2 KiB
63 lines
2.2 KiB
# -*- 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)) |