Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
dengmin committed Dec 25, 2012
1 parent ef1e83b commit cc4ef5f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
5 changes: 4 additions & 1 deletion handlers/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,13 @@ def post(self):
category_id = self.get_argument('category',1)
content = self.get_argument('content','')
tag = self.get_argument('tag',None)
category = Category.get(id=int(category_id))

category = Category.get(id=int(category_id))
print tag
post = Post.create(title=title,category=category,slug=slug,content=content,tags=tag)

if tag:
print tag
for tag in post.taglist():
Tag.create(name=tag,post=post.id)
self.render('admin/post/add.html')
Expand Down
5 changes: 5 additions & 0 deletions models.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ def perent(self):
def url(self):
return '/post/post-%d.html#comment-%d'%(self.post.id,self.id)

def gravatar_url(self,size=80):
return 'http://www.gravatar.com/avatar/%s?d=identicon&s=%d' % \
(hashlib.md5(self.email.strip().lower().encode('utf-8')).hexdigest(),
size)

class Meta:
db_table ='comments'

Expand Down
2 changes: 1 addition & 1 deletion templates/admin/post/update.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<textarea class="span7" rows="18" name="content">{{post.content}}</textarea>
<div class="input-prepend">
<span class="add-on">Tag</span>
<input type="text" class="span6" name="tag" value="{{post.tags}}">
<input type="text" class="span6" name="tag" value="{%if post.tags%}{{post.tags}}{%endif%}">
</div>
<div class="form-actions">
<button type="submit" class="btn btn-primary">Update changes</button>
Expand Down
6 changes: 4 additions & 2 deletions templates/fluid-blue/comment.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ <h3>{{post.comments.count()}} Comments </h3>
<li class="comment even thread-even depth-1" id="comment-{{comment.id}}">
<div id="comment-{{comment.id}}" class="comment-body">
<div class="comment-author vcard">
<img alt="" src="http://0.gravatar.com/avatar/?d=identicon&amp;s=48" class="avatar avatar-48 photo avatar-default" height="48" width="48">
<cite class="fn"><a href="{%if comment.website%}{{comment.website}}{%else%}#{%endif%}" rel="external nofollow" class="url">{{comment.author}}</a></cite> <span class="says">says:</span>
<img alt="" src="{{comment.gravatar_url(48)}}" class="avatar avatar-48 photo avatar-default" height="48" width="48">
<cite class="fn">
<a href="{%if comment.website%}{{comment.website}}{%else%}#{%endif%}" rel="external nofollow" class="url" target="_blank">{{comment.author}}</a>
</cite> <span class="says">says:</span>
</div>
<div class="comment-meta commentmetadata">
<a href="{{comment.url}}">{{comment.created|datetimeformat}}</a>
Expand Down

0 comments on commit cc4ef5f

Please sign in to comment.