meal plan prev+next week buttons
This commit is contained in:
parent
becdcdc6a4
commit
6f4a40acdd
@ -14,12 +14,26 @@
|
|||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12" style="text-align: center">
|
||||||
<form action="{% url 'view_plan' %}" method="post">
|
<form action="{% url 'view_plan' %}" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<label>{% trans 'Week' %}
|
<label>{% trans 'Week' %}
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<button class="btn btn-outline-secondary" id="btn_prev"
|
||||||
|
onclick="$('#id_week').val('{{ surrounding_weeks.prev }}'); document.forms[0].submit()">
|
||||||
|
<i class="fas fa-arrow-left"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
<input name="week" id="id_week" class="form-control" type="week"
|
<input name="week" id="id_week" class="form-control" type="week"
|
||||||
onchange="document.forms[0].submit()" value="{{ js_week }}">
|
onchange="document.forms[0].submit()" value="{{ js_week }}">
|
||||||
|
<div class="input-group-append">
|
||||||
|
<button class="btn btn-outline-secondary" id="btn_next"
|
||||||
|
onclick="$('#id_week').val('{{ surrounding_weeks.next }}'); document.forms[0].submit()">
|
||||||
|
<i class="fas fa-arrow-right"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</label>
|
</label>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@ -30,7 +44,7 @@
|
|||||||
<table class="table table-bordered">
|
<table class="table table-bordered">
|
||||||
<tr style="text-align: center">
|
<tr style="text-align: center">
|
||||||
{% for d in days %}
|
{% for d in days %}
|
||||||
<th>{{ d }}</th>
|
<th>{{ d | date:"l" }}<br/>{{ d }}</th>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tr>
|
</tr>
|
||||||
{% for plan_key, plan_value in plan.items %}
|
{% for plan_key, plan_value in plan.items %}
|
||||||
|
@ -95,6 +95,8 @@ def meal_plan(request):
|
|||||||
year, week = js_week.split('-')
|
year, week = js_week.split('-')
|
||||||
first_day, last_day = get_start_end_from_week(year, week.replace('W', ''))
|
first_day, last_day = get_start_end_from_week(year, week.replace('W', ''))
|
||||||
|
|
||||||
|
surrounding_weeks = {'next': (last_day + timedelta(3)).strftime("%Y-W%V"), 'prev': (first_day - timedelta(3)).strftime("%Y-W%V")}
|
||||||
|
|
||||||
days = get_days_from_week(first_day, last_day)
|
days = get_days_from_week(first_day, last_day)
|
||||||
days_dict = {}
|
days_dict = {}
|
||||||
for d in days:
|
for d in days:
|
||||||
@ -109,5 +111,4 @@ def meal_plan(request):
|
|||||||
for p in plan_day:
|
for p in plan_day:
|
||||||
plan[p.meal]['days'][d].append(p)
|
plan[p.meal]['days'][d].append(p)
|
||||||
|
|
||||||
print(plan)
|
return render(request, 'meal_plan.html', {'js_week': js_week, 'plan': plan, 'days': days, 'surrounding_weeks': surrounding_weeks})
|
||||||
return render(request, 'meal_plan.html', {'js_week': js_week, 'plan': plan, 'days': days})
|
|
||||||
|
Loading…
Reference in New Issue
Block a user