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.
 
 
 
 
 
 

39 lines
1.8 KiB

# -*- coding: utf-8 -*-
from django.db import models
from hvad.models import TranslatableModel, TranslatedFields
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic
#functions
from functions.custom_fields import EnumField
TYPES = ('announcement', 'news', 'overview')
class News(TranslatableModel):
content_type = models.ForeignKey(ContentType, null=True)
object_id = models.PositiveIntegerField(blank=True, null=True)
object = generic.GenericForeignKey(content_type, object_id)
url = models.SlugField(unique=True)
date = models.DateField(verbose_name='Дата')
type = EnumField(values=TYPES)
theme = models.ManyToManyField('theme.Theme', verbose_name='Тема')
tag = models.ManyToManyField('theme.Tag', verbose_name='Теги', blank=True, null=True)
user = models.ForeignKey('accounts.User', verbose_name='Организатор', blank=True, null=True,
on_delete=models.PROTECT)
paid = models.BooleanField(default=0)
translations = TranslatedFields(
main_title = models.CharField(verbose_name='Заголовок', max_length=255),
preview = models.TextField(verbose_name='Превью'),
description = models.TextField(verbose_name='Описание'),
#---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('main_title', self.pk)