Changeset 48 for plesonet_contentareas/trunk/models.py
- Timestamp:
- 06/07/09 22:57:38 (3 years ago)
- Files:
-
- 1 modified
-
plesonet_contentareas/trunk/models.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
plesonet_contentareas/trunk/models.py
r42 r48 1 1 from django.db import models 2 from django.contrib import admin3 2 from django.conf import settings 4 3 from django.utils.translation import ugettext_lazy as _ … … 10 9 class PublishedContentAreasManager(models.Manager): 11 10 def get_query_set(self): 12 return super(PublishedContentAreasManager, self).get_query_set().filter(is_published = True) 11 return super(PublishedContentAreasManager, self).get_query_set().filter(is_published = True) 12 #return super(PublishedContentAreasManager, self).get_query_set().filter(is_published = True, language = translation.get_language()) 13 13 14 14 def get_name(self, name): 15 #TODO: you should modify this, if you'd like to add language to cache! 15 16 result = cache.get(CONTENT_AREA_CACHE_KEY + name) 16 17 if result is None: … … 18 19 cache.set(CONTENT_AREA_CACHE_KEY + name, result, ALL_CONTENT_AREA_CACHE_TIMEOUT) 19 20 return result 20 21 21 22 class ContentArea(models.Model): 22 EXISTING_NAMES = ( ('contacts_form', 'Contacts form'),23 ('article_form', 'Send article from'), )23 EXISTING_NAMES = ( ('contacts_form', _('Contacts form')), 24 ('article_form', _('Send article from')), ) 24 25 25 26 name = models.CharField(_('Name'), max_length = 255, choices=EXISTING_NAMES) 27 #language = models.CharField(max_length = 2, choices = settings.LANGUAGES, verbose_name=_('Language'), blank=False, null=False) 26 28 body = models.TextField(_('Body')) 27 29 is_published = models.BooleanField(_('Is published'), default=True) … … 29 31 objects = models.Manager() # The default manager. 30 32 published = PublishedContentAreasManager() 31 33 32 34 def save(self, *args, **kwargs): 35 #TODO: you should modify this, if you'd like to add language to cache! 33 36 super(ContentArea, self).save(*args, **kwargs) 34 37 cache.delete(CONTENT_AREA_CACHE_KEY + self.name) 35 38 36 39 def delete(self): 40 #TODO: you should modify this, if you'd like to add language to cache! 37 41 super(ContentArea, self).delete() 38 cache.delete(CONTENT_AREA_CACHE_KEY + self.name) 42 cache.delete(CONTENT_AREA_CACHE_KEY + self.name) 39 43 40 44 class Meta: … … 42 46 verbose_name = _('content area') 43 47 verbose_name_plural = _('content areas') 48 #ordering = ('name', 'language') 49 #unique_together = (('language', 'name'),) 44 50 45 51 def __unicode__(self): 46 52 return self.name 47 48 class ContentAreaAdmin(admin.ModelAdmin):49 list_display = ('name', 'is_published')50 search_fields = ('title', 'slug', 'annotation', 'body')51 class Media:52 js = ( #relative path to MEDIA dir53 '../media-admin/fckeditor/fckeditor.js',54 '../media-admin/js/admin/textareas.js', )55 admin.site.register(ContentArea, ContentAreaAdmin)

