Example #1
0
    def update(self, synopsis):
        data = self.data
        synopsis.text = data['text']
        synopsis.updated_date = datetime.now()
        synopsis.save()

        tag_list = Tag.parse(data['tags'])
        for tag_name in tag_list:
            tag = Tag.find_or_create(name=tag_name, new_synopsis=False)
            tag.save()
            synopsis.tags.add(tag)
Example #2
0
 def save(self, synopsis, author):
     data = self.data
     synopsis.title = data['title']
     synopsis.article_url = data['article_url']
     synopsis.text = data['text']
     synopsis.pub_date = datetime.now()
     synopsis.author = author
     synopsis.score = 0
     synopsis.permalink = Synopsis.create_permalink(title=data['title'], 
                                                   article_url=data['article_url'])
     url_parts = urlparse.urlparse(data['article_url'])
     protocol, domain = url_parts[:2]
     synopsis.article_site_url = '%s://%s' % (protocol, domain)
     
     synopsis.save()
     
     tag_list = Tag.parse(data['tags'])
     for tag_name in tag_list:
         tag = Tag.find_or_create(name=tag_name)
         tag.save()
         synopsis.tags.add(tag)