Log in

Topic title here

texto normal
texto en negrita
texto en italica

  • item de lista
  • item de lista

texto del enlace

texto de imagen

texttexto de imagen

some text texto de imagen some more

@estecb

quote
line quote
some more text text text text text text
some more text text text text text text

texto normal

Comment text

This comment was deleted

text

this is an inline code block

#-*- coding: utf-8 -*-

from django.db import models
from django.utils.translation import ugettext as _
from django.core.urlresolvers import reverse
from django.utils.encoding import python_2_unicode_compatible

from spirit.managers.category import CategoryManager
from spirit.utils.models import AutoSlugField


@python_2_unicode_compatible
class Category(models.Model):

    parent = models.ForeignKey('self', verbose_name=_("category parent"), null=True, blank=True)

    title = models.CharField(_("title"), max_length=75)
    slug = AutoSlugField(populate_from="title", db_index=False, blank=True)
    description = models.CharField(_("description"), max_length=255, blank=True)
    is_closed = models.BooleanField(_("closed"), default=False)
    is_removed = models.BooleanField(_("removed"), default=False)
    is_private = models.BooleanField(_("private"), default=False)

    #topic_count = models.PositiveIntegerField(_("topic count"), default=0)

    objects = CategoryManager()

    class Meta:
        app_label = 'spirit'
        ordering = ['title', ]
        verbose_name = _("category")
        verbose_name_plural = _("categories")

    def get_absolute_url(self):
        return reverse('spirit:category:detail', kwargs={'pk': str(self.id), 'slug': self.slug})

    @property
    def is_subcategory(self):
        if self.parent_id:
            return True
        else:
            return False

    def __str__(self):
        if self.parent:
            return "%s, %s" % (self.parent.title, self.title)
        else:
            return self.title

This topi is now closed

nitelyEsteban Castro Borsani

Comment text

Notify me