Пример #1
0
from app.channel import Channel
from app.user import User
from app.message_class import Message_Class
from flask.ext.sqlalchemy import SQLAlchemy
from wtforms import SelectMultipleField, SubmitField, DateField, SelectField
from sqlalchemy import desc
from flask_wtf import Form
from wtforms import DateField
import time

#GLOBAL VARIABLES
usr = User()
ch = Channel()
#Querying the database for all exsisting users and chanels, 
#then returning them as an ordered dictionary
allUserData = usr.userList()
allChannelData = ch.channelList()

#Formating dictionaries into a list of tuples for dropdown fields
def formatDataForDropdown(dataDictionary):
    avaliableSelections = [('None', 'All')]
    for key in dataDictionary:
        selection = (key, key)
        avaliableSelections.append(selection)
    return avaliableSelections


#Form class that holds information on dt(Date FIeld), user and channel fields.
class Select2TagForm(Form):
    dataUser = usr.names
    userOptions = formatDataForDropdown(dataUser)