manager: change day/week/month urls (#72323)
This commit is contained in:
parent
4552ad19e9
commit
bf44300704
|
@ -12,9 +12,9 @@ $(function() {
|
|||
if ($('[name=day]').val()) {
|
||||
window.location = '../../../' + $('[name=year]').val() + '/' + $('[name=month]').val() + '/' + $('[name=day]').val() + '/';
|
||||
} else if ($('[name=month]').val()) {
|
||||
window.location = '../../' + $('[name=year]').val() + '/' + $('[name=month]').val() + '/';
|
||||
window.location = '../../../' + $('[name=year]').val() + '/' + $('[name=month]').val() + '/1/';
|
||||
} else {
|
||||
window.location = '../../../' + $('[name=year]').val() + '/week/' + $('[name=week]').val() + '/';
|
||||
window.location = '../../../' + $('[name=week]').val() + '/';
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
|
|
@ -10,18 +10,20 @@
|
|||
var dates = {};
|
||||
{% for year, weeks in view.get_week_dates.items %}
|
||||
dates[{{ year }}] = {};
|
||||
{% for week, weekdetails in weeks.items %}
|
||||
dates[{{ year }}][{{ week }}] = '{{ weekdetails.1 }} ({{ weekdetails.0|date:'j F' }})';
|
||||
{% for week_monday, week_label in weeks.items %}
|
||||
dates[{{ year }}]["{{ week_monday|date:'Y/m/d' }}"] = '{{ week_label }} ({{ week_monday|date:'j F' }})';
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
$('.date-picker select[name=year]').on('change', function() {
|
||||
var $week = $('.date-picker select[name="week"]');
|
||||
var selected = $week.val();
|
||||
var $selected = $(':selected', $week);
|
||||
$week.empty();
|
||||
$.each(dates[$(this).val()], function(index, value) {
|
||||
$week.append('<option value="' + index + '">' + value + '</option>');
|
||||
var index = 1;
|
||||
$.each(dates[$(this).val()], function(key, value) {
|
||||
$week.append('<option value="' + key + '" data-weeknum="' + index + '">' + value + '</option>');
|
||||
index += 1;
|
||||
});
|
||||
$week.val(selected);
|
||||
$week.val($('[data-weeknum=' + $selected.data('weeknum') + ']', $week).val());
|
||||
});
|
||||
$('.date-picker select[name=year]').change();
|
||||
});
|
||||
|
@ -30,7 +32,7 @@
|
|||
|
||||
{% block breadcrumb %}
|
||||
{{ block.super }}
|
||||
<a>{{ view.date|date:"F Y" }}</a>
|
||||
<a>{{ view.first_day|date:"F Y" }}</a>
|
||||
{% endblock %}
|
||||
|
||||
{% block appbar %}
|
||||
|
@ -39,11 +41,11 @@
|
|||
<a class="date-next pk-button" href="{{ view.get_next_week_url }}"><span class="sr-only">{% trans "Next week" %}</span></a>
|
||||
</span>
|
||||
<h2 class="date-nav">
|
||||
<span class="date-title">{{ view.date|date:_("Y \w\e\e\k W") }}</span>
|
||||
<span class="date-title">{{ view.first_day|date:_("Y \w\e\e\k W") }}</span>
|
||||
<button class="date-picker-opener"><span class="sr-only">{% trans "Pick a week" %}</span></button>
|
||||
{% with selected_week=view.date|date:"W" selected_year=view.date|date:"Y" %}
|
||||
{% with selected_week=view.first_day|date:"W" selected_year=view.first_day|date:"Y" weeks=view.get_week_dates|get:view.first_day.year %}
|
||||
<div class="date-picker" style="display: none">
|
||||
<select name="week">{% for week, week_label in view.get_weeks %}<option value="{{ week }}" {% if selected_week == week %}selected{% endif %}>{{ week_label }}</option>{% endfor %}</select>
|
||||
<select name="week">{% for week_monday, week_label in weeks.items %}<option value="{{ week_monday|date:'Y/m/d' }}" data-weeknum="{{ week_monday|date:"W" }}" {% if selected_week == week_monday|date:'W' %}selected{% endif %}>{{ week_label }}</option>{% endfor %}</select>
|
||||
<select name="year">{% for year in view.get_years %}<option value="{{ year }}" {% if selected_year == year %}selected{% endif %}>{{ year }}</option>{% endfor %}</select>
|
||||
<button>{% trans 'Set Date' %}</button>
|
||||
</div>
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
|
||||
<span class="buttons-group">
|
||||
<a class="active" href="{% url 'chrono-manager-agenda-day-view' pk=agenda.pk year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Day' %}</a>
|
||||
<a href="{% url 'chrono-manager-agenda-week-view' pk=agenda.pk year=view.date|date:"Y" week=view.date|date:"W" %}">{% trans 'Week' %}</a>
|
||||
<a href="{% url 'chrono-manager-agenda-month-view' pk=agenda.pk year=view.date|date:"Y" month=view.date|date:"n" %}">{% trans 'Month' %}</a>
|
||||
<a href="{% url 'chrono-manager-agenda-week-view' pk=agenda.pk year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Week' %}</a>
|
||||
<a href="{% url 'chrono-manager-agenda-month-view' pk=agenda.pk year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Month' %}</a>
|
||||
</span>
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
|
||||
<span class="buttons-group">
|
||||
<a href="{% url 'chrono-manager-agenda-day-view' pk=agenda.pk year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Day' %}</a>
|
||||
<a href="{% url 'chrono-manager-agenda-week-view' pk=agenda.pk year=view.date|date:"Y" week=view.date|date:"W" %}">{% trans 'Week' %}</a>
|
||||
<a class="active" href="{% url 'chrono-manager-agenda-month-view' pk=agenda.pk year=view.date|date:"Y" month=view.date|date:"n" %}">{% trans 'Month' %}</a>
|
||||
<a href="{% url 'chrono-manager-agenda-week-view' pk=agenda.pk year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Week' %}</a>
|
||||
<a class="active" href="{% url 'chrono-manager-agenda-month-view' pk=agenda.pk year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Month' %}</a>
|
||||
</span>
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
|
||||
<span class="buttons-group">
|
||||
<a href="{% url 'chrono-manager-agenda-day-view' pk=agenda.pk year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Day' %}</a>
|
||||
<a class="active" href="{% url 'chrono-manager-agenda-week-view' pk=agenda.pk year=view.date|date:"Y" week=view.date|date:"W" %}">{% trans 'Week' %}</a>
|
||||
<a href="{% url 'chrono-manager-agenda-month-view' pk=agenda.pk year=view.date|date:"Y" month=view.date|date:"n" %}">{% trans 'Month' %}</a>
|
||||
<a class="active" href="{% url 'chrono-manager-agenda-week-view' pk=agenda.pk year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Week' %}</a>
|
||||
<a href="{% url 'chrono-manager-agenda-month-view' pk=agenda.pk year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Month' %}</a>
|
||||
</span>
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
{{ block.super }}
|
||||
<span class="buttons-group">
|
||||
<a class="active" href="{% url 'chrono-manager-agenda-day-view' pk=agenda.id year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Day' %}</a>
|
||||
<a href="{% url 'chrono-manager-agenda-week-view' pk=agenda.id year=view.date|date:"Y" week=view.date|date:"W" %}">{% trans 'Week' %}</a>
|
||||
<a href="{% url 'chrono-manager-agenda-month-view' pk=agenda.id year=view.date|date:"Y" month=view.date|date:"n" %}">{% trans 'Month' %}</a>
|
||||
<a href="{% url 'chrono-manager-agenda-week-view' pk=agenda.id year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Week' %}</a>
|
||||
<a href="{% url 'chrono-manager-agenda-month-view' pk=agenda.id year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Month' %}</a>
|
||||
</span>
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
{{ block.super }}
|
||||
<span class="buttons-group">
|
||||
<a href="{% url 'chrono-manager-agenda-day-view' pk=agenda.id year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Day' %}</a>
|
||||
<a href="{% url 'chrono-manager-agenda-week-view' pk=agenda.id year=view.date|date:"Y" week=view.date|date:"W" %}">{% trans 'Week' %}</a>
|
||||
<a class="active" href="{% url 'chrono-manager-agenda-month-view' pk=agenda.id year=view.date|date:"Y" month=view.date|date:"n" %}">{% trans 'Month' %}</a>
|
||||
<a href="{% url 'chrono-manager-agenda-week-view' pk=agenda.id year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Week' %}</a>
|
||||
<a class="active" href="{% url 'chrono-manager-agenda-month-view' pk=agenda.id year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Month' %}</a>
|
||||
</span>
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
{% if forloop.first %}
|
||||
<th class="weeknum">
|
||||
{% if kind == 'month' %}
|
||||
<a href="{% url 'chrono-manager-agenda-week-view' pk=agenda.pk year=day.date|date:"Y" week=day.date|date:"W" %}">
|
||||
<a href="{% url 'chrono-manager-agenda-week-view' pk=agenda.pk year=day.date|date:"Y" month=day.date|date:"m" day=day.date|date:"d" %}">
|
||||
{% blocktrans with weeknum=day.date|date:"W" %}Week{{ weeknum }}{% endblocktrans %}
|
||||
</a>
|
||||
{% endif %}
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
{{ block.super }}
|
||||
<span class="buttons-group">
|
||||
<a href="{% url 'chrono-manager-agenda-day-view' pk=agenda.id year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Day' %}</a>
|
||||
<a class="active" href="{% url 'chrono-manager-agenda-week-view' pk=agenda.id year=view.date|date:"Y" week=view.date|date:"W" %}">{% trans 'Week' %}</a>
|
||||
<a href="{% url 'chrono-manager-agenda-month-view' pk=agenda.id year=view.date|date:"Y" month=view.date|date:"n" %}">{% trans 'Month' %}</a>
|
||||
<a class="active" href="{% url 'chrono-manager-agenda-week-view' pk=agenda.id year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Week' %}</a>
|
||||
<a href="{% url 'chrono-manager-agenda-month-view' pk=agenda.id year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Month' %}</a>
|
||||
</span>
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -26,9 +26,9 @@
|
|||
{% endblock %}
|
||||
{% block appbar-extras %}
|
||||
<span class="buttons-group">
|
||||
<a class="active" href="{% url 'chrono-manager-resource-day-view' pk=resource.pk year=view.date|date:"Y" month=view.date|date:"n" day=view.date|date:"d" %}">{% trans 'Day' %}</a>
|
||||
<a href="{% url 'chrono-manager-resource-week-view' pk=resource.pk year=view.date|date:"Y" week=view.date|date:"W" %}">{% trans 'Week' %}</a>
|
||||
<a href="{% url 'chrono-manager-resource-month-view' pk=resource.pk year=view.date|date:"Y" month=view.date|date:"n" %}">{% trans 'Month' %}</a>
|
||||
<a class="active" href="{% url 'chrono-manager-resource-day-view' pk=resource.pk year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Day' %}</a>
|
||||
<a href="{% url 'chrono-manager-resource-week-view' pk=resource.pk year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Week' %}</a>
|
||||
<a href="{% url 'chrono-manager-resource-month-view' pk=resource.pk year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Month' %}</a>
|
||||
</span>
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -21,11 +21,10 @@
|
|||
<a rel="popup" href="{% url 'chrono-manager-resource-delete' pk=resource.pk %}">{% trans 'Delete' %}</a>
|
||||
{% endif %}
|
||||
{% now "Y" as today_year %}
|
||||
{% now "n" as today_month %}
|
||||
{% now "W" as today_week %}
|
||||
{% now "m" as today_month %}
|
||||
{% now "j" as today_day %}
|
||||
<a href="{% url 'chrono-manager-resource-month-view' pk=resource.pk year=today_year month=today_month %}">{% trans 'Month view' %}</a>
|
||||
<a href="{% url 'chrono-manager-resource-week-view' pk=resource.pk year=today_year week=today_week %}">{% trans 'Week view' %}</a>
|
||||
<a href="{% url 'chrono-manager-resource-month-view' pk=resource.pk year=today_year month=today_month day=today_day %}">{% trans 'Month view' %}</a>
|
||||
<a href="{% url 'chrono-manager-resource-week-view' pk=resource.pk year=today_year month=today_month day=today_day %}">{% trans 'Week view' %}</a>
|
||||
<a href="{% url 'chrono-manager-resource-day-view' pk=resource.pk year=today_year month=today_month day=today_day %}">{% trans 'Day view' %}</a>
|
||||
{% endblock %}
|
||||
</span>
|
||||
|
|
|
@ -27,9 +27,9 @@
|
|||
{% endblock %}
|
||||
{% block appbar-extras %}
|
||||
<span class="buttons-group">
|
||||
<a href="{% url 'chrono-manager-resource-day-view' pk=resource.pk year=view.date|date:"Y" month=view.date|date:"n" day=view.date|date:"d" %}">{% trans 'Day' %}</a>
|
||||
<a href="{% url 'chrono-manager-resource-week-view' pk=resource.pk year=view.date|date:"Y" week=view.date|date:"W" %}">{% trans 'Week' %}</a>
|
||||
<a class="active" href="{% url 'chrono-manager-resource-month-view' pk=resource.pk year=view.date|date:"Y" month=view.date|date:"n" %}">{% trans 'Month' %}</a>
|
||||
<a href="{% url 'chrono-manager-resource-day-view' pk=resource.pk year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Day' %}</a>
|
||||
<a href="{% url 'chrono-manager-resource-week-view' pk=resource.pk year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Week' %}</a>
|
||||
<a class="active" href="{% url 'chrono-manager-resource-month-view' pk=resource.pk year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Month' %}</a>
|
||||
</span>
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
{% if forloop.first %}
|
||||
<th class="weeknum">
|
||||
{% if kind == 'month' %}
|
||||
<a href="{% url 'chrono-manager-resource-week-view' pk=resource.pk year=day.date|date:"Y" week=day.date|date:"W" %}">
|
||||
<a href="{% url 'chrono-manager-resource-week-view' pk=resource.pk year=day.date|date:"Y" month=day.date|date:"m" day=day.date|date:"d" %}">
|
||||
{% blocktrans with weeknum=day.date|date:"W" %}Week{{ weeknum }}{% endblocktrans %}
|
||||
</a>
|
||||
{% endif %}
|
||||
|
|
|
@ -10,18 +10,20 @@
|
|||
var dates = {};
|
||||
{% for year, weeks in view.get_week_dates.items %}
|
||||
dates[{{ year }}] = {};
|
||||
{% for week, weekdetails in weeks.items %}
|
||||
dates[{{ year }}][{{ week }}] = '{{ weekdetails.1 }} ({{ weekdetails.0|date:'j F' }})';
|
||||
{% for week_monday, week_label in weeks.items %}
|
||||
dates[{{ year }}]["{{ week_monday|date:'Y/m/d' }}"] = '{{ week_label }} ({{ week_monday|date:'j F' }})';
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
$('.date-picker select[name=year]').on('change', function() {
|
||||
var $week = $('.date-picker select[name="week"]');
|
||||
var selected = $week.val();
|
||||
var $selected = $(':selected', $week);
|
||||
$week.empty();
|
||||
$.each(dates[$(this).val()], function(index, value) {
|
||||
$week.append('<option value="' + index + '">' + value + '</option>');
|
||||
var index = 1;
|
||||
$.each(dates[$(this).val()], function(key, value) {
|
||||
$week.append('<option value="' + key + '" data-weeknum="' + index + '">' + value + '</option>');
|
||||
index += 1;
|
||||
});
|
||||
$week.val(selected);
|
||||
$week.val($('[data-weeknum=' + $selected.data('weeknum') + ']', $week).val());
|
||||
});
|
||||
$('.date-picker select[name=year]').change();
|
||||
});
|
||||
|
@ -30,7 +32,7 @@
|
|||
|
||||
{% block breadcrumb %}
|
||||
{{ block.super }}
|
||||
<a>{{ view.date|date:"F Y" }}</a>
|
||||
<a>{{ view.first_day|date:"F Y" }}</a>
|
||||
{% endblock %}
|
||||
|
||||
{% block appbar-title %}
|
||||
|
@ -39,11 +41,11 @@
|
|||
<a class="date-next pk-button" href="{{ view.get_next_week_url }}"><span class="sr-only">{% trans "Next week" %}</span></a>
|
||||
</span>
|
||||
<h2 class="date-nav">
|
||||
<span class="date-title">{{ view.date|date:_("Y \w\e\e\k W") }}</span>
|
||||
<span class="date-title">{{ view.first_day|date:_("Y \w\e\e\k W") }}</span>
|
||||
<button class="date-picker-opener"><span class="sr-only">{% trans "Pick a week" %}</span></button>
|
||||
{% with selected_week=view.date|date:"W" selected_year=view.date|date:"Y" %}
|
||||
{% with selected_week=view.first_day|date:"W" selected_year=view.first_day|date:"Y" weeks=view.get_week_dates|get:view.first_day.year %}
|
||||
<div class="date-picker" style="display: none">
|
||||
<select name="week">{% for week, week_label in view.get_weeks %}<option value="{{ week }}" {% if selected_week == week %}selected{% endif %}>{{ week_label }}</option>{% endfor %}</select>
|
||||
<select name="week">{% for week_monday, week_label in weeks.items %}<option value="{{ week_monday|date:'Y/m/d' }}" data-weeknum="{{ week_monday|date:"W" }}" {% if selected_week == week_monday|date:'W' %}selected{% endif %}>{{ week_label }}</option>{% endfor %}</select>
|
||||
<select name="year">{% for year in view.get_years %}<option value="{{ year }}" {% if selected_year == year %}selected{% endif %}>{{ year }}</option>{% endfor %}</select>
|
||||
<button>{% trans 'Set Date' %}</button>
|
||||
</div>
|
||||
|
@ -52,9 +54,9 @@
|
|||
{% endblock %}
|
||||
{% block appbar-extras %}
|
||||
<span class="buttons-group">
|
||||
<a href="{% url 'chrono-manager-resource-day-view' pk=resource.pk year=view.date|date:"Y" month=view.date|date:"n" day=view.date|date:"d" %}">{% trans 'Day' %}</a>
|
||||
<a class="active" href="{% url 'chrono-manager-resource-week-view' pk=resource.pk year=view.date|date:"Y" week=view.date|date:"W" %}">{% trans 'Week' %}</a>
|
||||
<a href="{% url 'chrono-manager-resource-month-view' pk=resource.pk year=view.date|date:"Y" month=view.date|date:"n" %}">{% trans 'Month' %}</a>
|
||||
<a href="{% url 'chrono-manager-resource-day-view' pk=resource.pk year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Day' %}</a>
|
||||
<a class="active" href="{% url 'chrono-manager-resource-week-view' pk=resource.pk year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Week' %}</a>
|
||||
<a href="{% url 'chrono-manager-resource-month-view' pk=resource.pk year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Month' %}</a>
|
||||
</span>
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -69,17 +69,17 @@ urlpatterns = [
|
|||
path('resource/add/', views.resource_add, name='chrono-manager-resource-add'),
|
||||
path('resource/<int:pk>/', views.resource_view, name='chrono-manager-resource-view'),
|
||||
re_path(
|
||||
r'^resource/(?P<pk>\d+)/(?P<year>[0-9]{4})/(?P<month>[0-9]+)/$',
|
||||
r'^resource/(?P<pk>\d+)/month/(?P<year>[0-9]{4})/(?P<month>[0-9]+)/(?P<day>[0-9]+)/$',
|
||||
views.resource_monthly_view,
|
||||
name='chrono-manager-resource-month-view',
|
||||
),
|
||||
re_path(
|
||||
r'^resource/(?P<pk>\d+)/(?P<year>[0-9]{4})/week/(?P<week>[0-9]+)/$',
|
||||
r'^resource/(?P<pk>\d+)/week/(?P<year>[0-9]{4})/(?P<month>[0-9]+)/(?P<day>[0-9]+)/$',
|
||||
views.resource_weekly_view,
|
||||
name='chrono-manager-resource-week-view',
|
||||
),
|
||||
re_path(
|
||||
r'^resource/(?P<pk>\d+)/(?P<year>[0-9]{4})/(?P<month>[0-9]+)/(?P<day>[0-9]+)/$',
|
||||
r'^resource/(?P<pk>\d+)/day/(?P<year>[0-9]{4})/(?P<month>[0-9]+)/(?P<day>[0-9]+)/$',
|
||||
views.resource_day_view,
|
||||
name='chrono-manager-resource-day-view',
|
||||
),
|
||||
|
@ -108,7 +108,7 @@ urlpatterns = [
|
|||
name='chrono-manager-agenda-month-redirect-view',
|
||||
),
|
||||
re_path(
|
||||
r'^agendas/(?P<pk>\d+)/(?P<year>[0-9]{4})/(?P<month>[0-9]+)/$',
|
||||
r'^agendas/(?P<pk>\d+)/month/(?P<year>[0-9]{4})/(?P<month>[0-9]+)/(?P<day>[0-9]+)/$',
|
||||
views.agenda_monthly_view,
|
||||
name='chrono-manager-agenda-month-view',
|
||||
),
|
||||
|
@ -118,7 +118,7 @@ urlpatterns = [
|
|||
name='chrono-manager-agenda-week-redirect-view',
|
||||
),
|
||||
re_path(
|
||||
r'^agendas/(?P<pk>\d+)/(?P<year>[0-9]{4})/week/(?P<week>[0-9]+)/$',
|
||||
r'^agendas/(?P<pk>\d+)/week/(?P<year>[0-9]{4})/(?P<month>[0-9]+)/(?P<day>[0-9]+)/$',
|
||||
views.agenda_weekly_view,
|
||||
name='chrono-manager-agenda-week-view',
|
||||
),
|
||||
|
@ -128,7 +128,7 @@ urlpatterns = [
|
|||
name='chrono-manager-agenda-day-redirect-view',
|
||||
),
|
||||
re_path(
|
||||
r'^agendas/(?P<pk>\d+)/(?P<year>[0-9]{4})/(?P<month>[0-9]+)/(?P<day>[0-9]+)/$',
|
||||
r'^agendas/(?P<pk>\d+)/day/(?P<year>[0-9]{4})/(?P<month>[0-9]+)/(?P<day>[0-9]+)/$',
|
||||
views.agenda_day_view,
|
||||
name='chrono-manager-agenda-day-view',
|
||||
),
|
||||
|
|
|
@ -52,14 +52,12 @@ from django.views.generic import (
|
|||
DetailView,
|
||||
FormView,
|
||||
ListView,
|
||||
MonthArchiveView,
|
||||
RedirectView,
|
||||
TemplateView,
|
||||
UpdateView,
|
||||
View,
|
||||
WeekArchiveView,
|
||||
)
|
||||
from django.views.generic.dates import MonthMixin, YearMixin
|
||||
from django.views.generic.dates import MonthMixin, WeekMixin, YearMixin
|
||||
from weasyprint import HTML
|
||||
|
||||
from chrono.agendas.management.commands.utils import send_reminder
|
||||
|
@ -259,10 +257,11 @@ class DateMixin:
|
|||
def get_week_dates(self):
|
||||
dates = {}
|
||||
for year in self.get_years():
|
||||
year = int(year)
|
||||
dates[year] = {}
|
||||
for week, week_label in self.get_weeks():
|
||||
date = datetime.datetime.strptime('%s-W%s-1' % (year, week), "%Y-W%W-%w")
|
||||
dates[year][week] = (date, week_label)
|
||||
dates[year][date] = week_label
|
||||
return dates
|
||||
|
||||
def get_years(self):
|
||||
|
@ -292,7 +291,10 @@ class ResourceDayView(DateMixin, DayArchiveView):
|
|||
)
|
||||
except ValueError: # day is out of range for month
|
||||
# redirect to last day of month
|
||||
date = datetime.date(int(self.get_year()), int(self.get_month()), 1)
|
||||
try:
|
||||
date = datetime.date(int(self.get_year()), int(self.get_month()), 1)
|
||||
except ValueError:
|
||||
raise Http404
|
||||
date += datetime.timedelta(days=40)
|
||||
date = date.replace(day=1)
|
||||
date -= datetime.timedelta(days=1)
|
||||
|
@ -335,8 +337,8 @@ class ResourceDayView(DateMixin, DayArchiveView):
|
|||
kwargs={
|
||||
'pk': self.resource.pk,
|
||||
'year': previous_day.year,
|
||||
'month': previous_day.month,
|
||||
'day': previous_day.day,
|
||||
'month': previous_day.strftime('%m'),
|
||||
'day': previous_day.strftime('%d'),
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -347,8 +349,8 @@ class ResourceDayView(DateMixin, DayArchiveView):
|
|||
kwargs={
|
||||
'pk': self.resource.pk,
|
||||
'year': next_day.year,
|
||||
'month': next_day.month,
|
||||
'day': next_day.day,
|
||||
'month': next_day.strftime('%m'),
|
||||
'day': next_day.strftime('%d'),
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -400,6 +402,26 @@ resource_day_view = ResourceDayView.as_view()
|
|||
|
||||
|
||||
class ResourceWeekMonthMixin:
|
||||
model = Event
|
||||
month_format = '%m'
|
||||
date_field = 'start_datetime'
|
||||
allow_empty = True
|
||||
allow_future = True
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
self.resource = get_object_or_404(Resource, pk=kwargs['pk'])
|
||||
if not self.resource.can_be_viewed(request.user):
|
||||
raise PermissionDenied()
|
||||
try:
|
||||
self.date = make_aware(
|
||||
datetime.datetime.strptime(
|
||||
'%s-%s-%s 06:00' % (self.get_year(), self.get_month(), self.get_day()), '%Y-%m-%d %H:%M'
|
||||
)
|
||||
)
|
||||
except ValueError:
|
||||
raise Http404
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
def get_queryset(self):
|
||||
queryset = (
|
||||
self.resource.event_set.all()
|
||||
|
@ -408,6 +430,23 @@ class ResourceWeekMonthMixin:
|
|||
)
|
||||
return queryset
|
||||
|
||||
@property
|
||||
def first_day(self):
|
||||
first_day = self.date
|
||||
if self.kind == 'month':
|
||||
first_day -= datetime.timedelta(days=first_day.day - 1)
|
||||
else:
|
||||
first_day -= datetime.timedelta(days=first_day.weekday())
|
||||
return first_day
|
||||
|
||||
def get_dated_queryset(self, **kwargs):
|
||||
# adjust min and max, incorrect as DayArchiveView is used to have Y/m/d in url
|
||||
kwargs['start_datetime__gte'] = self._make_date_lookup_arg(self.first_day)
|
||||
kwargs['start_datetime__lt'] = self._make_date_lookup_arg(
|
||||
getattr(self, 'get_next_%s' % self.kind)(self.first_day)
|
||||
)
|
||||
return super().get_dated_queryset(**kwargs)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
||||
|
@ -460,15 +499,16 @@ class ResourceWeekMonthMixin:
|
|||
|
||||
# avoid displaying empty first week
|
||||
first_week_offset = 0
|
||||
first_week_number = self.date.isocalendar()[1]
|
||||
first_week_number = self.first_day.isocalendar()[1]
|
||||
last_week_number = first_week_number
|
||||
if self.kind == 'month':
|
||||
first_week_offset = int(
|
||||
(hide_sunday and self.date.weekday() == 6) or (hide_weekend and self.date.weekday() == 5)
|
||||
(hide_sunday and self.first_day.weekday() == 6)
|
||||
or (hide_weekend and self.first_day.weekday() == 5)
|
||||
)
|
||||
if first_week_number >= 52:
|
||||
first_week_number = 0
|
||||
last_day = self.get_next(self.date.date()) - datetime.timedelta(days=1)
|
||||
last_day = self.get_next_month(self.first_day.date()) - datetime.timedelta(days=1)
|
||||
last_week_number = last_day.isocalendar()[1]
|
||||
|
||||
if last_week_number < first_week_number: # new year
|
||||
|
@ -481,13 +521,13 @@ class ResourceWeekMonthMixin:
|
|||
)
|
||||
|
||||
def get_week_timetable_infos(self, week_index, week_end_offset=0):
|
||||
date = self.date + datetime.timedelta(week_index * 7)
|
||||
date = self.first_day + datetime.timedelta(week_index * 7)
|
||||
dow = date.isocalendar()[2]
|
||||
start_date = date - datetime.timedelta(dow)
|
||||
|
||||
interval = datetime.timedelta(minutes=60)
|
||||
period = self.date.replace(hour=self.min_display.hour, minute=0)
|
||||
max_date = self.date.replace(hour=self.max_display.hour, minute=0)
|
||||
period = self.first_day.replace(hour=self.min_display.hour, minute=0)
|
||||
max_date = self.first_day.replace(hour=self.max_display.hour, minute=0)
|
||||
if self.max_display.minute != 0:
|
||||
# until the end of the last hour.
|
||||
max_date += datetime.timedelta(hours=1)
|
||||
|
@ -544,91 +584,72 @@ class ResourceWeekMonthMixin:
|
|||
return timetable
|
||||
|
||||
|
||||
class ResourceWeekView(ResourceWeekMonthMixin, DateMixin, WeekArchiveView):
|
||||
class ResourceWeekView(ResourceWeekMonthMixin, DateMixin, DayArchiveView, WeekMixin):
|
||||
template_name = 'chrono/manager_resource_week_view.html'
|
||||
model = Event
|
||||
week_format = '%W'
|
||||
date_field = 'start_datetime'
|
||||
allow_empty = True
|
||||
allow_future = True
|
||||
kind = 'week'
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
self.resource = get_object_or_404(Resource, pk=kwargs['pk'])
|
||||
if not self.resource.can_be_viewed(request.user):
|
||||
raise PermissionDenied()
|
||||
try:
|
||||
date = datetime.datetime.strptime('%s-W%s-1' % (self.get_year(), self.get_week()), "%Y-W%W-%w")
|
||||
self.date = make_aware(
|
||||
datetime.datetime.strptime(
|
||||
'%s-%s-%s 06:00' % (self.get_year(), date.month, date.day), '%Y-%m-%d %H:%M'
|
||||
)
|
||||
)
|
||||
except ValueError:
|
||||
raise Http404
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
def get_previous_week(self, date):
|
||||
return date - datetime.timedelta(days=7)
|
||||
|
||||
def get_next_week(self, date):
|
||||
return date + datetime.timedelta(days=7)
|
||||
|
||||
def get_previous_week_url(self):
|
||||
previous_week = self.get_previous_week(self.date.date())
|
||||
previous_week = self.get_previous_week(self.first_day.date())
|
||||
return reverse(
|
||||
'chrono-manager-resource-week-view',
|
||||
kwargs={'pk': self.resource.pk, 'year': previous_week.year, 'week': previous_week.strftime('%W')},
|
||||
kwargs={
|
||||
'pk': self.resource.pk,
|
||||
'year': previous_week.year,
|
||||
'month': previous_week.strftime('%m'),
|
||||
'day': previous_week.strftime('%d'),
|
||||
},
|
||||
)
|
||||
|
||||
def get_next_week_url(self):
|
||||
next_week = self.get_next_week(self.date.date())
|
||||
next_week = self.get_next_week(self.first_day.date())
|
||||
return reverse(
|
||||
'chrono-manager-resource-week-view',
|
||||
kwargs={'pk': self.resource.pk, 'year': next_week.year, 'week': next_week.strftime('%W')},
|
||||
kwargs={
|
||||
'pk': self.resource.pk,
|
||||
'year': next_week.year,
|
||||
'month': next_week.strftime('%m'),
|
||||
'day': next_week.strftime('%d'),
|
||||
},
|
||||
)
|
||||
|
||||
def get_next(self, date):
|
||||
return self.get_next_week(date)
|
||||
|
||||
|
||||
resource_weekly_view = ResourceWeekView.as_view()
|
||||
|
||||
|
||||
class ResourceMonthView(ResourceWeekMonthMixin, DateMixin, MonthArchiveView):
|
||||
class ResourceMonthView(ResourceWeekMonthMixin, DateMixin, DayArchiveView):
|
||||
template_name = 'chrono/manager_resource_month_view.html'
|
||||
model = Event
|
||||
month_format = '%m'
|
||||
date_field = 'start_datetime'
|
||||
allow_empty = True
|
||||
allow_future = True
|
||||
kind = 'month'
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
self.resource = get_object_or_404(Resource, pk=kwargs['pk'])
|
||||
if not self.resource.can_be_viewed(request.user):
|
||||
raise PermissionDenied()
|
||||
try:
|
||||
self.date = make_aware(
|
||||
datetime.datetime.strptime(
|
||||
'%s-%s-%s 06:00' % (self.get_year(), self.get_month(), 1), '%Y-%m-%d %H:%M'
|
||||
)
|
||||
)
|
||||
except ValueError:
|
||||
raise Http404
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
def get_previous_month_url(self):
|
||||
previous_month = self.get_previous_month(self.date.date())
|
||||
previous_month = self.get_previous_month(self.first_day.date())
|
||||
return reverse(
|
||||
'chrono-manager-resource-month-view',
|
||||
kwargs={'pk': self.resource.pk, 'year': previous_month.year, 'month': previous_month.month},
|
||||
kwargs={
|
||||
'pk': self.resource.pk,
|
||||
'year': previous_month.year,
|
||||
'month': previous_month.strftime('%m'),
|
||||
'day': previous_month.strftime('%d'),
|
||||
},
|
||||
)
|
||||
|
||||
def get_next_month_url(self):
|
||||
next_month = self.get_next_month(self.date.date())
|
||||
next_month = self.get_next_month(self.first_day.date())
|
||||
return reverse(
|
||||
'chrono-manager-resource-month-view',
|
||||
kwargs={'pk': self.resource.pk, 'year': next_month.year, 'month': next_month.month},
|
||||
kwargs={
|
||||
'pk': self.resource.pk,
|
||||
'year': next_month.year,
|
||||
'month': next_month.strftime('%m'),
|
||||
'day': next_month.strftime('%d'),
|
||||
},
|
||||
)
|
||||
|
||||
def get_next(self, date):
|
||||
return self.get_next_month(date)
|
||||
|
||||
|
||||
resource_monthly_view = ResourceMonthView.as_view()
|
||||
|
||||
|
@ -1189,7 +1210,13 @@ class AgendaMonthRedirectView(ViewableAgendaMixin, View):
|
|||
|
||||
def get(self, request, *args, **kwargs):
|
||||
day = self.get_day()
|
||||
return redirect('chrono-manager-agenda-month-view', pk=self.agenda.pk, year=day.year, month=day.month)
|
||||
return redirect(
|
||||
'chrono-manager-agenda-month-view',
|
||||
pk=self.agenda.pk,
|
||||
year=day.year,
|
||||
month=day.strftime('%m'),
|
||||
day=day.strftime('%d'),
|
||||
)
|
||||
|
||||
|
||||
agenda_month_redirect_view = AgendaMonthRedirectView.as_view()
|
||||
|
@ -1199,7 +1226,11 @@ class AgendaWeekRedirectView(AgendaMonthRedirectView):
|
|||
def get(self, request, *args, **kwargs):
|
||||
day = self.get_day()
|
||||
return redirect(
|
||||
'chrono-manager-agenda-week-view', pk=self.agenda.pk, year=day.year, week=day.strftime('%W')
|
||||
'chrono-manager-agenda-week-view',
|
||||
pk=self.agenda.pk,
|
||||
year=day.year,
|
||||
month=day.strftime('%m'),
|
||||
day=day.strftime('%d'),
|
||||
)
|
||||
|
||||
|
||||
|
@ -1210,7 +1241,11 @@ class AgendaDayRedirectView(AgendaMonthRedirectView):
|
|||
def get(self, request, *args, **kwargs):
|
||||
day = self.get_day()
|
||||
return redirect(
|
||||
'chrono-manager-agenda-day-view', pk=self.agenda.pk, year=day.year, month=day.month, day=day.day
|
||||
'chrono-manager-agenda-day-view',
|
||||
pk=self.agenda.pk,
|
||||
year=day.year,
|
||||
month=day.strftime('%m'),
|
||||
day=day.strftime('%d'),
|
||||
)
|
||||
|
||||
|
||||
|
@ -1220,7 +1255,6 @@ agenda_day_redirect_view = AgendaDayRedirectView.as_view()
|
|||
class AgendaDateView(DateMixin, ViewableAgendaMixin):
|
||||
model = Event
|
||||
month_format = '%m'
|
||||
week_format = '%W'
|
||||
date_field = 'start_datetime'
|
||||
allow_empty = True
|
||||
allow_future = True
|
||||
|
@ -1274,7 +1308,9 @@ class AgendaDateView(DateMixin, ViewableAgendaMixin):
|
|||
if self.agenda.kind == 'events':
|
||||
queryset = self.agenda.event_set.filter(recurrence_days__isnull=True)
|
||||
else:
|
||||
self.agenda.prefetch_desks_and_exceptions(min_date=self.date, max_date=self.get_max_date())
|
||||
self.agenda.prefetch_desks_and_exceptions(
|
||||
min_date=getattr(self, 'first_day', self.date), max_date=self.get_max_date()
|
||||
)
|
||||
if self.agenda.kind == 'meetings':
|
||||
queryset = self.agenda.event_set.select_related('meeting_type').prefetch_related(
|
||||
'booking_set'
|
||||
|
@ -1317,8 +1353,8 @@ class AgendaDayView(AgendaDateView, DayArchiveView):
|
|||
kwargs={
|
||||
'pk': self.agenda.id,
|
||||
'year': previous_day.year,
|
||||
'month': previous_day.month,
|
||||
'day': previous_day.day,
|
||||
'month': previous_day.strftime('%m'),
|
||||
'day': previous_day.strftime('%d'),
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -1329,8 +1365,8 @@ class AgendaDayView(AgendaDateView, DayArchiveView):
|
|||
kwargs={
|
||||
'pk': self.agenda.id,
|
||||
'year': next_day.year,
|
||||
'month': next_day.month,
|
||||
'day': next_day.day,
|
||||
'month': next_day.strftime('%m'),
|
||||
'day': next_day.strftime('%d'),
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -1436,13 +1472,28 @@ class AgendaWeekMonthMixin:
|
|||
return qs
|
||||
return qs.order_by('start_datetime', 'label')
|
||||
|
||||
@property
|
||||
def first_day(self):
|
||||
first_day = self.date
|
||||
if self.kind == 'month':
|
||||
first_day -= datetime.timedelta(days=first_day.day - 1)
|
||||
else:
|
||||
first_day -= datetime.timedelta(days=first_day.weekday())
|
||||
return first_day
|
||||
|
||||
def get_dated_queryset(self, **kwargs):
|
||||
# adjust min and max, incorrect as DayArchiveView is used to have Y/m/d in url
|
||||
kwargs['start_datetime__gte'] = self._make_date_lookup_arg(self.first_day)
|
||||
kwargs['start_datetime__lt'] = self._make_date_lookup_arg(
|
||||
getattr(self, 'get_next_%s' % self.kind)(self.first_day)
|
||||
)
|
||||
return super().get_dated_queryset(**kwargs)
|
||||
|
||||
def get_dated_items(self):
|
||||
date_list, object_list, extra_context = super().get_dated_items()
|
||||
if self.agenda.kind == 'events':
|
||||
min_start = make_aware(datetime.datetime.combine(extra_context[self.kind], datetime.time(0, 0)))
|
||||
max_start = make_aware(
|
||||
datetime.datetime.combine(extra_context['next_%s' % self.kind], datetime.time(0, 0))
|
||||
)
|
||||
min_start = self.first_day
|
||||
max_start = getattr(self, 'get_next_%s' % self.kind)(self.first_day)
|
||||
exceptions = TimePeriodException.objects.filter(
|
||||
desk__agenda=self.agenda, start_datetime__gte=min_start, end_datetime__lt=max_start
|
||||
).annotate(is_exception=Value(True, BooleanField()))
|
||||
|
@ -1496,16 +1547,17 @@ class AgendaWeekMonthMixin:
|
|||
|
||||
# avoid displaying empty first week
|
||||
first_week_offset = 0
|
||||
first_week_number = self.date.isocalendar()[1]
|
||||
first_week_number = self.first_day.isocalendar()[1]
|
||||
last_week_number = first_week_number
|
||||
if self.kind == 'month':
|
||||
first_week_offset = int(
|
||||
(hide_sunday and self.date.weekday() == 6) or (hide_weekend and self.date.weekday() == 5)
|
||||
(hide_sunday and self.first_day.weekday() == 6)
|
||||
or (hide_weekend and self.first_day.weekday() == 5)
|
||||
)
|
||||
first_week_number = self.date.isocalendar()[1]
|
||||
first_week_number = self.first_day.isocalendar()[1]
|
||||
if first_week_number >= 52:
|
||||
first_week_number = 0
|
||||
last_day = self.get_next(self.date.date()) - datetime.timedelta(days=1)
|
||||
last_day = self.get_next_month(self.first_day.date()) - datetime.timedelta(days=1)
|
||||
last_week_number = last_day.isocalendar()[1]
|
||||
|
||||
if last_week_number < first_week_number: # new year
|
||||
|
@ -1518,13 +1570,13 @@ class AgendaWeekMonthMixin:
|
|||
)
|
||||
|
||||
def get_week_timetable_infos(self, week_index, week_end_offset=0):
|
||||
date = self.date + datetime.timedelta(week_index * 7)
|
||||
date = self.first_day + datetime.timedelta(week_index * 7)
|
||||
dow = date.isocalendar()[2]
|
||||
start_date = date - datetime.timedelta(dow)
|
||||
|
||||
interval = datetime.timedelta(minutes=60)
|
||||
period = self.date.replace(hour=self.min_display.hour, minute=0)
|
||||
max_date = self.date.replace(hour=self.max_display.hour, minute=0)
|
||||
period = self.first_day.replace(hour=self.min_display.hour, minute=0)
|
||||
max_date = self.first_day.replace(hour=self.max_display.hour, minute=0)
|
||||
if period == max_date:
|
||||
# add at least an interval
|
||||
max_date = max_date + interval
|
||||
|
@ -1618,8 +1670,7 @@ class AgendaWeekMonthMixin:
|
|||
return timetable
|
||||
|
||||
|
||||
class AgendaWeekView(AgendaWeekMonthMixin, AgendaDateView, WeekArchiveView):
|
||||
week_format = "%W"
|
||||
class AgendaWeekView(AgendaWeekMonthMixin, AgendaDateView, DayArchiveView, WeekMixin):
|
||||
kind = 'week'
|
||||
|
||||
def get_template_names(self):
|
||||
|
@ -1627,39 +1678,44 @@ class AgendaWeekView(AgendaWeekMonthMixin, AgendaDateView, WeekArchiveView):
|
|||
return ['chrono/manager_meetings_agenda_week_view.html']
|
||||
return ['chrono/manager_%s_agenda_week_view.html' % self.agenda.kind]
|
||||
|
||||
def get_previous_week(self, date):
|
||||
return date - datetime.timedelta(days=7)
|
||||
|
||||
def get_next_week(self, date):
|
||||
return date + datetime.timedelta(days=7)
|
||||
|
||||
def get_previous_week_url(self):
|
||||
previous_week = self.get_previous_week(self.date.date())
|
||||
previous_week = self.get_previous_week(self.first_day.date())
|
||||
return reverse(
|
||||
'chrono-manager-agenda-week-view',
|
||||
kwargs={'pk': self.agenda.id, 'year': previous_week.year, 'week': previous_week.strftime('%W')},
|
||||
kwargs={
|
||||
'pk': self.agenda.id,
|
||||
'year': previous_week.year,
|
||||
'month': previous_week.strftime('%m'),
|
||||
'day': previous_week.strftime('%d'),
|
||||
},
|
||||
)
|
||||
|
||||
def get_next_week_url(self):
|
||||
next_week = self.get_next_week(self.date.date())
|
||||
next_week = self.get_next_week(self.first_day.date())
|
||||
return reverse(
|
||||
'chrono-manager-agenda-week-view',
|
||||
kwargs={'pk': self.agenda.id, 'year': next_week.year, 'week': next_week.strftime('%W')},
|
||||
kwargs={
|
||||
'pk': self.agenda.id,
|
||||
'year': next_week.year,
|
||||
'month': next_week.strftime('%m'),
|
||||
'day': next_week.strftime('%d'),
|
||||
},
|
||||
)
|
||||
|
||||
def get_next(self, date):
|
||||
return self.get_next_week(date)
|
||||
|
||||
def get_month(self):
|
||||
date = datetime.datetime.strptime('%s-W%s-1' % (self.get_year(), self.get_week()), "%Y-W%W-%w")
|
||||
return date.month
|
||||
|
||||
def get_day(self):
|
||||
date = datetime.datetime.strptime('%s-W%s-1' % (self.get_year(), self.get_week()), "%Y-W%W-%w")
|
||||
return date.day
|
||||
|
||||
def get_max_date(self):
|
||||
return self.get_next_week(self.date.date())
|
||||
return self.get_next_week(self.first_day.date())
|
||||
|
||||
|
||||
agenda_weekly_view = AgendaWeekView.as_view()
|
||||
|
||||
|
||||
class AgendaMonthView(AgendaWeekMonthMixin, AgendaDateView, MonthArchiveView):
|
||||
class AgendaMonthView(AgendaWeekMonthMixin, AgendaDateView, DayArchiveView):
|
||||
kind = 'month'
|
||||
|
||||
def get_template_names(self):
|
||||
|
@ -1668,27 +1724,31 @@ class AgendaMonthView(AgendaWeekMonthMixin, AgendaDateView, MonthArchiveView):
|
|||
return ['chrono/manager_%s_agenda_month_view.html' % self.agenda.kind]
|
||||
|
||||
def get_previous_month_url(self):
|
||||
previous_month = self.get_previous_month(self.date.date())
|
||||
previous_month = self.get_previous_month(self.first_day.date())
|
||||
return reverse(
|
||||
'chrono-manager-agenda-month-view',
|
||||
kwargs={'pk': self.agenda.id, 'year': previous_month.year, 'month': previous_month.month},
|
||||
kwargs={
|
||||
'pk': self.agenda.id,
|
||||
'year': previous_month.year,
|
||||
'month': previous_month.strftime('%m'),
|
||||
'day': previous_month.strftime('%d'),
|
||||
},
|
||||
)
|
||||
|
||||
def get_next_month_url(self):
|
||||
next_month = self.get_next_month(self.date.date())
|
||||
next_month = self.get_next_month(self.first_day.date())
|
||||
return reverse(
|
||||
'chrono-manager-agenda-month-view',
|
||||
kwargs={'pk': self.agenda.id, 'year': next_month.year, 'month': next_month.month},
|
||||
kwargs={
|
||||
'pk': self.agenda.id,
|
||||
'year': next_month.year,
|
||||
'month': next_month.strftime('%m'),
|
||||
'day': next_month.strftime('%d'),
|
||||
},
|
||||
)
|
||||
|
||||
def get_next(self, date):
|
||||
return self.get_next_month(date)
|
||||
|
||||
def get_day(self):
|
||||
return '1'
|
||||
|
||||
def get_max_date(self):
|
||||
return self.get_next_month(self.date.date())
|
||||
return self.get_next_month(self.first_day.date())
|
||||
|
||||
|
||||
agenda_monthly_view = AgendaMonthView.as_view()
|
||||
|
@ -2428,7 +2488,7 @@ class EventDeleteView(ManagedAgendaMixin, DeleteView):
|
|||
day = self.object.start_datetime
|
||||
return reverse(
|
||||
'chrono-manager-agenda-month-view',
|
||||
kwargs={'pk': self.agenda.id, 'year': day.year, 'month': day.month},
|
||||
kwargs={'pk': self.agenda.id, 'year': day.year, 'month': day.month, 'day': day.day},
|
||||
)
|
||||
|
||||
|
||||
|
@ -3374,7 +3434,7 @@ class BookingCancelView(ViewableAgendaMixin, UpdateView):
|
|||
day = event.start_datetime
|
||||
return reverse(
|
||||
'chrono-manager-agenda-month-view',
|
||||
kwargs={'pk': event.agenda.pk, 'year': day.year, 'month': day.month},
|
||||
kwargs={'pk': event.agenda.pk, 'year': day.year, 'month': day.month, 'day': day.day},
|
||||
)
|
||||
|
||||
|
||||
|
@ -3504,7 +3564,7 @@ class EventCancelView(ViewableAgendaMixin, UpdateView):
|
|||
day = self.event.start_datetime
|
||||
return reverse(
|
||||
'chrono-manager-agenda-month-view',
|
||||
kwargs={'pk': self.event.agenda.pk, 'year': day.year, 'month': day.month},
|
||||
kwargs={'pk': self.event.agenda.pk, 'year': day.year, 'month': day.month, 'day': day.day},
|
||||
)
|
||||
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -563,7 +563,9 @@ def test_booked_places(app, admin_user):
|
|||
app = login(app)
|
||||
|
||||
day = event.start_datetime
|
||||
resp = app.get('/manage/agendas/%s/%d/%d/' % (agenda.id, day.year, day.month), status=200)
|
||||
resp = app.get(
|
||||
'/manage/agendas/%s/month/%d/%d/%d/' % (agenda.id, day.year, day.month, day.day), status=200
|
||||
)
|
||||
assert '8 remaining places' in resp.text
|
||||
assert '(2/10 bookings)' in resp.text
|
||||
|
||||
|
@ -1236,7 +1238,7 @@ def test_event_cancellation_error_report(app, admin_user):
|
|||
Booking.objects.create(event=event, cancel_callback_url='http://example.org/jump/trigger/')
|
||||
|
||||
login(app)
|
||||
resp = app.get('/manage/agendas/%s/%d/%d/' % (agenda.id, day.year, day.month))
|
||||
resp = app.get('/manage/agendas/%s/month/%d/%d/%d/' % (agenda.id, day.year, day.month, day.day))
|
||||
resp = resp.click('Cancellation error reports')
|
||||
assert 'No error report' in resp.text
|
||||
|
||||
|
@ -1254,17 +1256,17 @@ def test_event_cancellation_error_report(app, admin_user):
|
|||
assert not event.cancelled and not event.cancellation_scheduled
|
||||
assert not Booking.objects.filter(cancellation_datetime__isnull=False).exists()
|
||||
|
||||
resp = app.get('/manage/agendas/%s/%d/%d/' % (agenda.id, day.year, day.month))
|
||||
resp = app.get('/manage/agendas/%s/month/%d/%d/%d/' % (agenda.id, day.year, day.month, day.day))
|
||||
assert 'Errors occured during cancellation of event "xyz".' in resp.text
|
||||
|
||||
# warning doesn't go away
|
||||
resp = app.get('/manage/agendas/%s/%d/%d/' % (agenda.id, day.year, day.month))
|
||||
resp = app.get('/manage/agendas/%s/month/%d/%d/%d/' % (agenda.id, day.year, day.month, day.day))
|
||||
assert 'Errors occured during cancellation of event "xyz".' in resp.text
|
||||
|
||||
resp = resp.click('Details')
|
||||
assert resp.text.count('unreachable') == 5
|
||||
|
||||
resp = app.get('/manage/agendas/%s/%d/%d/' % (agenda.id, day.year, day.month))
|
||||
resp = app.get('/manage/agendas/%s/month/%d/%d/%d/' % (agenda.id, day.year, day.month, day.day))
|
||||
assert 'Errors occured during cancellation of event "xyz".' not in resp.text
|
||||
|
||||
resp = resp.click('Cancellation error reports')
|
||||
|
@ -1296,7 +1298,7 @@ def test_event_cancellation_error_report_backofice_url_translation(app, admin_us
|
|||
)
|
||||
|
||||
login(app)
|
||||
resp = app.get('/manage/agendas/%s/%d/%d/' % (agenda.id, day.year, day.month))
|
||||
resp = app.get('/manage/agendas/%s/month/%d/%d/%d/' % (agenda.id, day.year, day.month, day.day))
|
||||
resp = resp.click('Cancellation error reports')
|
||||
assert 'No error report' in resp.text
|
||||
|
||||
|
@ -1314,7 +1316,7 @@ def test_event_cancellation_error_report_backofice_url_translation(app, admin_us
|
|||
assert not event.cancelled and not event.cancellation_scheduled
|
||||
assert not Booking.objects.filter(cancellation_datetime__isnull=False).exists()
|
||||
|
||||
resp = app.get('/manage/agendas/%s/%d/%d/' % (agenda.id, day.year, day.month))
|
||||
resp = app.get('/manage/agendas/%s/month/%d/%d/%d/' % (agenda.id, day.year, day.month, day.day))
|
||||
assert 'Errors occured during cancellation of event "xyz".' in resp.text
|
||||
|
||||
resp = resp.click('Cancellation error reports')
|
||||
|
@ -1354,7 +1356,7 @@ def test_event_booking_form_url(settings, app, admin_user):
|
|||
login(app)
|
||||
|
||||
assert event.get_booking_form_url() is None
|
||||
resp = app.get('/manage/agendas/%d/%d/%d/' % (agenda.pk, day.year, day.month))
|
||||
resp = app.get('/manage/agendas/%s/month/%d/%d/%d/' % (agenda.id, day.year, day.month, day.day))
|
||||
assert 'Booking form' not in resp.text
|
||||
resp = app.get('/manage/agendas/%d/events/open/' % agenda.pk)
|
||||
assert 'Booking form' not in resp.text
|
||||
|
@ -1368,13 +1370,13 @@ def test_event_booking_form_url(settings, app, admin_user):
|
|||
== 'http://demarches/backoffice/submission/inscription-aux-activites/?agenda=%s&event=%s'
|
||||
% (agenda.slug, event.slug)
|
||||
)
|
||||
resp = app.get('/manage/agendas/%d/%d/%d/' % (agenda.pk, day.year, day.month))
|
||||
resp = app.get('/manage/agendas/%s/month/%d/%d/%d/' % (agenda.id, day.year, day.month, day.day))
|
||||
assert (
|
||||
'<a class="link-action-text" href="http://demarches/backoffice/submission/inscription-aux-activites/?agenda=%s&event=%s&ReturnURL=%s">Booking form</a>'
|
||||
% (
|
||||
agenda.slug,
|
||||
event.slug,
|
||||
'http://testserver/manage/agendas/%d/%d/%d/' % (agenda.pk, day.year, day.month),
|
||||
'http://testserver/manage/agendas/%d/month/%d/%d/%d/' % (agenda.pk, day.year, day.month, day.day),
|
||||
)
|
||||
in resp.text
|
||||
)
|
||||
|
|
|
@ -1354,7 +1354,7 @@ def test_recurring_events_manage_exceptions(settings, app, admin_user, freezer):
|
|||
event.save()
|
||||
event.create_all_recurrences()
|
||||
|
||||
resp = app.get('/manage/agendas/%s/%s/%s/' % (agenda.id, 2021, 7))
|
||||
resp = app.get('/manage/agendas/%s/month/%s/%s/%s/' % (agenda.id, 2021, 7, 1))
|
||||
assert len(resp.pyquery.find('.event-info')) == 31
|
||||
|
||||
resp = app.get('/manage/agendas/%s/settings' % agenda.id)
|
||||
|
@ -1369,7 +1369,7 @@ def test_recurring_events_manage_exceptions(settings, app, admin_user, freezer):
|
|||
assert desk.timeperiodexception_set.count() == 1
|
||||
agenda.update_event_recurrences()
|
||||
|
||||
resp = app.get('/manage/agendas/%s/%s/%s/' % (agenda.id, 2021, 7))
|
||||
resp = app.get('/manage/agendas/%s/month/%s/%s/%s/' % (agenda.id, 2021, 7, 1))
|
||||
assert len(resp.pyquery.find('.event-info')) == 24
|
||||
|
||||
resp = app.get('/manage/agendas/%s/settings' % agenda.id)
|
||||
|
@ -1379,7 +1379,7 @@ def test_recurring_events_manage_exceptions(settings, app, admin_user, freezer):
|
|||
assert 'Bastille Day' in resp.text
|
||||
agenda.update_event_recurrences()
|
||||
|
||||
resp = app.get('/manage/agendas/%s/%s/%s/' % (agenda.id, 2021, 7))
|
||||
resp = app.get('/manage/agendas/%s/month/%s/%s/%s/' % (agenda.id, 2021, 7, 1))
|
||||
assert len(resp.pyquery.find('.event-info')) == 23
|
||||
|
||||
|
||||
|
@ -1397,7 +1397,7 @@ def test_recurring_events_exceptions_report(settings, app, admin_user, freezer):
|
|||
event.create_all_recurrences()
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/agendas/%s/%s/%s/' % (agenda.pk, 2021, 7))
|
||||
resp = app.get('/manage/agendas/%s/month/%s/%s/%s/' % (agenda.id, 2021, 7, 1))
|
||||
assert len(resp.pyquery.find('.event-info')) == 30
|
||||
|
||||
time_period_exception = TimePeriodException.objects.create(
|
||||
|
@ -1407,7 +1407,7 @@ def test_recurring_events_exceptions_report(settings, app, admin_user, freezer):
|
|||
)
|
||||
call_command('update_event_recurrences')
|
||||
|
||||
resp = app.get('/manage/agendas/%s/%s/%s/' % (agenda.pk, 2021, 7))
|
||||
resp = app.get('/manage/agendas/%s/month/%s/%s/%s/' % (agenda.id, 2021, 7, 1))
|
||||
assert len(resp.pyquery.find('.event-info')) == 25
|
||||
|
||||
resp = app.get('/manage/agendas/%s/settings' % agenda.id)
|
||||
|
@ -1419,7 +1419,7 @@ def test_recurring_events_exceptions_report(settings, app, admin_user, freezer):
|
|||
time_period_exception.save()
|
||||
call_command('update_event_recurrences')
|
||||
|
||||
resp = app.get('/manage/agendas/%s/%s/%s/' % (agenda.pk, 2021, 7))
|
||||
resp = app.get('/manage/agendas/%s/month/%s/%s/%s/' % (agenda.id, 2021, 7, 1))
|
||||
assert len(resp.pyquery.find('.event-info')) == 24
|
||||
|
||||
resp = app.get('/manage/agendas/%s/settings' % agenda.id)
|
||||
|
@ -1429,7 +1429,7 @@ def test_recurring_events_exceptions_report(settings, app, admin_user, freezer):
|
|||
booking.cancel()
|
||||
call_command('update_event_recurrences')
|
||||
|
||||
resp = app.get('/manage/agendas/%s/%s/%s/' % (agenda.pk, 2021, 7))
|
||||
resp = app.get('/manage/agendas/%s/month/%s/%s/%s/' % (agenda.id, 2021, 7, 1))
|
||||
assert len(resp.pyquery.find('.event-info')) == 23
|
||||
|
||||
resp = app.get('/manage/agendas/%s/settings' % agenda.id)
|
||||
|
|
|
@ -77,19 +77,19 @@ def test_resource_day_view(app, admin_user, get_proper_html_str):
|
|||
)
|
||||
|
||||
login(app)
|
||||
app.get('/manage/agendas/%s/%d/%d/%d/' % (agenda.pk, today.year, 42, today.day), status=404)
|
||||
resp = app.get('/manage/resource/%s/%d/%d/%d/' % (resource.pk, today.year, today.month, today.day))
|
||||
app.get('/manage/resource/%s/day/%d/%d/%d/' % (resource.pk, today.year, 42, today.day), status=404)
|
||||
resp = app.get('/manage/resource/%s/day/%d/%d/%d/' % (resource.pk, today.year, today.month, today.day))
|
||||
assert 'div class="booking' not in resp.text
|
||||
assert 'No bookings this day.' in resp.text
|
||||
|
||||
agenda.resources.add(resource)
|
||||
resp = app.get('/manage/resource/%s/%d/%d/%d/' % (resource.pk, today.year, today.month, today.day))
|
||||
resp = app.get('/manage/resource/%s/day/%d/%d/%d/' % (resource.pk, today.year, today.month, today.day))
|
||||
assert 'div class="booking' not in resp.text
|
||||
assert resp.text.count('<tr') == 8 # 10->18 (not included)
|
||||
|
||||
timeperiod.end_time = datetime.time(18, 30) # end during an hour
|
||||
timeperiod.save()
|
||||
resp = app.get('/manage/resource/%s/%d/%d/%d/' % (resource.pk, today.year, today.month, today.day))
|
||||
resp = app.get('/manage/resource/%s/day/%d/%d/%d/' % (resource.pk, today.year, today.month, today.day))
|
||||
assert resp.text.count('<tr') == 9 # 10->18 (included)
|
||||
|
||||
# book some slots
|
||||
|
@ -108,7 +108,9 @@ def test_resource_day_view(app, admin_user, get_proper_html_str):
|
|||
Booking.objects.create(event=event, label='foo', user_last_name="bar's")
|
||||
|
||||
with CaptureQueriesContext(connection) as ctx:
|
||||
resp = app.get('/manage/resource/%s/%d/%d/%d/' % (resource.pk, today.year, today.month, today.day))
|
||||
resp = app.get(
|
||||
'/manage/resource/%s/day/%d/%d/%d/' % (resource.pk, today.year, today.month, today.day)
|
||||
)
|
||||
assert len(ctx.captured_queries) == 7
|
||||
assert resp.text.count('div class="booking') == 2
|
||||
assert resp.pyquery.find('div.booking a').not_('.cancel')[0].text.strip() == 'booked'
|
||||
|
@ -120,7 +122,7 @@ def test_resource_day_view(app, admin_user, get_proper_html_str):
|
|||
|
||||
agenda.booking_user_block_template = '<b>{{ booking.user_name }}</b> Foo Bar'
|
||||
agenda.save()
|
||||
resp = app.get('/manage/resource/%s/%d/%d/%d/' % (resource.pk, today.year, today.month, today.day))
|
||||
resp = app.get('/manage/resource/%s/day/%d/%d/%d/' % (resource.pk, today.year, today.month, today.day))
|
||||
assert resp.pyquery.find('div.booking a').not_('.cancel')[0].text.strip() == '<b></b> Foo Bar'
|
||||
assert resp.pyquery.find('div.booking a').not_('.cancel')[1].text.strip() == "<b>bar's</b> Foo Bar"
|
||||
assert get_proper_html_str('<b>bar's</b> Foo Bar') in resp
|
||||
|
@ -128,14 +130,14 @@ def test_resource_day_view(app, admin_user, get_proper_html_str):
|
|||
# create a shorter meeting type, this will change the table CSS class
|
||||
# (and visually this will give more room for events)
|
||||
meetingtype = MeetingType.objects.create(agenda=agenda, label='Baz', duration=15)
|
||||
resp = app.get('/manage/resource/%s/%d/%d/%d/' % (resource.pk, today.year, today.month, today.day))
|
||||
resp = app.get('/manage/resource/%s/day/%d/%d/%d/' % (resource.pk, today.year, today.month, today.day))
|
||||
assert resp.text.count('div class="booking') == 2
|
||||
assert 'hourspan-4' in resp.text # table CSS class
|
||||
|
||||
# cancel a booking
|
||||
booking = Booking.objects.first()
|
||||
booking.cancel()
|
||||
resp = app.get('/manage/resource/%s/%d/%d/%d/' % (resource.pk, today.year, today.month, today.day))
|
||||
resp = app.get('/manage/resource/%s/day/%d/%d/%d/' % (resource.pk, today.year, today.month, today.day))
|
||||
assert resp.text.count('div class="booking') == 1
|
||||
|
||||
|
||||
|
@ -151,7 +153,7 @@ def test_resource_day_view_late_meeting(app, admin_user):
|
|||
)
|
||||
|
||||
login(app)
|
||||
resp = app.get('/manage/resource/%s/%d/%d/%d/' % (resource.pk, today.year, today.month, today.day))
|
||||
resp = app.get('/manage/resource/%s/day/%d/%d/%d/' % (resource.pk, today.year, today.month, today.day))
|
||||
assert resp.text.count('<tr') == 14
|
||||
assert '<th class="hour">midnight</th>' not in resp.text
|
||||
assert '<th class="hour">11 p.m.</th>' in resp.text
|
||||
|
@ -161,7 +163,7 @@ def test_resource_invalid_day_view(app, admin_user):
|
|||
resource = Resource.objects.create(label='Foo bar')
|
||||
|
||||
login(app)
|
||||
resp = app.get('/manage/resource/%s/%d/%d/%d/' % (resource.pk, 2018, 11, 31), status=302)
|
||||
resp = app.get('/manage/resource/%s/day/%d/%d/%d/' % (resource.pk, 2018, 11, 31), status=302)
|
||||
assert resp.location.endswith('2018/11/30/')
|
||||
|
||||
|
||||
|
@ -175,7 +177,7 @@ def test_resource_day_view_event_outside_timeperiod(app, admin_user):
|
|||
login(app)
|
||||
|
||||
# no time period - no events
|
||||
resp = app.get('/manage/resource/%s/%d/%d/%d/' % (resource.pk, today.year, today.month, today.day))
|
||||
resp = app.get('/manage/resource/%s/day/%d/%d/%d/' % (resource.pk, today.year, today.month, today.day))
|
||||
assert 'No bookings this day.' in resp.text
|
||||
assert 'div class="booking' not in resp.text
|
||||
|
||||
|
@ -192,12 +194,12 @@ def test_resource_day_view_event_outside_timeperiod(app, admin_user):
|
|||
Booking.objects.create(event=event)
|
||||
|
||||
# no time period - events are displayed
|
||||
resp = app.get('/manage/resource/%s/%d/%d/%d/' % (resource.pk, today.year, today.month, today.day))
|
||||
resp = app.get('/manage/resource/%s/day/%d/%d/%d/' % (resource.pk, today.year, today.month, today.day))
|
||||
assert resp.text.count('div class="booking') == 2
|
||||
|
||||
# bookings are cancelled
|
||||
Booking.objects.update(cancellation_datetime=now())
|
||||
resp = app.get('/manage/resource/%s/%d/%d/%d/' % (resource.pk, today.year, today.month, today.day))
|
||||
resp = app.get('/manage/resource/%s/day/%d/%d/%d/' % (resource.pk, today.year, today.month, today.day))
|
||||
assert 'No bookings this day.' in resp.text
|
||||
assert resp.text.count('div class="booking') == 0
|
||||
|
||||
|
@ -206,7 +208,7 @@ def test_resource_day_view_event_outside_timeperiod(app, admin_user):
|
|||
TimePeriod.objects.create(
|
||||
desk=desk, weekday=today.weekday(), start_time=datetime.time(10, 0), end_time=datetime.time(16, 0)
|
||||
)
|
||||
resp = app.get('/manage/resource/%s/%d/%d/%d/' % (resource.pk, today.year, today.month, today.day))
|
||||
resp = app.get('/manage/resource/%s/day/%d/%d/%d/' % (resource.pk, today.year, today.month, today.day))
|
||||
assert resp.text.count('div class="booking') == 2
|
||||
|
||||
|
||||
|
@ -217,7 +219,9 @@ def test_day_view_resource_as_manager(app, manager_user):
|
|||
resource = Resource.objects.create(label='Resource 1')
|
||||
app = login(app, username='manager', password='manager')
|
||||
today = datetime.date.today()
|
||||
app.get('/manage/resource/%s/%d/%d/%d/' % (resource.pk, today.year, today.month, today.day), status=403)
|
||||
app.get(
|
||||
'/manage/resource/%s/day/%d/%d/%d/' % (resource.pk, today.year, today.month, today.day), status=403
|
||||
)
|
||||
|
||||
|
||||
@freezegun.freeze_time('2020-06-15')
|
||||
|
@ -233,8 +237,8 @@ def test_resource_week_view(app, admin_user, get_proper_html_str):
|
|||
|
||||
login(app)
|
||||
today = datetime.date(2018, 11, 10) # fixed day
|
||||
app.get('/manage/resource/%s/%s/%s/' % (resource.pk, today.year, 72), status=404)
|
||||
resp = app.get('/manage/resource/%s/%s/week/%s/' % (resource.pk, today.year, today.strftime('%W')))
|
||||
app.get('/manage/resource/%s/week/%s/%s/%s/' % (resource.pk, today.year, 72, today.day), status=404)
|
||||
resp = app.get('/manage/resource/%s/week/%s/%s/%s/' % (resource.pk, today.year, today.month, today.day))
|
||||
assert '<div class="booking' not in resp.text
|
||||
assert resp.text.count('<tr') == 9
|
||||
|
||||
|
@ -255,7 +259,9 @@ def test_resource_week_view(app, admin_user, get_proper_html_str):
|
|||
|
||||
today = datetime.date.today()
|
||||
with CaptureQueriesContext(connection) as ctx:
|
||||
resp = app.get('/manage/resource/%s/%s/week/%s/' % (resource.pk, today.year, today.strftime('%W')))
|
||||
resp = app.get(
|
||||
'/manage/resource/%s/week/%s/%s/%s/' % (resource.pk, today.year, today.month, today.day)
|
||||
)
|
||||
assert len(ctx.captured_queries) == 8
|
||||
assert resp.text.count('<div class="booking" style="height:33.0%;') == 2 # booking cells
|
||||
assert resp.pyquery.find('div.booking a').not_('.cancel')[0].text.strip() == 'booked'
|
||||
|
@ -264,7 +270,7 @@ def test_resource_week_view(app, admin_user, get_proper_html_str):
|
|||
|
||||
agenda.booking_user_block_template = '<b>{{ booking.user_name }}</b> Foo Bar'
|
||||
agenda.save()
|
||||
resp = app.get('/manage/resource/%s/%s/week/%s/' % (resource.pk, today.year, today.strftime('%W')))
|
||||
resp = app.get('/manage/resource/%s/week/%s/%s/%s/' % (resource.pk, today.year, today.month, today.day))
|
||||
assert resp.pyquery.find('div.booking a').not_('.cancel')[0].text.strip() == '<b></b> Foo Bar'
|
||||
assert resp.pyquery.find('div.booking a').not_('.cancel')[1].text.strip() == "<b>bar's</b> Foo Bar"
|
||||
assert get_proper_html_str('<b>bar's</b> Foo Bar') in resp
|
||||
|
@ -274,7 +280,7 @@ def test_resource_week_view(app, admin_user, get_proper_html_str):
|
|||
booking.cancel()
|
||||
|
||||
# make sure the are not
|
||||
resp = app.get('/manage/resource/%s/%s/week/%s/' % (resource.pk, today.year, today.strftime('%W')))
|
||||
resp = app.get('/manage/resource/%s/week/%s/%s/%s/' % (resource.pk, today.year, today.month, today.day))
|
||||
assert resp.text.count('<div class="booking"') == 1
|
||||
|
||||
|
||||
|
@ -288,24 +294,24 @@ def test_resource_week_view_weekend(app, admin_user):
|
|||
TimePeriod.objects.create(
|
||||
desk=desk, weekday=monday, start_time=datetime.time(10, 0), end_time=datetime.time(18, 0)
|
||||
)
|
||||
week, year = '01', 2019
|
||||
|
||||
login(app)
|
||||
resp = app.get('/manage/resource/%s/%s/week/%s/' % (resource.pk, year, week))
|
||||
resp = app.get('/manage/resource/%s/week/%s/%s/%s/' % (resource.pk, 2019, 1, 1))
|
||||
assert 'Sunday' not in resp.text
|
||||
assert 'Saturday' not in resp.text
|
||||
# Month starts a Tuesday, but monday is displayed
|
||||
assert len(resp.pyquery.find('tbody tr:first th.weekday:empty')) == 0
|
||||
|
||||
week, year = 21, 2019 # month starts a Saturday
|
||||
resp = app.get('/manage/resource/%s/%s/week/%s/' % (resource.pk, year, week))
|
||||
resp = app.get(
|
||||
'/manage/resource/%s/week/%s/%s/%s/' % (resource.pk, 2019, 6, 1)
|
||||
) # month starts a Saturday
|
||||
assert len(resp.pyquery.find('tbody tr:first th.weekday:empty')) == 0
|
||||
|
||||
saturday = 5
|
||||
timeperiod_sat = TimePeriod.objects.create(
|
||||
desk=desk, weekday=saturday, start_time=datetime.time(10, 0), end_time=datetime.time(18, 0)
|
||||
)
|
||||
resp = app.get('/manage/resource/%s/%s/week/%s/' % (resource.pk, year, week))
|
||||
resp = app.get('/manage/resource/%s/week/%s/%s/%s/' % (resource.pk, 2019, 6, 1))
|
||||
assert 'Sunday' not in resp.text
|
||||
assert 'Saturday' in resp.text
|
||||
assert len(resp.pyquery.find('tbody tr:first th.weekday:empty')) == 0
|
||||
|
@ -314,12 +320,12 @@ def test_resource_week_view_weekend(app, admin_user):
|
|||
TimePeriod.objects.create(
|
||||
desk=desk, weekday=sunday, start_time=datetime.time(10, 0), end_time=datetime.time(18, 0)
|
||||
)
|
||||
resp = app.get('/manage/resource/%s/%s/week/%s/' % (resource.pk, year, week))
|
||||
resp = app.get('/manage/resource/%s/week/%s/%s/%s/' % (resource.pk, 2019, 6, 1))
|
||||
assert 'Sunday' in resp.text
|
||||
assert 'Saturday' in resp.text
|
||||
|
||||
timeperiod_sat.delete()
|
||||
resp = app.get('/manage/resource/%s/%s/week/%s/' % (resource.pk, year, week))
|
||||
resp = app.get('/manage/resource/%s/week/%s/%s/%s/' % (resource.pk, 2019, 6, 1))
|
||||
assert 'Sunday' in resp.text
|
||||
assert 'Saturday' in resp.text
|
||||
|
||||
|
@ -336,7 +342,7 @@ def test_resource_week_view_opening_not_even_an_hour(app, admin_user, get_proper
|
|||
|
||||
login(app)
|
||||
today = datetime.date(2018, 11, 10) # fixed day
|
||||
resp = app.get('/manage/resource/%s/%s/week/%s/' % (resource.pk, today.year, today.strftime('%W')))
|
||||
resp = app.get('/manage/resource/%s/week/%s/%s/%s/' % (resource.pk, today.year, today.month, today.day))
|
||||
assert '<div class="booking' not in resp.text
|
||||
assert resp.text.count('<tr') == 2
|
||||
|
||||
|
@ -351,7 +357,7 @@ def test_resource_week_view_opening_not_even_an_hour(app, admin_user, get_proper
|
|||
event.resources.add(resource)
|
||||
Booking.objects.create(event=event)
|
||||
|
||||
resp = app.get('/manage/resource/%s/%s/week/%s/' % (resource.pk, today.year, today.strftime('%W')))
|
||||
resp = app.get('/manage/resource/%s/week/%s/%s/%s/' % (resource.pk, today.year, today.month, today.day))
|
||||
assert resp.text.count('<div class="booking" style="height:25.0%;') == 1 # booking cell
|
||||
|
||||
|
||||
|
@ -383,7 +389,7 @@ def test_resource_week_view_dst_change(app, admin_user):
|
|||
Booking.objects.create(event=event)
|
||||
|
||||
# check booked slots are similarly aligned
|
||||
resp = app.get('/manage/resource/%s/2019/week/43/' % resource.pk)
|
||||
resp = app.get('/manage/resource/%s/week/%s/%s/%s/' % (resource.pk, 2019, 10, 2))
|
||||
assert resp.text.count('height:50.0%;top:100.0%') == 1
|
||||
|
||||
|
||||
|
@ -398,7 +404,7 @@ def test_resource_week_view_januaries(app, admin_user):
|
|||
date = datetime.date(year, 1, 1)
|
||||
with freezegun.freeze_time(date):
|
||||
login(app)
|
||||
resp = app.get('/manage/resource/%s/%s/week/01/' % (resource.pk, date.year))
|
||||
resp = app.get('/manage/resource/%s/week/%s/%s/%s/' % (resource.pk, year, 1, 1))
|
||||
assert resp.text.count('<th class="weeknum">') == 1
|
||||
|
||||
|
||||
|
@ -414,7 +420,8 @@ def test_resource_week_view_event_outside_timeperiod(app, admin_user):
|
|||
|
||||
# no time period - no events
|
||||
resp = app.get(
|
||||
'/manage/resource/%s/%d/week/%s/' % (resource.pk, middle_day.year, middle_day.strftime('%W'))
|
||||
'/manage/resource/%s/week/%s/%s/%s/'
|
||||
% (resource.pk, middle_day.year, middle_day.month, middle_day.day)
|
||||
)
|
||||
assert 'No bookings this week.' in resp.text
|
||||
assert 'div class="booking' not in resp.text
|
||||
|
@ -435,7 +442,8 @@ def test_resource_week_view_event_outside_timeperiod(app, admin_user):
|
|||
|
||||
# no time period - events are displayed
|
||||
resp = app.get(
|
||||
'/manage/resource/%s/%d/week/%s/' % (resource.pk, middle_day.year, middle_day.strftime('%W'))
|
||||
'/manage/resource/%s/week/%s/%s/%s/'
|
||||
% (resource.pk, middle_day.year, middle_day.month, middle_day.day)
|
||||
)
|
||||
assert resp.text.count('div class="booking') == 2
|
||||
|
||||
|
@ -444,7 +452,8 @@ def test_resource_week_view_event_outside_timeperiod(app, admin_user):
|
|||
desk=desk, weekday=2, start_time=datetime.time(10, 0), end_time=datetime.time(16, 0)
|
||||
)
|
||||
resp = app.get(
|
||||
'/manage/resource/%s/%d/week/%s/' % (resource.pk, middle_day.year, middle_day.strftime('%W'))
|
||||
'/manage/resource/%s/week/%s/%s/%s/'
|
||||
% (resource.pk, middle_day.year, middle_day.month, middle_day.day)
|
||||
)
|
||||
assert resp.text.count('div class="booking') == 2
|
||||
assert 'Sunday' not in resp.text
|
||||
|
@ -453,7 +462,8 @@ def test_resource_week_view_event_outside_timeperiod(app, admin_user):
|
|||
# bookings are cancelled
|
||||
Booking.objects.update(cancellation_datetime=now())
|
||||
resp = app.get(
|
||||
'/manage/resource/%s/%d/week/%s/' % (resource.pk, middle_day.year, middle_day.strftime('%W'))
|
||||
'/manage/resource/%s/week/%s/%s/%s/'
|
||||
% (resource.pk, middle_day.year, middle_day.month, middle_day.day)
|
||||
)
|
||||
assert resp.text.count('div class="booking') == 0
|
||||
|
||||
|
@ -471,7 +481,8 @@ def test_resource_week_view_event_outside_timeperiod(app, admin_user):
|
|||
event.resources.add(resource)
|
||||
Booking.objects.create(event=event)
|
||||
resp = app.get(
|
||||
'/manage/resource/%s/%d/week/%s/' % (resource.pk, middle_day.year, middle_day.strftime('%W'))
|
||||
'/manage/resource/%s/week/%s/%s/%s/'
|
||||
% (resource.pk, middle_day.year, middle_day.month, middle_day.day)
|
||||
)
|
||||
assert resp.text.count('div class="booking') == 3
|
||||
assert 'Sunday' not in resp.text
|
||||
|
@ -479,7 +490,8 @@ def test_resource_week_view_event_outside_timeperiod(app, admin_user):
|
|||
# bookings are cancelled
|
||||
Booking.objects.update(cancellation_datetime=now())
|
||||
resp = app.get(
|
||||
'/manage/resource/%s/%d/week/%s/' % (resource.pk, middle_day.year, middle_day.strftime('%W'))
|
||||
'/manage/resource/%s/week/%s/%s/%s/'
|
||||
% (resource.pk, middle_day.year, middle_day.month, middle_day.day)
|
||||
)
|
||||
assert resp.text.count('div class="booking') == 0
|
||||
# and a timeperiod
|
||||
|
@ -488,7 +500,8 @@ def test_resource_week_view_event_outside_timeperiod(app, admin_user):
|
|||
desk=desk, weekday=5, start_time=datetime.time(11, 0), end_time=datetime.time(12, 0)
|
||||
)
|
||||
resp = app.get(
|
||||
'/manage/resource/%s/%d/week/%s/' % (resource.pk, middle_day.year, middle_day.strftime('%W'))
|
||||
'/manage/resource/%s/week/%s/%s/%s/'
|
||||
% (resource.pk, middle_day.year, middle_day.month, middle_day.day)
|
||||
)
|
||||
assert resp.text.count('div class="booking') == 3
|
||||
assert 'Sunday' not in resp.text
|
||||
|
@ -507,7 +520,8 @@ def test_resource_week_view_event_outside_timeperiod(app, admin_user):
|
|||
event.resources.add(resource)
|
||||
Booking.objects.create(event=event)
|
||||
resp = app.get(
|
||||
'/manage/resource/%s/%d/week/%s/' % (resource.pk, middle_day.year, middle_day.strftime('%W'))
|
||||
'/manage/resource/%s/week/%s/%s/%s/'
|
||||
% (resource.pk, middle_day.year, middle_day.month, middle_day.day)
|
||||
)
|
||||
assert resp.text.count('div class="booking') == 4
|
||||
assert 'Sunday' in resp.text
|
||||
|
@ -515,7 +529,8 @@ def test_resource_week_view_event_outside_timeperiod(app, admin_user):
|
|||
# bookings are cancelled
|
||||
Booking.objects.update(cancellation_datetime=now())
|
||||
resp = app.get(
|
||||
'/manage/resource/%s/%d/week/%s/' % (resource.pk, middle_day.year, middle_day.strftime('%W'))
|
||||
'/manage/resource/%s/week/%s/%s/%s/'
|
||||
% (resource.pk, middle_day.year, middle_day.month, middle_day.day)
|
||||
)
|
||||
assert resp.text.count('div class="booking') == 0
|
||||
# and a timeperiod
|
||||
|
@ -524,7 +539,8 @@ def test_resource_week_view_event_outside_timeperiod(app, admin_user):
|
|||
desk=desk, weekday=6, start_time=datetime.time(11, 0), end_time=datetime.time(12, 0)
|
||||
)
|
||||
resp = app.get(
|
||||
'/manage/resource/%s/%d/week/%s/' % (resource.pk, middle_day.year, middle_day.strftime('%W'))
|
||||
'/manage/resource/%s/week/%s/%s/%s/'
|
||||
% (resource.pk, middle_day.year, middle_day.month, middle_day.day)
|
||||
)
|
||||
assert resp.text.count('div class="booking') == 4
|
||||
assert 'Sunday' in resp.text
|
||||
|
@ -538,7 +554,9 @@ def test_week_view_resource_as_manager(app, manager_user):
|
|||
resource = Resource.objects.create(label='Resource 1')
|
||||
app = login(app, username='manager', password='manager')
|
||||
today = datetime.date.today()
|
||||
app.get('/manage/resource/%s/%d/week/%s/' % (resource.pk, today.year, today.strftime('%W')), status=403)
|
||||
app.get(
|
||||
'/manage/resource/%s/week/%s/%s/%s/' % (resource.pk, today.year, today.month, today.day), status=403
|
||||
)
|
||||
|
||||
|
||||
@freezegun.freeze_time('2020-06-15')
|
||||
|
@ -554,8 +572,8 @@ def test_resource_month_view(app, admin_user, get_proper_html_str):
|
|||
|
||||
login(app)
|
||||
today = datetime.date(2018, 11, 10) # fixed day
|
||||
app.get('/manage/resource/%s/%s/%s/' % (resource.pk, today.year, 42), status=404)
|
||||
resp = app.get('/manage/resource/%s/%s/%s/' % (resource.pk, today.year, today.month))
|
||||
app.get('/manage/resource/%s/month/%s/%s/%s/' % (resource.pk, today.year, 42, today.day), status=404)
|
||||
resp = app.get('/manage/resource/%s/month/%s/%s/%s/' % (resource.pk, today.year, today.month, today.day))
|
||||
assert '<div class="booking' not in resp.text
|
||||
first_month_day = today.replace(day=1)
|
||||
last_month_day = today.replace(day=1, month=today.month + 1) - datetime.timedelta(days=1)
|
||||
|
@ -581,8 +599,10 @@ def test_resource_month_view(app, admin_user, get_proper_html_str):
|
|||
|
||||
today = datetime.date.today()
|
||||
with CaptureQueriesContext(connection) as ctx:
|
||||
resp = app.get('/manage/resource/%s/%s/%s/' % (resource.pk, today.year, today.month))
|
||||
assert len(ctx.captured_queries) == 9
|
||||
resp = app.get(
|
||||
'/manage/resource/%s/month/%s/%s/%s/' % (resource.pk, today.year, today.month, today.day)
|
||||
)
|
||||
assert len(ctx.captured_queries) == 8
|
||||
assert resp.text.count('<div class="booking" style="height:33.0%;') == 2 # booking cells
|
||||
assert resp.pyquery.find('div.booking a').not_('.cancel')[0].text.strip() == 'booked'
|
||||
assert resp.pyquery.find('div.booking a').not_('.cancel')[1].text.strip() == "foo - bar's"
|
||||
|
@ -590,7 +610,7 @@ def test_resource_month_view(app, admin_user, get_proper_html_str):
|
|||
|
||||
agenda.booking_user_block_template = '<b>{{ booking.user_name }}</b> Foo Bar'
|
||||
agenda.save()
|
||||
resp = app.get('/manage/resource/%s/%s/%s/' % (resource.pk, today.year, today.month))
|
||||
resp = app.get('/manage/resource/%s/month/%s/%s/%s/' % (resource.pk, today.year, today.month, today.day))
|
||||
assert resp.pyquery.find('div.booking a').not_('.cancel')[0].text.strip() == '<b></b> Foo Bar'
|
||||
assert resp.pyquery.find('div.booking a').not_('.cancel')[1].text.strip() == "<b>bar's</b> Foo Bar"
|
||||
assert get_proper_html_str('<b>bar's</b> Foo Bar') in resp
|
||||
|
@ -600,7 +620,7 @@ def test_resource_month_view(app, admin_user, get_proper_html_str):
|
|||
booking.cancel()
|
||||
|
||||
# make sure the are not
|
||||
resp = app.get('/manage/resource/%s/%s/%s/' % (resource.pk, today.year, today.month))
|
||||
resp = app.get('/manage/resource/%s/month/%s/%s/%s/' % (resource.pk, today.year, today.month, today.day))
|
||||
assert resp.text.count('<div class="booking"') == 1
|
||||
|
||||
|
||||
|
@ -614,29 +634,30 @@ def test_resource_month_view_weekend(app, admin_user):
|
|||
TimePeriod.objects.create(
|
||||
desk=desk, weekday=monday, start_time=datetime.time(10, 0), end_time=datetime.time(18, 0)
|
||||
)
|
||||
month, year = 1, 2019
|
||||
|
||||
login(app)
|
||||
resp = app.get('/manage/resource/%s/%s/%s/' % (resource.pk, year, month))
|
||||
resp = app.get('/manage/resource/%s/month/%s/%s/%s/' % (resource.pk, 2019, 1, 1))
|
||||
assert 'Sunday' not in resp.text
|
||||
assert 'Saturday' not in resp.text
|
||||
# No Monday on first row since month starts a Tuesday
|
||||
assert len(resp.pyquery.find('tbody tr:first th.weekday:empty')) == 1
|
||||
|
||||
# When weekend is hidden, do not display an empty first week
|
||||
month, year = 12, 2019 # month starts a Sunday
|
||||
resp = app.get('/manage/resource/%s/%s/%s/' % (resource.pk, year, month))
|
||||
resp = app.get(
|
||||
'/manage/resource/%s/month/%s/%s/%s/' % (resource.pk, 2019, 12, 1)
|
||||
) # month starts a Sunday
|
||||
assert len(resp.pyquery.find('tbody tr:first th.weekday:empty')) == 0
|
||||
|
||||
month, year = 6, 2019 # month starts a Saturday
|
||||
resp = app.get('/manage/resource/%s/%s/%s/' % (resource.pk, year, month))
|
||||
resp = app.get(
|
||||
'/manage/resource/%s/month/%s/%s/%s/' % (resource.pk, 2019, 6, 1)
|
||||
) # month starts a Saturday
|
||||
assert len(resp.pyquery.find('tbody tr:first th.weekday:empty')) == 0
|
||||
|
||||
saturday = 5
|
||||
timeperiod_sat = TimePeriod.objects.create(
|
||||
desk=desk, weekday=saturday, start_time=datetime.time(10, 0), end_time=datetime.time(18, 0)
|
||||
)
|
||||
resp = app.get('/manage/resource/%s/%s/%s/' % (resource.pk, year, month))
|
||||
resp = app.get('/manage/resource/%s/month/%s/%s/%s/' % (resource.pk, 2019, 6, 1))
|
||||
assert 'Sunday' not in resp.text
|
||||
assert 'Saturday' in resp.text
|
||||
assert len(resp.pyquery.find('tbody tr:first th.weekday:empty')) == 5
|
||||
|
@ -645,12 +666,12 @@ def test_resource_month_view_weekend(app, admin_user):
|
|||
TimePeriod.objects.create(
|
||||
desk=desk, weekday=sunday, start_time=datetime.time(10, 0), end_time=datetime.time(18, 0)
|
||||
)
|
||||
resp = app.get('/manage/resource/%s/%s/%s/' % (resource.pk, year, month))
|
||||
resp = app.get('/manage/resource/%s/month/%s/%s/%s/' % (resource.pk, 2019, 6, 1))
|
||||
assert 'Sunday' in resp.text
|
||||
assert 'Saturday' in resp.text
|
||||
|
||||
timeperiod_sat.delete()
|
||||
resp = app.get('/manage/resource/%s/%s/%s/' % (resource.pk, year, month))
|
||||
resp = app.get('/manage/resource/%s/month/%s/%s/%s/' % (resource.pk, 2019, 6, 1))
|
||||
assert 'Sunday' in resp.text
|
||||
assert 'Saturday' in resp.text
|
||||
|
||||
|
@ -683,7 +704,7 @@ def test_resource_month_view_dst_change(app, admin_user):
|
|||
Booking.objects.create(event=event)
|
||||
|
||||
# check booked slots are similarly aligned
|
||||
resp = app.get('/manage/resource/%s/2019/10/' % resource.pk)
|
||||
resp = app.get('/manage/resource/%s/month/%s/%s/%s/' % (resource.pk, 2019, 10, 1))
|
||||
assert resp.text.count('height:50.0%;top:100.0%') == 2
|
||||
|
||||
|
||||
|
@ -698,7 +719,7 @@ def test_resource_month_view_januaries(app, admin_user):
|
|||
date = datetime.date(year, 1, 1)
|
||||
with freezegun.freeze_time(date):
|
||||
login(app)
|
||||
resp = app.get('/manage/resource/%s/%s/1/' % (resource.pk, date.year))
|
||||
resp = app.get('/manage/resource/%s/month/%s/%s/%s/' % (resource.pk, year, 1, 1))
|
||||
assert resp.text.count('<th class="weeknum">') in (4, 5)
|
||||
|
||||
|
||||
|
@ -712,7 +733,7 @@ def test_resource_month_view_event_outside_timeperiod(app, admin_user):
|
|||
login(app)
|
||||
|
||||
# no time period - no events
|
||||
resp = app.get('/manage/resource/%s/%d/%d/' % (resource.pk, today.year, today.month))
|
||||
resp = app.get('/manage/resource/%s/month/%s/%s/%s/' % (resource.pk, today.year, today.month, today.day))
|
||||
assert 'No bookings this month.' in resp.text
|
||||
assert 'div class="booking' not in resp.text
|
||||
|
||||
|
@ -732,21 +753,21 @@ def test_resource_month_view_event_outside_timeperiod(app, admin_user):
|
|||
Booking.objects.create(event=event)
|
||||
|
||||
# no time period - events are displayed
|
||||
resp = app.get('/manage/resource/%s/%d/%d/' % (resource.pk, today.year, today.month))
|
||||
resp = app.get('/manage/resource/%s/month/%s/%s/%s/' % (resource.pk, today.year, today.month, today.day))
|
||||
assert resp.text.count('div class="booking') == 2
|
||||
|
||||
# events outside time period
|
||||
TimePeriod.objects.create(
|
||||
desk=desk, weekday=2, start_time=datetime.time(10, 0), end_time=datetime.time(16, 0)
|
||||
)
|
||||
resp = app.get('/manage/resource/%s/%d/%d/' % (resource.pk, today.year, today.month))
|
||||
resp = app.get('/manage/resource/%s/month/%s/%s/%s/' % (resource.pk, today.year, today.month, today.day))
|
||||
assert resp.text.count('div class="booking') == 2
|
||||
assert 'Sunday' not in resp.text
|
||||
assert 'Saturday' not in resp.text
|
||||
|
||||
# bookings are cancelled
|
||||
Booking.objects.update(cancellation_datetime=now())
|
||||
resp = app.get('/manage/resource/%s/%d/%d/' % (resource.pk, today.year, today.month))
|
||||
resp = app.get('/manage/resource/%s/month/%s/%s/%s/' % (resource.pk, today.year, today.month, today.day))
|
||||
assert resp.text.count('div class="booking') == 0
|
||||
|
||||
# create an event on saturday
|
||||
|
@ -762,20 +783,20 @@ def test_resource_month_view_event_outside_timeperiod(app, admin_user):
|
|||
)
|
||||
event.resources.add(resource)
|
||||
Booking.objects.create(event=event)
|
||||
resp = app.get('/manage/resource/%s/%d/%d/' % (resource.pk, today.year, today.month))
|
||||
resp = app.get('/manage/resource/%s/month/%s/%s/%s/' % (resource.pk, today.year, today.month, today.day))
|
||||
assert resp.text.count('div class="booking') == 3
|
||||
assert 'Sunday' not in resp.text
|
||||
assert 'Saturday' in resp.text
|
||||
# bookings are cancelled
|
||||
Booking.objects.update(cancellation_datetime=now())
|
||||
resp = app.get('/manage/resource/%s/%d/%d/' % (resource.pk, today.year, today.month))
|
||||
resp = app.get('/manage/resource/%s/month/%s/%s/%s/' % (resource.pk, today.year, today.month, today.day))
|
||||
assert resp.text.count('div class="booking') == 0
|
||||
# and a timeperiod
|
||||
Booking.objects.update(cancellation_datetime=None) # reset
|
||||
TimePeriod.objects.create(
|
||||
desk=desk, weekday=5, start_time=datetime.time(11, 0), end_time=datetime.time(12, 0)
|
||||
)
|
||||
resp = app.get('/manage/resource/%s/%d/%d/' % (resource.pk, today.year, today.month))
|
||||
resp = app.get('/manage/resource/%s/month/%s/%s/%s/' % (resource.pk, today.year, today.month, today.day))
|
||||
assert resp.text.count('div class="booking') == 3
|
||||
assert 'Sunday' not in resp.text
|
||||
assert 'Saturday' in resp.text
|
||||
|
@ -793,20 +814,20 @@ def test_resource_month_view_event_outside_timeperiod(app, admin_user):
|
|||
)
|
||||
event.resources.add(resource)
|
||||
Booking.objects.create(event=event)
|
||||
resp = app.get('/manage/resource/%s/%d/%d/' % (resource.pk, today.year, today.month))
|
||||
resp = app.get('/manage/resource/%s/month/%s/%s/%s/' % (resource.pk, today.year, today.month, today.day))
|
||||
assert resp.text.count('div class="booking') == 4
|
||||
assert 'Sunday' in resp.text
|
||||
assert 'Saturday' in resp.text
|
||||
# bookings are cancelled
|
||||
Booking.objects.update(cancellation_datetime=now())
|
||||
resp = app.get('/manage/resource/%s/%d/%d/' % (resource.pk, today.year, today.month))
|
||||
resp = app.get('/manage/resource/%s/month/%s/%s/%s/' % (resource.pk, today.year, today.month, today.day))
|
||||
assert resp.text.count('div class="booking') == 0
|
||||
# and a timeperiod
|
||||
Booking.objects.update(cancellation_datetime=None) # reset
|
||||
TimePeriod.objects.create(
|
||||
desk=desk, weekday=6, start_time=datetime.time(11, 0), end_time=datetime.time(12, 0)
|
||||
)
|
||||
resp = app.get('/manage/resource/%s/%d/%d/' % (resource.pk, today.year, today.month))
|
||||
resp = app.get('/manage/resource/%s/month/%s/%s/%s/' % (resource.pk, today.year, today.month, today.day))
|
||||
assert resp.text.count('div class="booking') == 4
|
||||
assert 'Sunday' in resp.text
|
||||
assert 'Saturday' in resp.text
|
||||
|
@ -819,7 +840,9 @@ def test_month_view_resource_as_manager(app, manager_user):
|
|||
resource = Resource.objects.create(label='Resource 1')
|
||||
app = login(app, username='manager', password='manager')
|
||||
today = datetime.date.today()
|
||||
app.get('/manage/resource/%s/%d/%d/' % (resource.pk, today.year, today.month), status=403)
|
||||
app.get(
|
||||
'/manage/resource/%s/month/%s/%s/%s/' % (resource.pk, today.year, today.month, today.day), status=403
|
||||
)
|
||||
|
||||
|
||||
def test_edit_resource(app, admin_user):
|
||||
|
@ -913,8 +936,8 @@ def test_meetings_agenda_resources(app, admin_user):
|
|||
@pytest.mark.parametrize(
|
||||
'view',
|
||||
(
|
||||
'/manage/resource/%(resource)s/%(year)d/%(month)d/%(day)d/',
|
||||
'/manage/resource/%(resource)s/%(year)d/%(month)d/',
|
||||
'/manage/resource/%(resource)s/day/%(year)d/%(month)d/%(day)d/',
|
||||
'/manage/resource/%(resource)s/month/%(year)d/%(month)d/%(day)d/',
|
||||
),
|
||||
)
|
||||
def test_agenda_day_month_view_backoffice_url_translation(
|
||||
|
|
Loading…
Reference in New Issue