Ejemplo n.º 1
0
def changeView():
    try:
        conn = p3.getConnection()
        if 'userID' in session:
            userID = session['userID']
            allCats = p3.getCats(conn, userID)
            timeSelection = request.form['time']
            dataSelection = request.form['views']

            if (dataSelection == "checklist"):
                dataStruct = p3.rightPanelTask(conn, userID)
                return jsonify(dataStruct)
            if (dataSelection == "events"):
                dataStruct = p3.rightPanelEvent(conn, userID)
                return jsonify(dataStruct)
            if (dataSelection == "log"):
                print "at dataselectionlog!"
                dataStruct = p3.allLog(conn, userID, allCats)
                print dataStruct
                return jsonify(dataStruct)

        else:
            return render_template('login.html')
    except:
        flash('Error! Redirecting to login page')
        return render_template('login.html')
Ejemplo n.º 2
0
def month_event():
    try:
        conn = p3.getConnection()
        if 'userID' in session:
            userID = session['userID']
            allCats = p3.getCats(conn, userID)  #need to take care of userID
            data = p3.rightPanelEvent(conn, userID)
            return render_template('base_event_month.html',
                                   allCats=allCats,
                                   dataStruct=data,
                                   database=DATABASE)
        else:
            return render_template('login.html')
    except:
        flash('Error! Redirecting to login page')
        return render_template('login.html')
Ejemplo n.º 3
0
def tickedCats():
    conn = p3.getConnection()
    if 'userID' in session:
        userID = session['userID']
        if request.method == 'POST':
            dataSelection = request.form['catHiddenRedirect']

            if (dataSelection == "checklist"):
                dataStruct = p3.rightPanelTask(conn, userID)
                return jsonify(dataStruct)
            if (dataSelection == "events"):
                dataStruct = p3.rightPanelEvent(conn, userID)
                return jsonify(dataStruct)
            if (dataSelection == "log"):
                allCats = p3.getCats(conn, userID)
                dataStruct = p3.allLog(conn, userID, allCats)
                return jsonify(dataStruct)
    return jsonify({"error": "Please refresh!"})
Ejemplo n.º 4
0
def addEvent():
    try:
        conn = p3.getConnection()
        if 'userID' in session:
            userID = session['userID']
            allCats = p3.getCats(conn, userID)

            if (request.form['eventName']
                    == "") or (request.form['eventDate']
                               == "") or (request.form['eventName']
                                          == "") or (request.form['eventName']
                                                     == ""):
                return jsonify({"error": "Empty inputs!"})

            startCheck = request.form['startTime'].split(':')
            startCheckFormat = int(startCheck[0] + startCheck[1])
            endCheck = request.form['endTime'].split(':')
            endCheckFormat = int(endCheck[0] + endCheck[1])
            if (endCheckFormat < startCheckFormat):
                return jsonify({"error": "Time continuum violation!"})

            eventName = request.form[
                'eventName']  # we should change the name of this varchar
            eventDate = request.form['eventDate']
            start = request.form['startTime'] + ':00'
            end = request.form['endTime'] + ':00'

            if eventName.split() != [] and p3.legaldate(eventDate):
                checkError = p3.addEvent(conn, userID, eventName, eventDate,
                                         start, end)
                print checkError
                if (checkError):
                    return jsonify({"error": "Scheduling conflict!"})

            dataStruct = p3.rightPanelEvent(conn, userID)
            return jsonify(dataStruct)
        else:
            print "break1"
            return render_template('login.html')
    except:
        flash('Error! Redirecting to login page')
        print "break2"
        return render_template('login.html')