Exemple #1
0
def admin_news(id):
    form = ArticleForm(request.form)
    if request.method == 'POST' and form.validate():
        article = get_article(form.id.data)
        title = form.title.data
        date = get_date_from_str(form.date.data)
        place = form.place.data
        article.update(title, date, place, True)
        logger.info("{0} post data of job {1}.".format(g.current_user.name, id))
        return redirect(url_for('admin.admin_feeds', id=article.fid))

    a = get_article(id)
    fulltext = a.body 
    if a.is_published:
        form.place.data = a.place
        form.date.data = a.date.strftime('%Y-%m-%d %H:%M:%S')
        form.title.data = a.title
    else:
        date, place = get_time_and_place(fulltext)
        form.place.data = (place or u'').strip()
        form.date.data = (date or u'').strip()
        form.title.data = a.title.split()[-1]
    form.id.label = ''
    form.id.data = id
    return render_template('admin.html', form=form, fulltext=fulltext, title=a.title)
Exemple #2
0
def detail(uid, aid):
    article = get_article(aid)
    if not article:
        return dict()
    feed = get_feed(article.fid)
    return dict(aid=article.id, feed=feed.name,
            date=article.date.strftime('%Y-%m-%d %H:%M'),
            expired=(datetime.now() > article.date), place=article.place,
            pubdate=article.pubdate, link=article.link, url=article.url)
Exemple #3
0
def delete_job(id):
    job = get_article(id)
    if not job:
        abort(404)
    job.delete()
Exemple #4
0
def get_local_fulltext(aid):
    a = get_article(aid)
    content = a and a.body or '' 
    if not content:
        return None
    return content
Exemple #5
0
def collect(uid, aid):
    article = get_article(aid)
    if not article:
        return dict(r=1, msg='收藏的主题不存在')
    article.collect(uid)
    return dict(r=0, msg='收藏成功')