Show dates in calendar week selection

This commit is contained in:
Raphael Michel
2020-10-05 17:29:19 +02:00
parent a31f0c1bc8
commit e9a972ad60
5 changed files with 14 additions and 8 deletions

View File

@@ -16,9 +16,9 @@
</a>
</div>
<div class="col-sm-4 col-xs-12 text-center">
<select name="week" class="form-control">
<select name="week" class="form-control select-calendar-week-short">
{% for w in weeks %}
<option value="{{ w }}" {% if w == date.isocalendar.1 %}selected{% endif %}>{% trans "W" %} {{ w }}</option>
<option value="{{ w.0.isocalendar.1 }}" {% if w.0.isocalendar.1 == date.isocalendar.1 %}selected{% endif %}>{% trans "W" %} {{ w.0.isocalendar.1 }} ({{ w.0|date:"SHORT_DATE_FORMAT" }} {{ w.1|date:"SHORT_DATE_FORMAT" }})</option>
{% endfor %}
</select>
<select name="year" class="form-control">

View File

@@ -43,9 +43,9 @@
</a>
</div>
<div class="col-sm-4 col-xs-12 text-center">
<select name="week" class="form-control">
<select name="week" class="form-control select-calendar-week-short">
{% for w in weeks %}
<option value="{{ w }}" {% if w == date.isocalendar.1 %}selected{% endif %}>{% trans "W" %} {{ w }}</option>
<option value="{{ w.0.isocalendar.1 }}" {% if w.0.isocalendar.1 == date.isocalendar.1 %}selected{% endif %}>{% trans "W" %} {{ w.0.isocalendar.1 }} ({{ w.0|date:"SHORT_DATE_FORMAT" }} {{ w.1|date:"SHORT_DATE_FORMAT" }})</option>
{% endfor %}
</select>
<select name="year" class="form-control">

View File

@@ -465,8 +465,10 @@ class EventIndex(EventViewMixin, EventListMixin, CartMixin, TemplateView):
len(i) for i in ebd.values() if isinstance(i, list)
) < 2
context['days'] = days_for_template(ebd, week)
context['weeks'] = [date(self.year, i + 1, 1) for i in range(12)]
context['weeks'] = [i + 1 for i in range(53)]
context['weeks'] = [
(date.fromisocalendar(self.year, i + 1, 1), date.fromisocalendar(self.year, i + 1, 7))
for i in range(53)
]
context['years'] = range(now().year - 2, now().year + 3)
context['week_format'] = get_format('WEEK_FORMAT')
if context['week_format'] == 'WEEK_FORMAT':

View File

@@ -522,8 +522,7 @@ class WeekCalendarView(OrganizerViewMixin, EventListMixin, TemplateView):
ebd = self._events_by_day(before, after)
ctx['days'] = days_for_template(ebd, week)
ctx['weeks'] = [date(self.year, i + 1, 1) for i in range(12)]
ctx['weeks'] = [i + 1 for i in range(53)]
ctx['weeks'] = [(date.fromisocalendar(self.year, i + 1, 1), date.fromisocalendar(self.year, i + 1, 7)) for i in range(53)]
ctx['years'] = range(now().year - 2, now().year + 3)
ctx['week_format'] = get_format('WEEK_FORMAT')
if ctx['week_format'] == 'WEEK_FORMAT':

View File

@@ -124,3 +124,8 @@
#monthselform .row > div {
margin-bottom: 15px;
}
@media(min-width: $screen-md-min) {
.select-calendar-week-short {
max-width: 50%;
}
}