Revision 60441a7f cloudcms/models.py

b/cloudcms/models.py
36 36
from django.db import models
37 37
from django.conf import settings
38 38
from django.contrib.sites import models as sites_models
39
from django.utils.translation import ugettext_lazy as _, ugettext, ungettext
39 40
from django.core.cache import cache
40 41
from django.utils import simplejson
41 42

  
43
from feincms import translations
42 44
from feincms.module.medialibrary.fields import MediaFileForeignKey
43 45
from feincms.module.medialibrary.models import MediaFile
44 46

  
......
143 145
# hook for feincms configuration, is this appropriate place ??? who knows
144 146
from cloudcms.cms import *
145 147

  
148
class Service(models.Model, translations.TranslatedObjectMixin):
149
    """
150
    Service.
151
    """
152

  
153
    ordering = models.SmallIntegerField(_('ordering'), default=0)
154

  
155
    class Meta:
156
        verbose_name = _('service')
157
        verbose_name_plural = _('services')
158
        ordering = ['-ordering',]
159

  
160
    objects = translations.TranslatedObjectManager()
161

  
162
    def __unicode__(self):
163
        trans = translations.TranslatedObjectMixin.__unicode__(self)
164
        return trans or _('Unnamed category')
165

  
166

  
167
class ServiceTranslation(translations.Translation(Service)):
168
    """
169
    Service translation
170
    """
171
    title = models.CharField(_('service title'), max_length=100)
172
    slug = models.SlugField(_('slug'), unique=True)
173
    description = models.CharField(_('description'), max_length=250, blank=True)
174
    cms_page = models.ForeignKey(Page, null=True, blank=True)
175

  
176
    class Meta:
177
        verbose_name = _('service translation')
178
        verbose_name_plural = _('service translations')
179
        ordering = ['title']
180

  
181
    def __unicode__(self):
182
        return self.title
183

  
184
    def save(self, *args, **kwargs):
185
        if not self.slug:
186
            self.slug = slugify(self.title)
187

  
188
        super(ServiceTranslation, self).save(*args, **kwargs)
189

  

Also available in: Unified diff