Пример #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) + "\"}]"
Пример #2
0
def get_agenda():
    if request.method == 'GET':
        return render_template("index.html")

    mail = request.form['mail']
    ade = ADECalendar()
    #ade = ADEApi()

    try:
        aurion = Aurion()
        unites_and_groups = aurion.get_unites_and_groups_from_csv(mail)
        ade.set_groups_unites(unites_and_groups)

        result = ade.get_all_cours()
        if not result:
            return "[{\"error\": \"No events\"}]"

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

    except Exception as e:
        return "[{\"error\": \"" + str(e) + "\"}]"
Пример #3
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) + "\"}]"
Пример #4
0
def get_agenda_mail(mail):
    ade = ADECalendar()
    #ade = ADEApi()

    try:
        aurion = Aurion()
        unites_and_groups = aurion.get_unites_and_groups_from_csv(mail)
        ade.set_groups_unites(unites_and_groups)
        result = ade.get_all_cours()
        if not result:
            return "[{\"error\": \"No events\"}]"

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

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