diff --git a/lifting/urls.py b/lifting/urls.py new file mode 100644 index 0000000..1e96603 --- /dev/null +++ b/lifting/urls.py @@ -0,0 +1,9 @@ +from django.conf.urls import url + +from lifting import views + +urlpatterns = [ + url(r'^(?P\d{4})/(?P\d{1,2})/$', views.month, name='lifting-month'), + + url(r'^fitnotes/$', views.fitnotes_upload), +] diff --git a/lifting/views.py b/lifting/views.py index 1a74608..ebb6955 100644 --- a/lifting/views.py +++ b/lifting/views.py @@ -33,8 +33,23 @@ def month(request, year, month): days_by_week = [days[0:7], days[7:14], days[14:21], days[21:28], days[28:35], days[35:42]] - return render(request, 'month.html', { 'date': date, - 'days': days_by_week + # prev and next month + if date.month == 1: + prev_date = datetime.date(year-1, 12, 1) + next_date = datetime.date(year, 2, 1) + elif date.month == 12: + prev_date = datetime.date(year, 11, 1) + next_date = datetime.date(year+1, 1, 1) + else: + prev_date = datetime.date(year, month-1, 1) + next_date = datetime.date(year, month+1, 1) + + + + return render(request, 'month.html', {'date': date, + 'days': days_by_week, + 'prev_date': prev_date, + 'next_date': next_date, }) diff --git a/static/css/bia.css b/static/css/bia.css index 150e249..d20f5ac 100644 --- a/static/css/bia.css +++ b/static/css/bia.css @@ -1,13 +1,33 @@ +.header-row { + padding-bottom: 2em; + text-align: center; +} +.month-name { + display: inline; + padding: 0 2em; +} .calendar-month { table-layout: fixed; } +.calendar-month > thead > tr > th { + text-align: center; +} .calendar-month > tbody > tr > td { border: 1px solid #666; padding: 0 0 2em 0; } +.calendar-day { + height: 8em; +} .day-number { width: 100%; text-align: right; padding: 0 1em 0 0; background-color: #ddd; } +.month-day-list { + padding-left: 1em; +} +.month-day-list li { + list-style: none; +} diff --git a/templates/month.html b/templates/month.html index 9734d22..1b8417e 100644 --- a/templates/month.html +++ b/templates/month.html @@ -1,9 +1,11 @@ {% extends "base.html" %} {% block content %} -
-
-

{{date|date:"F Y"}}

+
+
+ ← Previous +

{{date|date:"F Y"}}

+ Next →
@@ -28,7 +30,7 @@ {% if day %}
{{day.number}}
-
    +
      {% for set in day.sets %}
    • {{set}} diff --git a/web/urls.py b/web/urls.py index fafe7ee..eca80b5 100644 --- a/web/urls.py +++ b/web/urls.py @@ -3,10 +3,11 @@ from django.conf.urls import include, url from django.contrib import admin from django.conf.urls.static import static +import lifting.urls + urlpatterns = [ url(r'^admin/', include(admin.site.urls)), - url(r'^fitnotes-upload/$', 'lifting.views.fitnotes_upload'), - url(r'^lifting/(?P\d{4})/(?P\d{1,2})/$', 'lifting.views.month'), + url(r'^lifting/', include(lifting.urls.urlpatterns)), ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)