Example #1
0
 def update_post(self, post_id, title, text, user_id, tags):
     t = datetime.now()
     site=get_current_site()
     user = User.get(user_id)
     post = Posts.get(post_id)
     post.set(title=title,
              text=text,
              user=user,
              updated=t)
     
     tag_list = Tags.parse(tags)
     for tag_name in tag_list:
         tag = Tags.find_or_create(name=tag_name, site=site)
         if tag not in post.tags:
             tag.count = tag.count + 1            
             post.addTags(tag)
                           
     redirect_to_home()
Example #2
0
 def create_post(self, title, text, user_id, tags):
     t = datetime.now()
     site=get_current_site()
     user = User.get(user_id)
     cleaned = remove_special_char(title)
     permalink = "/".join((t.strftime('%Y/%m/%d'), cleaned.strip()))
     post = Posts(title=title, 
                  text=text, 
                  user=user, 
                  site=site,
                  created=t,
                  updated=None,
                  archives=(t.strftime('%Y/%m')),
                  permalink=permalink)
                  
     tag_list = Tags.parse(tags)
     for tag_name in tag_list:
         tag = Tags.find_or_create(name=tag_name, site=site)
         tag.count = tag.count + 1
         post.addTags(tag)
             
     redirect_to_home()