initial day view
This commit is contained in:
parent
98342f5d48
commit
0c08be8885
@ -3,7 +3,10 @@ from django.conf.urls import url
|
||||
from lifting import views
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^(?P<year>\d{4})/(?P<month>\d{1,2})/$', views.month, name='lifting-month'),
|
||||
url(r'^(?P<year>\d{4})/(?P<month>\d{1,2})/$', views.month_lifts,
|
||||
name='lifting-month'),
|
||||
url(r'^(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/$', views.day_lifts,
|
||||
name='lifting-day'),
|
||||
|
||||
url(r'^fitnotes/$', views.fitnotes_upload),
|
||||
]
|
||||
|
@ -14,7 +14,7 @@ from .models import Set
|
||||
|
||||
|
||||
@login_required
|
||||
def month(request, year, month):
|
||||
def month_lifts(request, year, month):
|
||||
year, month = int(year), int(month)
|
||||
|
||||
sets_by_day = defaultdict(set)
|
||||
@ -50,6 +50,20 @@ def month(request, year, month):
|
||||
'prev_date': prev_date, 'next_date': next_date
|
||||
})
|
||||
|
||||
@login_required
|
||||
def day_lifts(request, year, month, day):
|
||||
year, month, day = int(year), int(month), int(day)
|
||||
|
||||
sets = list(Set.objects.filter(user=request.user, date__year=year, date__month=month,
|
||||
date__day=day))
|
||||
date = datetime.date(year, month, day)
|
||||
prev_date = date - datetime.timedelta(days=1)
|
||||
next_date = date + datetime.timedelta(days=1)
|
||||
|
||||
return render(request, 'lifting/day.html', {'date': date, 'sets': sets,
|
||||
'prev_date': prev_date, 'next_date': next_date
|
||||
})
|
||||
|
||||
|
||||
class FitnotesUploadForm(forms.Form):
|
||||
file = forms.FileField()
|
||||
|
12
templates/lifting/day.html
Normal file
12
templates/lifting/day.html
Normal file
@ -0,0 +1,12 @@
|
||||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
|
||||
<section class="row header-row">
|
||||
<section class="col-sm-12">
|
||||
<a href="{% url 'lifting-day' prev_date.year prev_date.month prev_date.day %}">← Previous</a>
|
||||
<h3 class="month-name">{{date|date:"F d Y"}}</h3>
|
||||
<a href="{% url 'lifting-day' next_date.year next_date.month next_date.day %}">Next →</a>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
{% endblock %}
|
@ -29,7 +29,9 @@
|
||||
{% for day in week %}
|
||||
<td class="calendar-day">
|
||||
{% if day %}
|
||||
<div class="day-number">{{day.number}}</div>
|
||||
<div class="day-number">
|
||||
<a href="{% url 'lifting-day' date.year date.month day.number %}">{{day.number}}</a>
|
||||
</div>
|
||||
<ul class="month-day-list">
|
||||
{% for set in day.sets %}
|
||||
<li>
|
||||
|
Loading…
Reference in New Issue
Block a user