[snowy] A few tweaks to the default values of the model fields



commit 6b602813f16430265a2396e1b3d23fb558af8f69
Author: Brad Taylor <brad getcoded net>
Date:   Wed May 13 17:27:27 2009 -0400

    A few tweaks to the default values of the model fields
---
 notes/models.py |   25 ++++++++++++++++++++++---
 1 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/notes/models.py b/notes/models.py
index c178606..2b7617c 100644
--- a/notes/models.py
+++ b/notes/models.py
@@ -24,23 +24,42 @@ class Note(models.Model):
     )
 
     guid = models.CharField(max_length=36)
+
+    author = models.ForeignKey(User)
+
     created = models.DateTimeField(auto_now_add=True)
     modified = models.DateTimeField(auto_now=True)
-    author = models.ForeignKey(User)
+    user_modified = models.DateTimeField(auto_now_add=True)
+
     title = models.CharField(max_length=128)
     content = models.TextField(blank=True)
     content_version = models.CharField(max_length=10)
+
     tags = models.ManyToManyField('NoteTag', null=True, blank=True)
     permissions = models.IntegerField(choices=NOTE_PERMISSIONS,
                                       default=0)
 
+    open_on_startup = models.BooleanField(default=False)
+
+    class Meta:
+        get_latest_by = 'user_modified'
+        unique_together = ('author', 'title')
+
     def __unicode__(self):
         return self.title
 
 class NoteTag(models.Model):
-    user = models.ForeignKey(User)
+    author = models.ForeignKey(User)
     name = models.CharField(max_length=256)
-    is_notebook = models.BooleanField()
+    is_notebook = models.BooleanField(default=False)
+
+    class Meta:
+        unique_together = ('author', 'name')
 
     def __unicode__(self):
         return self.name
+
+    def get_name_for_display(self):
+        if self.is_notebook:
+            return self.name.split(':', 3)[-1]
+        return self.name



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]