Anonymous avatar Anonymous committed 4ae7cce

added autouser recog via django-globals

Comments (0)

Files changed (1)

content_item_base/models.py

 from django.db import models
 from django.contrib.auth.models import User
 from tagging.fields import TagField
+from django_globals import globals
 
 class LiveItemManager(models.Manager):
     def get_query_set(self): 
     title = models.CharField(max_length=250, help_text="Maximum 250 characters.")
     slug = models.SlugField(unique_for_date='publish', help_text="Suggested value automatically generated from title. Must be unique.")
     
-    author = models.ForeignKey(User)
+    author = models.ForeignKey(User, default=lambda: globals.user)
     
     created = models.DateTimeField(editable=False)
     updated = models.DateTimeField(editable=False)
         if not self.id:
             self.created = datetime.datetime.today()
         self.updated = datetime.datetime.today()
+        self.user = globals.user
         super(ContentItemBase, self).save()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.