Mercurial > public > sg101
comparison gpp/potd/models.py @ 491:7dbdbb08e68c
For #233; add social media sharing buttons to the photo of the day app.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Thu, 20 Oct 2011 01:00:19 +0000 |
parents | 3c951521e0ec |
children | ae89ba801e8b |
comparison
equal
deleted
inserted
replaced
490:f0f3966ea44f | 491:7dbdbb08e68c |
---|---|
71 s = StringIO() | 71 s = StringIO() |
72 image.save(s, format) | 72 image.save(s, format) |
73 thumb_name = os.path.basename(self.photo.path) | 73 thumb_name = os.path.basename(self.photo.path) |
74 self.thumb.save(thumb_name, ContentFile(s.getvalue()), save=False) | 74 self.thumb.save(thumb_name, ContentFile(s.getvalue()), save=False) |
75 | 75 |
76 def ogp_tags(self): | |
77 """ | |
78 Returns a dict of Open Graph Protocol meta tags. | |
79 | |
80 """ | |
81 desc = "Photo of the day: %s." % self.caption | |
82 return { | |
83 'og:title': self.caption, | |
84 'og:type': 'article', | |
85 'og:url': self.get_absolute_url(), | |
86 'og:image': self.photo.url, | |
87 'og:description': desc, | |
88 } | |
89 | |
76 | 90 |
77 class CurrentManager(models.Manager): | 91 class CurrentManager(models.Manager): |
78 def get_current_photo(self): | 92 def get_current_photo(self): |
79 try: | 93 try: |
80 c = self.get(pk=1) | 94 c = self.get(pk=1) |