aboutsummaryrefslogtreecommitdiffstats
path: root/notes/models.py
diff options
context:
space:
mode:
authorFilipp Lepalaan <f@0x00.co>2013-02-01 09:49:20 +0200
committerFilipp Lepalaan <f@0x00.co>2013-02-01 09:49:20 +0200
commit2e9cd65e869b8bd31e6e6ba66b52705c023af5ec (patch)
treefda1874e6338022ee5666330249650fe41193cf1 /notes/models.py
parentc0121b9b7f5041f6434a2e2dd24d3c68ed84b582 (diff)
downloadopus-2e9cd65e869b8bd31e6e6ba66b52705c023af5ec.tar.gz
opus-2e9cd65e869b8bd31e6e6ba66b52705c023af5ec.tar.bz2
opus-2e9cd65e869b8bd31e6e6ba66b52705c023af5ec.zip
Some improvementsHEADmaster
Diffstat (limited to 'notes/models.py')
-rw-r--r--notes/models.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/notes/models.py b/notes/models.py
index 2cd5ca6..25a08cf 100644
--- a/notes/models.py
+++ b/notes/models.py
@@ -14,7 +14,7 @@ class Tag(models.Model):
class Note(models.Model):
user = models.ForeignKey(User)
shared = models.BooleanField(default=True)
- title = models.CharField(max_length=140, null=True)
+ title = models.CharField(max_length=140, null=True, default=u'New Note')
tags = models.ManyToManyField(Tag, null=True, blank=True)
def get_date(self):
@@ -51,11 +51,13 @@ class Attachment(models.Model):
content = models.FileField(upload_to='uploads')
note = models.ForeignKey(Note)
+ def get_name(self):
+ import os.path
+ return os.path.basename(self.content.name)
+
@receiver(post_save, sender=Version)
def version_saved(sender, instance, created, **kwargs):
-
tags = re.findall('#(\w+)', instance.content)
-
for t in tags:
tag = Tag.objects.get_or_create(title=t)[0]
instance.note.tags.add(tag)