- commit
- 295b3397e9b704ad42d27c318dfaca6522357f7e
- parent
- 0f8de167eb1bfaeabe298ace7ce1a1cd6c46c60b
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2020-08-13 05:36
make year/month optional in calendar view
Diffstat
| M | rebelstuff/admin.py | 6 | +----- |
| M | rebelstuff/templates/rebelstuff/calendar.html | 4 | ++-- |
| M | rebelstuff/urls.py | 2 | +- |
| M | rebelstuff/views.py | 5 | +++-- |
4 files changed, 7 insertions, 10 deletions
diff --git a/rebelstuff/admin.py b/rebelstuff/admin.py
@@ -1,5 +1,3 @@1 -1 import datetime2 -13 1 from django.conf import settings 4 2 from django.contrib.auth.admin import UserAdmin 5 3 from django.contrib.auth import models as auth_models @@ -10,13 +8,11 @@ from django.utils.translation import gettext_lazy as _ 10 8 from . import models 11 9 from .views import ContractView 12 1013 -1 today = datetime.date.today()14 -115 11 16 12 class Site(admin.AdminSite): 17 13 site_header = 'RebelStuff' 18 14 site_title = 'RebelStuff'19 -1 site_url = '/calendar/%i/%i/' % (today.year, today.month)-1 15 site_url = '/calendar/' 20 16 index_title = _('Home') 21 17 22 18
diff --git a/rebelstuff/templates/rebelstuff/calendar.html b/rebelstuff/templates/rebelstuff/calendar.html
@@ -51,8 +51,8 @@ 51 51 </script> 52 52 53 53 <ul class="object-tools">54 -1 <li><a href="{% url 'calendar' prev.year prev.month %}">{% trans 'Previous month' %}</a></li>55 -1 <li><a href="{% url 'calendar' next.year next.month %}">{% trans 'Next month' %}</a></li>-1 54 <li><a href="{% url 'calendar' %}?year={{ prev.year }}&month={{ prev.month }}">{% trans 'Previous month' %}</a></li> -1 55 <li><a href="{% url 'calendar' %}?year={{ next.year }}&month={{ next.month }}">{% trans 'Next month' %}</a></li> 56 56 </ul> 57 57 58 58 <table class="calendar">
diff --git a/rebelstuff/urls.py b/rebelstuff/urls.py
@@ -6,7 +6,7 @@ from .admin import site 6 6 urlpatterns = [ 7 7 path('', site.urls), 8 8 path(9 -1 'calendar/<int:year>/<int:month>/',-1 9 'calendar/', 10 10 views.CalendarView.as_view(), 11 11 name='calendar', 12 12 ),
diff --git a/rebelstuff/views.py b/rebelstuff/views.py
@@ -24,8 +24,9 @@ class CalendarView(PermissionRequiredMixin, TemplateView): 24 24 context = super().get_context_data(**kwargs) 25 25 context['stuff_list'] = Stuff.objects.all() 26 2627 -1 year = self.kwargs['year']28 -1 month = self.kwargs['month']-1 27 today = datetime.date.today() -1 28 year = int(self.request.GET.get('year', today.year)) -1 29 month = int(self.request.GET.get('month', today.month)) 29 30 context['date_list'] = [] 30 31 for i in range(31): 31 32 try: