Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5908dff
initial commit branch 74/user_registration_bizmarcin
bizmarcin Sep 16, 2019
883b0d7
add child and caregiver, add record to assign child to caregiver
bizmarcin Sep 16, 2019
db1a330
already done in master branch
bizmarcin Sep 17, 2019
3f3ef08
add col is_active to table home_points
bizmarcin Sep 17, 2019
fb27a74
simple solution for showing only active tasks
bizmarcin Sep 17, 2019
7666208
change query for include is_active in table home_points
bizmarcin Sep 17, 2019
d54f2d8
add buttons
bizmarcin Sep 17, 2019
892ecdd
remove points indication
bizmarcin Sep 17, 2019
dc6c4be
add point number near button, coment 'block add_points'
bizmarcin Sep 18, 2019
1d36092
sync with master
bizmarcin Sep 25, 2019
b8ae25a
chenge from GET to POST
bizmarcin Sep 25, 2019
973cf2d
switch to master
bizmarcin Oct 4, 2019
8952c8b
Merge branch 'master' into 79_add_buutons_to_add_points
bizmarcin Oct 4, 2019
2852e51
pull froma master and starting work froma limits
bizmarcin Oct 4, 2019
66923df
add points button ready to check
bizmarcin Oct 12, 2019
631a628
sync with #79 and master, first few fix, not ready
bizmarcin Oct 12, 2019
baff351
max_day, still to fix history table
bizmarcin Oct 12, 2019
2b8667e
pull from master
bizmarcin Nov 2, 2019
010df89
almost done, not for PR yeat
bizmarcin Nov 2, 2019
124b6b6
works but there no flash message, check time diff
bizmarcin Nov 2, 2019
35279da
ready for PR
bizmarcin Nov 2, 2019
e812d3b
test
bizmarcin Nov 3, 2019
97d73f3
test1
bizmarcin Nov 3, 2019
0db2613
Merge branch 'master' into 81_max_week
bizmarcin Nov 3, 2019
ecbd4b5
modify max_day method to universal, add max_week check
bizmarcin Nov 3, 2019
fdd677c
Merge branch 'master' into 81_max_week
bizmarcin Nov 4, 2019
6c014db
Merge branch 'master' into 81_max_week
bizmarcin Nov 21, 2019
490f889
prepare init data after merge master
bizmarcin Nov 21, 2019
7bb511f
fix data
bizmarcin Nov 21, 2019
0133734
start work with Leszeks CR
bizmarcin Nov 24, 2019
3a0712f
modify flash message day/week
bizmarcin Nov 24, 2019
2c3befa
Merge branch 'master' into 81_max_week
tgbdc7 Nov 25, 2019
e687379
once again
bizmarcin Nov 25, 2019
15876b9
Merge branch 'master' into 82_midify_detail_view
bizmarcin Nov 25, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions zeton/api/points.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ def is_limit_reached(child_id, exercise_id, days, max_column):
return False
return True

@bp.route("/child/<child_id>/points/add/<points>/<exercise_id>", methods=['POST'])
@bp.route("/child/<child_id>/points/add/<points>/<exercise_id>/<is_detail>", methods=['POST'])
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

proponuję bez is_detail - można wykorzystać request.referrer

@auth.login_required
@auth.logged_child_or_caregiver_only
def add_points(child_id, points, exercise_id):

def add_points(child_id, points, exercise_id,is_detail):
if is_limit_reached(child_id, exercise_id, 1, 'max_day') and is_limit_reached(child_id, exercise_id, 7, 'max_week'):
logged_user_id = g.user_data['id']
return_url = request.args.get('return_url', '/')
Expand All @@ -46,15 +47,23 @@ def add_points(child_id, points, exercise_id):
if role == 'child':
return redirect(return_url)
else:
return redirect(url_for('views.child', child_id=child_id))
if is_detail == "0":
return redirect(url_for('views.child', child_id=child_id))
else:
return redirect(url_for('views.task_detail', child_id=child_id))
Comment on lines +50 to +53
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

proponuję return redirect(request.referrer)
uprości i kod będzie bardziej czytelny .

else:
if not is_limit_reached(child_id, exercise_id, 1, 'max_day'):
flash(f'W ciągu ostatniej doby został przekroczony limit punktów')

if not is_limit_reached(child_id, exercise_id, 7, 'max_week'):
flash(f'W ciągu ostatnich 7 dni został przekroczony limit punktów')

return redirect(url_for('views.child', child_id=child_id))


if is_detail == "0":
return redirect(url_for('views.child', child_id=child_id))
else:
return redirect(url_for('views.task_detail', child_id=child_id))



@bp.route("/child/<child_id>/points/use", methods=['POST'])
Expand Down
4 changes: 4 additions & 0 deletions zeton/templates/base/childs_basic_data.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ <h2> Ilość punktów {{ child_points.points }} punktów</h2>
<h3>Punkty doświadczenia {{ child_points.exp }} punktów</h3>
<h3>Szkolny rekord tygodnia : {{ child_points.school_weekly_highscore }}</h3>

{% if messages %}
<div class="alert alert-dark">{{ messages[0] }}</div>
{% endif %}

{% if child.bans.6.active %}
<h2 style="color: red;"> Masz BANA !</h2>
<h4> Ban konczy sie: {{ child.bans.6.stop|ban_time }}</h4>
Expand Down
2 changes: 1 addition & 1 deletion zeton/templates/base/index_child.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ <h2 class="text-center">Sposób na zdobycie punktów</h2>
<td>{{ loop.index }}</td>
<td>{{ task.name }}</td>
<td>{{ task.points }}</td>
<form action="/api/child/{{ child.id }}/points/add/{{ task.points }}/{{ task.id }}"
<form action="/api/child/{{ child.id }}/points/add/{{ task.points }}/{{ task.id }}/0"
method="post">
<td><input class="btn btn-info" type="submit" name="Dodaj punkty" value="Dodaj"/></td>
</form>
Expand Down
4 changes: 4 additions & 0 deletions zeton/templates/tasks/task_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ <h2 class="text-center">Sposoby na zdobycie punktów</h2>
<td>{{ task.max_day }}</td>
<td>{{ task.max_week }}</td>
{% if role == 'caregiver' %}
<form action="/api/child/{{ child.id }}/points/add/{{ task.points }}/{{ task.id }}/1"
method="post">
<td><input class="btn btn-info" type="submit" name="Dodaj punkty" value="Dodaj"/></td>
</form>
<form action="/api/child/{{ child.id }}/tasks/deactivate/{{ task.id }}"
method="post">
<td><input class="btn btn-info" type="submit" name="Deactivate_task"
Expand Down
4 changes: 3 additions & 1 deletion zeton/views/details.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ def task_detail(child_id):
'child_points': child_points
}

return render_template('tasks/task_detail.html', **context)
messages = get_flashed_messages()

return render_template('tasks/task_detail.html', **context, messages=messages)


@bp.route('/prizes_detail/<child_id>')
Expand Down