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.
37 lines
1.4 KiB
37 lines
1.4 KiB
# -*- coding: utf-8 -*-
|
|
from django.db import models
|
|
from django.contrib.contenttypes.models import ContentType
|
|
from django.contrib.contenttypes import generic
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
from accounts.models import User
|
|
# from core.utils import UCrypto
|
|
|
|
|
|
class Comment(models.Model):
|
|
|
|
class Meta:
|
|
verbose_name = u'Комментарий'
|
|
verbose_name_plural = u'Комментарии'
|
|
get_latest_by = 'created'
|
|
|
|
ip = models.GenericIPAddressField(_(u'IP address'), unpack_ipv4=True, blank=True, null=True)
|
|
created = models.DateTimeField(_(u'дата создания'), auto_now_add=True)
|
|
hidden = models.BooleanField(_(u'скрыть'), default=False, help_text=_(u'Будет скрыто, если отмечено'))
|
|
|
|
parent = models.ForeignKey('self', verbose_name=_(u'Родительский комментарий'), null=True, blank=True)
|
|
user = models.ForeignKey(User, verbose_name=_(u'Пользователь'))
|
|
text = models.TextField(_(u'сообщение'))
|
|
|
|
content_type = models.ForeignKey(ContentType)
|
|
object_id = models.PositiveIntegerField()
|
|
content_object = generic.GenericForeignKey('content_type', 'object_id')
|
|
|
|
def get_name(self):
|
|
return self.user.get_full_name()
|
|
|
|
def get_date(self):
|
|
return self.created.strftime('%d %B %Y %H:%M')
|
|
|
|
def __unicode__(self):
|
|
return self.get_date()
|
|
|