fix section view
This commit is contained in:
@@ -41,20 +41,6 @@ def calc_fingerprint_h(a):
|
|||||||
h.update(unicode(pp))
|
h.update(unicode(pp))
|
||||||
return h.hexdigest()
|
return h.hexdigest()
|
||||||
|
|
||||||
|
|
||||||
class ArticleSchema(Schema):
|
|
||||||
id=fields.Integer()
|
|
||||||
text=fields.String()
|
|
||||||
title=fields.String()
|
|
||||||
author=fields.String()
|
|
||||||
sourcetype =fields.String()
|
|
||||||
image =fields.String()
|
|
||||||
url =fields.String()
|
|
||||||
published_date=fields.DateTime()
|
|
||||||
date=fields.DateTime()
|
|
||||||
first_fetched=fields.DateTime()
|
|
||||||
section_id=fields.Integer()
|
|
||||||
|
|
||||||
class Article(Base):
|
class Article(Base):
|
||||||
__tablename__ = 'articles'
|
__tablename__ = 'articles'
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
@@ -137,3 +123,30 @@ class Article(Base):
|
|||||||
#flask.json.JSONEncoder.default = lambda self,obj: ((ArticleSchema().dump(obj)[0]) if isinstance(obj, Article) else None)
|
#flask.json.JSONEncoder.default = lambda self,obj: ((ArticleSchema().dump(obj)[0]) if isinstance(obj, Article) else None)
|
||||||
|
|
||||||
#json.JSONEncoder.default = lambda self,obj: ((ArticleSchema().dump(obj)[0]) if isinstance(obj, Article) else None)
|
#json.JSONEncoder.default = lambda self,obj: ((ArticleSchema().dump(obj)[0]) if isinstance(obj, Article) else None)
|
||||||
|
|
||||||
|
class ArticleCompSchema(Schema):
|
||||||
|
id=fields.Integer()
|
||||||
|
# text=fields.String()
|
||||||
|
title=fields.String()
|
||||||
|
author=fields.String()
|
||||||
|
sourcetype =fields.String()
|
||||||
|
image =fields.String()
|
||||||
|
url =fields.String()
|
||||||
|
published_date=fields.DateTime()
|
||||||
|
date=fields.DateTime()
|
||||||
|
first_fetched=fields.DateTime()
|
||||||
|
section_id=fields.Integer()
|
||||||
|
|
||||||
|
class ArticleSchema(Schema):
|
||||||
|
id=fields.Integer()
|
||||||
|
text=fields.String()
|
||||||
|
title=fields.String()
|
||||||
|
author=fields.String()
|
||||||
|
sourcetype =fields.String()
|
||||||
|
image =fields.String()
|
||||||
|
url =fields.String()
|
||||||
|
published_date=fields.DateTime()
|
||||||
|
date=fields.DateTime()
|
||||||
|
first_fetched=fields.DateTime()
|
||||||
|
section_id=fields.Integer()
|
||||||
|
|
||||||
|
|||||||
@@ -10,11 +10,6 @@ import flask
|
|||||||
|
|
||||||
#from src.articles import Article
|
#from src.articles import Article
|
||||||
|
|
||||||
class SectionSchema(Schema):
|
|
||||||
id=fields.Integer()
|
|
||||||
foreign_name=fields.String()
|
|
||||||
name=fields.String()
|
|
||||||
|
|
||||||
class Section(Base):
|
class Section(Base):
|
||||||
__tablename__ = 'sections'
|
__tablename__ = 'sections'
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
@@ -48,3 +43,24 @@ class Section(Base):
|
|||||||
db_session.add(s)
|
db_session.add(s)
|
||||||
db_session.commit()
|
db_session.commit()
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
||||||
|
class ArticleCompSchema(Schema):
|
||||||
|
id=fields.Integer()
|
||||||
|
# text=fields.String()
|
||||||
|
title=fields.String()
|
||||||
|
author=fields.String()
|
||||||
|
sourcetype =fields.String()
|
||||||
|
image =fields.String()
|
||||||
|
url =fields.String()
|
||||||
|
published_date=fields.DateTime()
|
||||||
|
date=fields.DateTime()
|
||||||
|
first_fetched=fields.DateTime()
|
||||||
|
section_id=fields.Integer()
|
||||||
|
|
||||||
|
#from src.articles.model import ArticleCompSchema
|
||||||
|
class SectionSchema(Schema):
|
||||||
|
id=fields.Integer()
|
||||||
|
foreign_name=fields.String()
|
||||||
|
name=fields.String()
|
||||||
|
articles=fields.Nested(ArticleCompSchema,many=True)
|
||||||
|
|||||||
@@ -35,6 +35,6 @@ def get(id):
|
|||||||
section=Section.query.get(id)
|
section=Section.query.get(id)
|
||||||
clogger.info(section)
|
clogger.info(section)
|
||||||
# section=SectionSchema().dump(section)[0]
|
# section=SectionSchema().dump(section)[0]
|
||||||
return jsonify(section=section,articles=section.articles)
|
return jsonify(section=section)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user