list all exercises by month
This commit is contained in:
parent
32fac6e442
commit
6eedca2b7e
@ -17,9 +17,9 @@ from .models import Set
|
||||
def month(request, year, month):
|
||||
year, month = int(year), int(month)
|
||||
|
||||
sets_by_day = defaultdict(list)
|
||||
sets_by_day = defaultdict(set)
|
||||
for workset in Set.objects.filter(user=request.user, date__year=year, date__month=month):
|
||||
sets_by_day[workset.date.day].append(workset)
|
||||
sets_by_day[workset.date.day].add(workset.exercise)
|
||||
date = datetime.date(year, month, 1)
|
||||
first_day, max_days = calendar.monthrange(year, month)
|
||||
# make first_day use 0 for sunday
|
||||
@ -31,7 +31,7 @@ def month(request, year, month):
|
||||
for day in range(max_days+1):
|
||||
days.append({'number': day, 'sets': sets_by_day[day]})
|
||||
|
||||
days_by_week = [days[0:7], days[7:14], days[14:21], days[21:28], days[28:35]
|
||||
days_by_week = [days[0:7], days[7:14], days[14:21], days[21:28], days[28:35]]
|
||||
|
||||
return render(request, 'month.html', { 'date': date,
|
||||
'days': days_by_week
|
||||
|
13
static/css/bia.css
Normal file
13
static/css/bia.css
Normal file
@ -0,0 +1,13 @@
|
||||
.calendar-month {
|
||||
table-layout: fixed;
|
||||
}
|
||||
.calendar-month > tbody > tr > td {
|
||||
border: 1px solid #666;
|
||||
padding: 0 0 2em 0;
|
||||
}
|
||||
.day-number {
|
||||
width: 100%;
|
||||
text-align: right;
|
||||
padding: 0 1em 0 0;
|
||||
background-color: #ddd;
|
||||
}
|
@ -9,7 +9,7 @@
|
||||
|
||||
<section class="row">
|
||||
<section class="col-sm-12">
|
||||
<table class="calendar-month">
|
||||
<table class="table calendar-month">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Sunday</th>
|
||||
@ -25,10 +25,16 @@
|
||||
{% for week in days %}
|
||||
<tr>
|
||||
{% for day in week %}
|
||||
<td>
|
||||
<td class="calendar-day">
|
||||
{% if day %}
|
||||
<span class="calendar-day">{{day.number}}</span>
|
||||
{{day.sets|length}}
|
||||
<div class="day-number">{{day.number}}</div>
|
||||
<ul>
|
||||
{% for set in day.sets %}
|
||||
<li>
|
||||
{{set}}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</td>
|
||||
{% endfor %}
|
||||
|
Loading…
Reference in New Issue
Block a user