Skip to content
Browse files

Add support for team blogs

  • Loading branch information...
1 parent 379e02c commit 114792a8c1c681e7efd14ecfc9bed23a87d8ae02 @mhagander committed May 18, 2009
Showing with 12 additions and 6 deletions.
  1. +2 −2 generator.py
  2. +2 −2 hamnadmin/register/models.py
  3. +7 −1 planethtml.py
  4. +1 −1 template/index.tmpl
View
4 generator.py
@@ -59,7 +59,7 @@ def Generate(self):
self.db.set_client_encoding('UTF8')
c = self.db.cursor()
c.execute("SET TIMEZONE=GMT")
- c.execute("SELECT guid,link,dat,title,txt,name,blogurl,guidisperma FROM planet.posts INNER JOIN planet.feeds ON planet.feeds.id=planet.posts.feed WHERE planet.feeds.approved AND NOT planet.posts.hidden ORDER BY dat DESC LIMIT 30")
+ c.execute("SELECT guid,link,dat,title,txt,planet.feeds.name,blogurl,guidisperma,planet.teams.name,planet.teams.teamurl FROM planet.posts INNER JOIN planet.feeds ON planet.feeds.id=planet.posts.feed LEFT JOIN planet.teams ON planet.feeds.team = planet.teams.id WHERE planet.feeds.approved AND NOT planet.posts.hidden ORDER BY dat DESC LIMIT 30")
for post in c.fetchall():
desc = self.TruncateAndCleanDescription(post[4])
rss.items.append(PyRSS2Gen.RSSItem(
@@ -74,7 +74,7 @@ def Generate(self):
guid=PyRSS2Gen.Guid(post[0],post[7]),
pubDate=post[2],
description=desc))
- self.items.append(PlanetPost(post[0], post[1], post[2], post[3], post[5], post[6], desc))
+ self.items.append(PlanetPost(post[0], post[1], post[2], post[3], post[5], post[6], desc, post[8], post[9]))
c.execute("SELECT name,blogurl,feedurl FROM planet.feeds WHERE approved ORDER BY name")
for feed in c.fetchall():
View
4 hamnadmin/register/models.py
@@ -19,10 +19,10 @@ class Blog(models.Model):
feedurl = models.CharField(max_length=255, blank=False)
name = models.CharField(max_length=255, blank=False)
blogurl = models.CharField(max_length=255, blank=False)
- lastget = models.DateTimeField(default='2000-01-01')
+ lastget = models.DateTimeField(default=datetime(2000,1,1))
userid = models.CharField(max_length=255, blank=False)
approved = models.BooleanField()
- authorfilter = models.CharField(max_length=255,default='')
+ authorfilter = models.CharField(max_length=255,default='',blank=True)
team = models.ForeignKey(Team,db_column='team', blank=True, null=True)
def __str__(self):
View
8 planethtml.py
@@ -17,20 +17,26 @@ def quoteurl(str):
return str.replace('&','&')
class PlanetPost:
- def __init__(self, guid,link,dat,title,author,blogurl,txt):
+ def __init__(self, guid,link,dat,title,author,blogurl,txt,teamname,teamurl):
self.guid = guid
self.link = link
self.dat = dat
self.posttitle = title
self.author = author
self._blogurl = blogurl
self.txt = txt
+ self.teamname = teamname
+ self._teamurl = teamurl
def _get_blogurl(self):
return quoteurl(self._blogurl)
blogurl = property(_get_blogurl)
+ def _get_teamurl(self):
+ return quoteurl(self._teamurl)
+ teamurl = property(_get_teamurl)
+
def _get_datetime(self):
return self.dat.strftime("%Y-%m-%d at %H:%M:%S")
datetime = property(_get_datetime)
View
2 template/index.tmpl
@@ -31,7 +31,7 @@
<div class="planetPostTitle"><a href="{{post.link}}">{{post.title}}</a></div>
<b class="blf"></b><b class="b2f"></b><b class="b3f"></b><b class="b4f"></b>
<div class="planetPostAuthor">
- Posted by {%if post.blogurl%}<a href="{{post.blogurl}}">{{post.author}}</a>{%else%}{{post.author}}{%endif%} on <span class="date">{{post.datetime}}</span>
+ Posted by {%if post.blogurl%}<a href="{{post.blogurl}}">{{post.author}}</a>{%else%}{{post.author}}{%endif%} {%if post.teamurl%} in <a href="{{post.teamurl}}">{{post.teamname}}</a>{%endif%} on <span class="date">{{post.datetime}}</span>
</div><!-- end planetPostHeader -->
<b class="b4f"></b><b class="b3f"></b><b class="b2f"></b><b class="b1f"></b>
<div class="cl"></div>

0 comments on commit 114792a

Please sign in to comment.
Something went wrong with that request. Please try again.