calendar view more functional now
This commit is contained in:
parent
fc52f7245f
commit
da59374b7e
9
lifting/urls.py
Normal file
9
lifting/urls.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
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'^fitnotes/$', views.fitnotes_upload),
|
||||||
|
]
|
@ -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]]
|
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,
|
# prev and next month
|
||||||
'days': days_by_week
|
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,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,13 +1,33 @@
|
|||||||
|
.header-row {
|
||||||
|
padding-bottom: 2em;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.month-name {
|
||||||
|
display: inline;
|
||||||
|
padding: 0 2em;
|
||||||
|
}
|
||||||
.calendar-month {
|
.calendar-month {
|
||||||
table-layout: fixed;
|
table-layout: fixed;
|
||||||
}
|
}
|
||||||
|
.calendar-month > thead > tr > th {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
.calendar-month > tbody > tr > td {
|
.calendar-month > tbody > tr > td {
|
||||||
border: 1px solid #666;
|
border: 1px solid #666;
|
||||||
padding: 0 0 2em 0;
|
padding: 0 0 2em 0;
|
||||||
}
|
}
|
||||||
|
.calendar-day {
|
||||||
|
height: 8em;
|
||||||
|
}
|
||||||
.day-number {
|
.day-number {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
padding: 0 1em 0 0;
|
padding: 0 1em 0 0;
|
||||||
background-color: #ddd;
|
background-color: #ddd;
|
||||||
}
|
}
|
||||||
|
.month-day-list {
|
||||||
|
padding-left: 1em;
|
||||||
|
}
|
||||||
|
.month-day-list li {
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<section class="row">
|
<section class="row header-row">
|
||||||
<section class="col-sm-6">
|
<section class="col-sm-12">
|
||||||
<h3>{{date|date:"F Y"}}</h3>
|
<a href="{% url 'lifting-month' prev_date.year prev_date.month %}">← Previous</a>
|
||||||
|
<h3 class="month-name">{{date|date:"F Y"}}</h3>
|
||||||
|
<a href="{% url 'lifting-month' next_date.year next_date.month %}">Next →</a>
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
@ -28,7 +30,7 @@
|
|||||||
<td class="calendar-day">
|
<td class="calendar-day">
|
||||||
{% if day %}
|
{% if day %}
|
||||||
<div class="day-number">{{day.number}}</div>
|
<div class="day-number">{{day.number}}</div>
|
||||||
<ul>
|
<ul class="month-day-list">
|
||||||
{% for set in day.sets %}
|
{% for set in day.sets %}
|
||||||
<li>
|
<li>
|
||||||
{{set}}
|
{{set}}
|
||||||
|
@ -3,10 +3,11 @@ from django.conf.urls import include, url
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.conf.urls.static import static
|
from django.conf.urls.static import static
|
||||||
|
|
||||||
|
import lifting.urls
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^admin/', include(admin.site.urls)),
|
url(r'^admin/', include(admin.site.urls)),
|
||||||
|
|
||||||
url(r'^fitnotes-upload/$', 'lifting.views.fitnotes_upload'),
|
url(r'^lifting/', include(lifting.urls.urlpatterns)),
|
||||||
url(r'^lifting/(?P<year>\d{4})/(?P<month>\d{1,2})/$', 'lifting.views.month'),
|
|
||||||
|
|
||||||
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
||||||
|
Loading…
Reference in New Issue
Block a user