예제 #1
0
파일: index.py 프로젝트: jwojciec/zeton
def index():
    role = g.user_data['role']
    logged_user_id = g.user_data['id']

    template = None
    context = {}

    if role == 'caregiver':
        children = users.get_caregivers_children(logged_user_id)
        template = 'index_caregiver.html'

        context.update({
            "firstname": g.user_data['firstname'],
            "role": role,
            "children": children
        })

    elif role == 'child':

        template = 'index_child.html'
        child = users.get_child_data(logged_user_id)
        child_points = points.get_child_points(child['id'])
        childs_tasks = tasks.get_tasks(logged_user_id)
        childs_prizes = prizes.get_prizes(logged_user_id)
        context = {
            'child': child,
            'child_points': child_points,
            'childs_tasks': childs_tasks,
            'childs_prizes': childs_prizes
        }

    messages = get_flashed_messages()

    return render_template(template, **context, messages=messages)
예제 #2
0
파일: user.py 프로젝트: tgbdc7/zeton
def set_child_password(child_id):
    logged_user_id = g.user_data['id']
    child = users.get_child_data(child_id)
    child_password = child['password']

    password = request.form['password']
    new_password = request.form['new_password']
    repeat_new_password = request.form['repeat_new_password']

    hashed_new_password = generate_password_hash(new_password)

    if not logged_user_id:
        return abort(403)

    if not (password == '' or new_password == '' or repeat_new_password == ''):
        if new_password == repeat_new_password:
            if auth.password_validation(new_password):
                if check_password_hash(child_password, password):
                    users.update_password(child['id'], hashed_new_password)
                    flash('Nowe hasło wprowadzone poprawnie')
                flash(
                    'Aktualne hasło zostało źle wprowadzone. Spróbuj ponownie')
            flash(
                'Hasło musi zawierać 1 dużą literę, 1 małą literę, 1 cyfrę i musi mieć długość 8 znaków'
            )
        flash(
            'Nowe hasło i powtórzone nowe hasło muszą się zgadzać. Spróbuj ponownie'
        )
    else:
        flash('Wypełnij wszystkie pola')

    return redirect(url_for('views.child_password_change', child_id=child_id))
예제 #3
0
파일: index.py 프로젝트: tgbdc7/zeton
def child(child_id):
    child = users.get_child_data(child_id)
    childs_tasks = tasks.get_tasks(child_id)
    childs_prizes = prizes.get_prizes(child_id)
    role = g.user_data['role']
    child_points = points.get_child_points(child['id'])
    info = bans.get_most_important_warn_ban(child_id).split(';')
    info_str = info[0]
    info_bck = info[1]

    context = {
        'child': child,
        'childs_tasks': childs_tasks,
        'childs_prizes': childs_prizes,
        'role': role,
        'child_points': child_points,
        'info_str': info_str,
        'info_bck': info_bck,
        "firstname": g.user_data['firstname']
    }

    messages = get_flashed_messages()

    return render_template('base/index_child.html',
                           **context,
                           messages=messages)
예제 #4
0
파일: details.py 프로젝트: tgbdc7/zeton
def add_task(child_id):
    logged_user_id = g.user_data['id']
    user_data = users.get_user_data(logged_user_id)
    child = users.get_child_data(child_id)

    context = {'user_data': user_data, 'child': child}

    messages = get_flashed_messages()

    return render_template('tasks/add_task.html', **context, messages=messages)
예제 #5
0
파일: settings.py 프로젝트: tgbdc7/zeton
def child_firstname_change(child_id):
    child = users.get_child_data(child_id)
    logged_user_id = g.user_data['id']
    user_data = users.get_user_data(logged_user_id)

    context = {'child': child,
               'user_data': user_data}

    messages = get_flashed_messages()

    return render_template('user/child_firstname_change.html', **context, messages=messages)
예제 #6
0
파일: user.py 프로젝트: tgbdc7/zeton
def set_child_firstname(child_id):
    child = users.get_child_data(child_id)

    new_firstname = request.form.get('new_firstname')

    if new_firstname:
        users.update_firstname(child_id, new_firstname)
    else:
        flash('Wprowadź imię')
    flash('Imię zostało zmienione')

    return redirect(url_for('views.child_firstname_change', child_id=child_id))
예제 #7
0
파일: details.py 프로젝트: malsolec/zeton
def bans_detail(child_id):
    role = g.user_data['role']

    try:
        child = users.get_child_data(child_id)
    except TypeError:
        return abort(403)
    child_points = points.get_child_points(child['id'])

    context = {'child': child, 'role': role, 'child_points': child_points}

    return render_template('bans_detail.html', **context)
예제 #8
0
파일: details.py 프로젝트: tgbdc7/zeton
def edit_task(child_id, task_id):
    logged_user_id = g.user_data['id']
    child_id = int(child_id)
    user_data = users.get_user_data(logged_user_id)
    child = users.get_child_data(child_id)
    task = tasks.get_task_by_tasks_id(child_id, task_id)

    context = {'user_data': user_data, 'child': child, 'task': task}

    messages = get_flashed_messages()

    return render_template('tasks/edit_task.html',
                           **context,
                           messages=messages)
예제 #9
0
파일: details.py 프로젝트: tgbdc7/zeton
def edit_prize(child_id, prize_id):
    logged_user_id = g.user_data['id']
    user_data = users.get_user_data(logged_user_id)
    child = users.get_child_data(child_id)
    child_id = int(child_id)
    prize_id = int(prize_id)
    prize = prizes.get_prize(child_id, prize_id)

    context = {'user_data': user_data, 'child': child, 'prize': prize}

    messages = get_flashed_messages()

    return render_template('prizes/edit_prize.html',
                           **context,
                           messages=messages)
예제 #10
0
def task_detail(child_id):
    child = users.get_child_data(child_id)
    childs_tasks = tasks.get_tasks(child_id)
    childs_points_history = points.get_points_history(child_id)
    role = g.user_data['role']
    child_points = points.get_child_points(child['id'])

    context = {'child': child,
               'childs_tasks': childs_tasks,
               'childs_points_history': childs_points_history,
               'role': role,
               'child_points': child_points
               }

    return render_template('tasks/task_detail.html', **context)
예제 #11
0
def child(child_id):
    child = users.get_child_data(child_id)
    childs_tasks = tasks.get_tasks(child_id)
    childs_prizes = prizes.get_prizes(child_id)
    role = g.user_data['role']
    child_points = points.get_child_points(child['id'])

    context = {'child': child,
               'childs_tasks': childs_tasks,
               'childs_prizes': childs_prizes,
               'role': role,
               'child_points': child_points}

    messages = get_flashed_messages()

    return render_template('caregiver_panel.html', **context, messages=messages)
예제 #12
0
파일: details.py 프로젝트: tgbdc7/zeton
def school_points_detail(child_id):
    role = g.user_data['role']

    try:
        child = users.get_child_data(child_id)
    except TypeError:
        return abort(403)
    child_points = points.get_child_points(child['id'])

    context = {
        'child': child,
        'role': role,
        'child_points': child_points,
        "firstname": g.user_data['firstname']
    }

    return render_template('school_points/school_points_detail.html',
                           **context)
예제 #13
0
파일: index.py 프로젝트: jwojciec/zeton
def add_caregiver_to_child(child_id):
    role = g.user_data['role']

    try:
        child = users.get_child_data(child_id)
    except TypeError:
        return abort(403)

    context = {
        'child': child,
        'role': role,
        "firstname": g.user_data['firstname']
    }

    messages = get_flashed_messages()

    return render_template('add_caregiver_to_child.html',
                           **context,
                           messages=messages)
예제 #14
0
def prizes_detail(child_id):
    role = g.user_data['role']

    try:
        child = users.get_child_data(child_id)
    except TypeError:
        return abort(403)

    childs_prizes = prizes.get_prizes(child_id)
    child_points = points.get_child_points(child['id'])
    childs_points_history = points.get_points_history(child_id)

    context = {'child': child,
               'childs_prizes': childs_prizes,
               'role': role,
               'child_points': child_points,
               'childs_points_history': childs_points_history
               }

    return render_template('prizes/prizes_detail.html', **context)
예제 #15
0
파일: details.py 프로젝트: tgbdc7/zeton
def bans_detail(child_id):
    role = g.user_data['role']

    try:
        child = users.get_child_data(child_id)
    except TypeError:
        return abort(403)
    child_points = points.get_child_points(child['id'])
    info = bans.get_most_important_warn_ban(child_id).split(';')
    info_str = info[0]
    info_bck = info[1]

    context = {
        'child': child,
        'role': role,
        'child_points': child_points,
        'info_str': info_str,
        'info_bck': info_bck,
        "firstname": g.user_data['firstname']
    }

    return render_template('bans/bans_detail.html', **context)
예제 #16
0
파일: settings.py 프로젝트: malsolec/zeton
def child_settings(child_id):
    child = users.get_child_data(child_id)

    context = {'child': child}

    return render_template('child_settings.html', **context)