summaryrefslogtreecommitdiff
path: root/apps/blog/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'apps/blog/models.py')
-rw-r--r--apps/blog/models.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/apps/blog/models.py b/apps/blog/models.py
index 0c6d93e..9a104d7 100644
--- a/apps/blog/models.py
+++ b/apps/blog/models.py
@@ -85,6 +85,11 @@ class Entry(models.Model):
meta_description = models.CharField(max_length=256, null=True, blank=True)
topics = models.ManyToManyField(Topic, blank=True)
template_name = models.IntegerField(choices=TEMPLATES, default=0)
+ location_name = models.CharField(max_length=200, null=True,blank=True)
+ state_name = models.CharField(max_length=200, null=True,blank=True)
+ country_name = models.CharField(max_length=200, null=True,blank=True)
+ state_iso = models.CharField(max_length=2, null=True,blank=True)
+ country_iso = models.CharField(max_length=2, null=True,blank=True)
@property
def longitude(self):
@@ -107,9 +112,11 @@ class Entry(models.Model):
def get_absolute_url(self):
return "/%s/%s/" % (self.pub_date.strftime("%Y/%b/%d").lower(), self.slug)
+ @property
def get_previous_published(self):
return self.get_previous_by_pub_date(status__exact=1)
-
+
+ @property
def get_next_published(self):
return self.get_next_by_pub_date(status__exact=1)
@@ -124,7 +131,7 @@ class Entry(models.Model):
def get_image_url(self):
image_dir, img = self.image.url.split('post-images/')[1].split('/')
return '%spost-images/%s/%s' %(settings.IMAGES_URL, image_dir, img)
-
+
def save(self):
#get image dimensions
img = Image.open(self.image)
@@ -139,6 +146,11 @@ class Entry(models.Model):
self.body_html = html
self.lede = lede
self.dek == markdown.markdown(self.dek, safe_mode = False)
+ self.location_name = self.location.name
+ self.state_name = self.location.state.name
+ self.country_name = self.location.state.country.name
+ self.state_iso = self.location.state.code
+ self.country_iso = self.location.state.country.iso2
super(Entry, self).save()
class BlogSitemap(Sitemap):