div. updates

This commit is contained in:
andis
2017-02-17 10:02:20 +01:00
parent bdfa16728d
commit b71803c050
14 changed files with 224 additions and 65 deletions

View File

@@ -59,6 +59,9 @@ class FullArticleSchema(Schema):
author=fields.String(allow_none=True)
section_id=fields.Integer()
sourcetype =fields.String()
organization_name=fields.String(dump_only=True)
organization_image=fields.String(dump_only=True)
organization_id=fields.Integer(dump_only=True)
image =fields.String(allow_none=True)
# @post_load
# def make_article(self, data):
@@ -95,9 +98,15 @@ class Article(Base):
self.title=title
self.published_date=published_date
self.first_fetched=datetime.now()
def __json__(self):
return ArticleSchema().dump(self)[0]
# def __json__(self):
# return ArticleSchema().dump(self)[0]
def organization_name(self):
return self.section.organization.name
def organization_image(self):
return self.section.organization.image
def organization_id(self):
return self.section.organization.id
# def dict(self):
# return {"id": str(int(self.id)), "title": self.title, "text": self.text, "author": self.author, "section":self.section, "sourcetype": self.sourcetype, "last_fetched": self.last_fetched, "first_fetched": self.first_fetched, "published_date": self.published_date, "date": self.date,"image": self.image, "url": self.url}

View File

@@ -50,7 +50,7 @@ def update(id):
@article_pages.route("/<int:id>.json",methods=['GET'])
def get(id):
article=Article.query.get(id)
clogger.info(article)
# clogger.info(article)
# article=ArticleSchema().dump(article)[0]
return jsonify(article=article)