From f8cda18e218cf9849ea7b70fc39b505420c930b9 Mon Sep 17 00:00:00 2001 From: "luxagraf@c63593aa-01b0-44d9-8516-4b9c7e931d7f" Date: Sun, 4 Apr 2010 23:30:30 +0000 Subject: started work on the 5x5 project, models, views, templates --- apps/projects/models/__init__.py | 2 ++ apps/projects/models/base.py | 63 ++++++++++++++++++++++++++++++++++++++++ apps/projects/models/fiveby.py | 58 ++++++++++++++++++++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 apps/projects/models/__init__.py create mode 100644 apps/projects/models/base.py create mode 100644 apps/projects/models/fiveby.py (limited to 'apps/projects/models') diff --git a/apps/projects/models/__init__.py b/apps/projects/models/__init__.py new file mode 100644 index 0000000..b29933a --- /dev/null +++ b/apps/projects/models/__init__.py @@ -0,0 +1,2 @@ +from base import Project +from fiveby import FiveBy \ No newline at end of file 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('') + 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 diff --git a/apps/projects/models/fiveby.py b/apps/projects/models/fiveby.py new file mode 100644 index 0000000..5415ee7 --- /dev/null +++ b/apps/projects/models/fiveby.py @@ -0,0 +1,58 @@ +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 + +from locations.models import Location,Region + +def get_upload_path(self, filename): + return "images/projects/videos/5x5/%s/%s" %(datetime.datetime.today().strftime("%Y"), filename) + +def get_image_upload_path(self, filename): + return "images/projects/5x5/%s/%s" %(datetime.datetime.today().strftime("%Y"), filename) + +class FiveBy(models.Model): + title = models.CharField(max_length=200) + slug = models.SlugField(unique_for_date='pub_date') + lede = models.TextField(blank=True) + image = models.FileField(upload_to=get_image_upload_path, null=True,blank=True) + videoh264 = models.FileField(upload_to=get_upload_path, null=True,blank=True) + videoogg = models.FileField(upload_to=get_upload_path, null=True,blank=True) + vimeo_link = models.CharField(max_length=200) + youtube_link = models.CharField(max_length=200) + pub_date = models.DateTimeField('Date published') + PUB_STATUS = ( + (0, 'Draft'), + (1, 'Published'), + ) + status = models.IntegerField(choices=PUB_STATUS, default=0) + point = models.PointField(null=True) + location = models.ForeignKey(Location, null=True) + region = models.ForeignKey(Region, null=True) + + + + class Meta: + ordering = ('-pub_date',) + get_latest_by = 'pub_date' + app_label = 'projects' + verbose_name_plural = '5x5' + + def __unicode__(self): + return self.title + + def get_absolute_url(self): + return "/%s/%s/%s/" % ('projects', '5x5', self.slug) + + @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 + \ No newline at end of file -- cgit v1.2.3-70-g09d2