diff options
author | luxagraf@c63593aa-01b0-44d9-8516-4b9c7e931d7f <luxagraf@c63593aa-01b0-44d9-8516-4b9c7e931d7f> | 2010-04-04 23:30:30 +0000 |
---|---|---|
committer | luxagraf@c63593aa-01b0-44d9-8516-4b9c7e931d7f <luxagraf@c63593aa-01b0-44d9-8516-4b9c7e931d7f> | 2010-04-04 23:30:30 +0000 |
commit | f8cda18e218cf9849ea7b70fc39b505420c930b9 (patch) | |
tree | 43eecea66befb5d84dac316f4ca9de7944855a1b /apps/projects/models/base.py | |
parent | a1138b560308e043de00c2211293583515def19e (diff) |
started work on the 5x5 project, models, views, templates
Diffstat (limited to 'apps/projects/models/base.py')
-rw-r--r-- | apps/projects/models/base.py | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/apps/projects/models/base.py b/apps/projects/models/base.py new file mode 100644 index 0000000..bc42918 --- /dev/null +++ b/apps/projects/models/base.py @@ -0,0 +1,63 @@ +import datetime +from django.contrib.gis.db import models +from django.conf import settings +from django.contrib.syndication.feeds import Feed +from django.contrib.sitemaps import Sitemap +from django.template.defaultfilters import truncatewords_html + + +import markdown2 as markdown + + +from photos.models import PhotoGallery +from locations.models import Location,Region + + +def get_upload_path(self, filename): + return "images/project-thumbs/%s/%s" %(datetime.datetime.today().strftime("%Y"), filename) + +def markdown_processor(md): + html = markdown.markdown(md, safe_mode = False).split('<break>') + return html + + + +class Project(models.Model): + title = models.CharField(max_length=200) + subtitle = models.CharField(max_length=200, null=True, blank=True) + slug = models.SlugField(unique_for_date='pub_date') + lede = models.TextField(blank=True) + pub_date = models.DateTimeField('Date published') + PUB_STATUS = ( + (0, 'Draft'), + (1, 'Published'), + ) + status = models.IntegerField(choices=PUB_STATUS, default=0) + image = models.FileField(upload_to=get_upload_path, null=True,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',) + get_latest_by = 'pub_date' + app_label = 'projects' + + def __unicode__(self): + return self.title + + def get_absolute_url(self): + return "/%s/%s/" % ('projects', self.slug) + + def get_previous_published(self): + return self.get_previous_by_pub_date(status__exact=1) + + def get_next_published(self): + return self.get_next_by_pub_date(status__exact=1)
\ No newline at end of file |