예제 #1
0
def news():
    with dbapi2.connect(app.config['dsn']) as connection:
        _newsList = dbmanager.getNews(connection)
        _sponsorList = dbmanager.getSponsor(connection)
        _channelList = dbmanager.getChannels(connection)
        _info = layoutInfo('All about Snooker','Daily News for Snooker','static/img/home-bg.jpg')
        return render_template('fnews.html', newsList = _newsList, info = _info, sponsorList = _sponsorList, channelList = _channelList)
예제 #2
0
def addNews():
    with dbapi2.connect(app.config['dsn']) as connection:

        if(request.method == 'GET'):
            _newsList = dbmanager.getNews(connection)
            return render_template('news.html', newsList = _newsList)

        if(request.form["action"] == "add_news_action"):
            dbmanager.addNews(request.form['news_title'], request.form['message'], request.form['news_imageurl'], request.form['news_date'], connection)
            return redirect(url_for('addNews'))

        if(request.form["action"] == "delete_news_action"):
            dbmanager.deleteNews(request.form['id'], connection)
            return redirect(url_for('addNews'))