From 0882d73ca1ba4c84ce24c946548c80d9e4d1c04e Mon Sep 17 00:00:00 2001 From: "luxagraf@c63593aa-01b0-44d9-8516-4b9c7e931d7f" Date: Sat, 30 Jan 2010 19:19:30 +0000 Subject: added topics to posts --- apps/blog/models.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'apps/blog/models.py') diff --git a/apps/blog/models.py b/apps/blog/models.py index 5ff6624..bdbcd82 100644 --- a/apps/blog/models.py +++ b/apps/blog/models.py @@ -35,6 +35,17 @@ class PostImage(models.Model): return force_unicode('%s' % \ (settings.IMAGES_URL, self.image.url.split('images')[1].split('/',1)[1], self.title)) + +class Topic(models.Model): + name = models.CharField(max_length=100) + slug = models.SlugField() + + def __unicode__(self): + return self.name + + def get_absolute_url(self): + return "/topics/%s/" % (self.slug) + class Entry(models.Model): title = models.CharField(max_length=200) slug = models.SlugField(unique_for_date='pub_date') @@ -56,6 +67,17 @@ class Entry(models.Model): photo_gallery = models.ForeignKey(PhotoGallery, blank=True, null=True, verbose_name='photo set') thumbnail = models.FileField(upload_to=get_upload_path, null=True,blank=True) title_keywords = models.CharField(max_length=200, null=True, blank=True) + topics = models.ManyToManyField(Topic, blank=True) + + @property + def longitude(self): + '''Get the site's longitude.''' + return self.point.x + + @property + def latitude(self): + '''Get the site's latitude.''' + return self.point.y class Meta: ordering = ('-pub_date',) -- cgit v1.2.3-70-g09d2