示例#1
0
 def save(self, *args, **kwargs):
     if not self.author:
         self.author = get_current_user()
         
     # publishing date save logic.
     if not self.published_from:
         self.published_from = tz_now()
               
     super(PublishingMixin, self).save(*args, **kwargs)
示例#2
0
 def get_content_object_display(self, obj):
     """this method is just used for display in the admin"""
     co = getattr(obj, content_object_field)
     if not co:
         return "-------"
     user = get_current_user()
     app_name = co._meta.app_label
     model_name = co.__class__.__name__.lower()
     co_unicode = hasattr(co, "__unicode__") and co.__unicode__() or co._get_pk_val()
     if user.has_perm("%s.change_%s" % (app_name, model_name), co):
         return u"""<a href="/admin/%s/%s/%s/" class="content_object">%s</a>""" % (
             app_name,
             model_name,
             co._get_pk_val(),
             co_unicode,
             )
     else:
         return co_unicode
示例#3
0
 def save(self, *args, **kwargs):
     if self.pk:
         self.modifier = get_current_user()
     super(ModifierMixin, self).save(*args, **kwargs)
示例#4
0
 def save(self, *args, **kwargs):
     if not self.pk:
         self.creator = get_current_user()
     super(CreatorMixin, self).save(*args, **kwargs)