Changeset 48

Show
Ignore:
Timestamp:
06/07/09 22:57:38 (3 years ago)
Author:
235
Message:

content-areas cache

Location:
plesonet_contentareas/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • plesonet_contentareas/trunk/models.py

    r42 r48  
    11from django.db import models 
    2 from django.contrib import admin 
    32from django.conf import settings 
    43from django.utils.translation import ugettext_lazy as _ 
     
    109class PublishedContentAreasManager(models.Manager): 
    1110    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()) 
    1313     
    1414    def get_name(self, name): 
     15        #TODO: you should modify this, if you'd like to add language to cache! 
    1516        result = cache.get(CONTENT_AREA_CACHE_KEY + name) 
    1617        if result is None: 
     
    1819            cache.set(CONTENT_AREA_CACHE_KEY + name, result, ALL_CONTENT_AREA_CACHE_TIMEOUT) 
    1920        return result 
    20      
     21 
    2122class 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')), ) 
    2425     
    2526    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) 
    2628    body = models.TextField(_('Body')) 
    2729    is_published = models.BooleanField(_('Is published'), default=True) 
     
    2931    objects = models.Manager() # The default manager. 
    3032    published = PublishedContentAreasManager() 
    31      
     33 
    3234    def save(self, *args, **kwargs): 
     35        #TODO: you should modify this, if you'd like to add language to cache! 
    3336        super(ContentArea, self).save(*args, **kwargs) 
    3437        cache.delete(CONTENT_AREA_CACHE_KEY + self.name) 
    3538     
    3639    def delete(self): 
     40        #TODO: you should modify this, if you'd like to add language to cache! 
    3741        super(ContentArea, self).delete() 
    38         cache.delete(CONTENT_AREA_CACHE_KEY + self.name)   
     42        cache.delete(CONTENT_AREA_CACHE_KEY + self.name) 
    3943 
    4044    class Meta: 
     
    4246        verbose_name = _('content area') 
    4347        verbose_name_plural = _('content areas') 
     48        #ordering = ('name', 'language') 
     49        #unique_together = (('language', 'name'),)         
    4450         
    4551    def __unicode__(self): 
    4652        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 dir 
    53                 '../media-admin/fckeditor/fckeditor.js', 
    54                 '../media-admin/js/admin/textareas.js', ) 
    55 admin.site.register(ContentArea, ContentAreaAdmin)  
  • plesonet_contentareas/trunk/templatetags/contentareas.py

    r42 r48  
    1010     
    1111    try: 
     12        #TODO: you should modify this, if you'd like to add language to cache! 
    1213        contentarea = ContentArea.published.get_name(name) 
    1314    except: