Exemple #1
0
def get_groups():
    if request.method == 'GET':
        return render_template("index.html")

    username = request.form['username']
    password = request.form['password']

    if len(username) <= 0 or len(password) <= 0:
        return "[{\"error\": \"Wrong credentials\"}]"

    aurion = Aurion()

    try:

        aurion.connect(username, password)
        myCours = aurion.get_unites_and_groups()

        value = json.dumps(myCours)
        response = app.response_class(response=value,
                                      status=200,
                                      mimetype='application/json')
        return response

    except PersoException as e:
        return "[{\"error\": \"" + str(e) + "\"}]"
Exemple #2
0
def get_calendar():
    if request.method == 'GET':
        return render_template("index.html")

    username = request.form['username']
    password = request.form['password']
    month = request.form['month']
    day = request.form['day']

    if len(username) <= 0 or len(password) <= 0:
        return "[{\"error\": \"Wrong credentials\"}]"

    aurion = Aurion()
    ade = ADECalendar()

    try:

        aurion.connect(username, password)
        myCours = aurion.get_unites_and_groups()
        ade.set_groups_unites(myCours)

        result = ade.get_all_cours()
        if len(month) > 0:
            result = ade.get_cours_by_month(result, month)
            if len(day) > 0:
                result = ade.get_cours_of(day, month)

        value = json.dumps(result)
        response = app.response_class(response=value,
                                      status=200,
                                      mimetype='application/json')
        return response

    except PersoException as e:
        return "[{\"error\": \"" + str(e) + "\"}]"