article update
This commit is contained in:
@@ -10,4 +10,4 @@ def get_all():
|
|||||||
return Article.query.order_by(Article.published_date.desc()).all()
|
return Article.query.order_by(Article.published_date.desc()).all()
|
||||||
|
|
||||||
def search(s):
|
def search(s):
|
||||||
return Article.query.filter(Article.title.like("%"+s+"%")).order_by(Article.published_date.desc()).all()
|
return Article.query.filter(Article.title.like("%"+s+"%")).order_by(Article.published_date.desc()).limit(20).all()
|
||||||
|
|||||||
@@ -98,8 +98,7 @@ def handle(handler,msg):
|
|||||||
lg.debug(msg['data'])
|
lg.debug(msg['data'])
|
||||||
|
|
||||||
def make_article_json(art):
|
def make_article_json(art):
|
||||||
|
res={"type":"article", "title":art.title+" (" +str(art.section.title())+")", "id": str(art.id), "url": art.url, "message_text": art.title + " " + art.url}
|
||||||
res={"type":"article", "title":art.title, "id": str(art.id), "url": art.url, "message_text": art.title + " " + art.url}
|
|
||||||
if art.image != None:
|
if art.image != None:
|
||||||
lg.debug("http://crawler.fachschaften.at/"+str(art.image))
|
lg.debug("http://crawler.fachschaften.at/"+str(art.image))
|
||||||
res["thumb_url"]="http://crawler.fachschaften.at/"+str(art.image)
|
res["thumb_url"]="http://crawler.fachschaften.at/"+str(art.image)
|
||||||
|
|||||||
@@ -30,7 +30,13 @@ class Section(Base):
|
|||||||
def __init__(self, url=None,fname=None):
|
def __init__(self, url=None,fname=None):
|
||||||
self.url=url
|
self.url=url
|
||||||
self.foreign_name=fname
|
self.foreign_name=fname
|
||||||
|
|
||||||
|
def title(self):
|
||||||
|
t=self.name
|
||||||
|
if t == None or t.strip()=="":
|
||||||
|
t=self.foreign_name
|
||||||
|
return t
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def find_or_create(cls, fname):
|
def find_or_create(cls, fname):
|
||||||
s=Section.query.filter(Section.foreign_name==fname).first()
|
s=Section.query.filter(Section.foreign_name==fname).first()
|
||||||
|
|||||||
Reference in New Issue
Block a user