pricing: change agenda pricing urls, add list view (#67196)
This commit is contained in:
parent
4cf25a1bca
commit
6998f1e9e5
|
@ -132,10 +132,7 @@ class AgendaPricingForm(forms.ModelForm):
|
|||
super().__init__(*args, **kwargs)
|
||||
if not self.instance.pk:
|
||||
last_date_end = (
|
||||
AgendaPricing.objects.filter(agenda=self.instance.agenda)
|
||||
.order_by('date_end')
|
||||
.values_list('date_end', flat=True)
|
||||
.last()
|
||||
AgendaPricing.objects.all().order_by('date_end').values_list('date_end', flat=True).last()
|
||||
)
|
||||
self.initial['date_start'] = last_date_end or now().date()
|
||||
|
||||
|
@ -145,15 +142,6 @@ class AgendaPricingForm(forms.ModelForm):
|
|||
if 'date_start' in cleaned_data and 'date_end' in cleaned_data:
|
||||
if cleaned_data['date_end'] <= cleaned_data['date_start']:
|
||||
self.add_error('date_end', _('End date must be greater than start date.'))
|
||||
else:
|
||||
overlapping_qs = AgendaPricing.objects.filter(agenda=self.instance.agenda,).extra(
|
||||
where=["(date_start, date_end) OVERLAPS (%s, %s)"],
|
||||
params=[cleaned_data['date_start'], cleaned_data['date_end']],
|
||||
)
|
||||
if self.instance.pk:
|
||||
overlapping_qs = overlapping_qs.exclude(pk=self.instance.pk)
|
||||
if overlapping_qs.exists():
|
||||
raise forms.ValidationError(_('Pricing overlaps existing pricings.'))
|
||||
|
||||
return cleaned_data
|
||||
|
||||
|
@ -175,17 +163,21 @@ class PricingTestToolForm(forms.Form):
|
|||
def __init__(self, *args, **kwargs):
|
||||
self.request = kwargs.pop('request')
|
||||
self.agenda_pricing = kwargs.pop('agenda_pricing')
|
||||
self.agenda = self.agenda_pricing.agenda
|
||||
self.agenda = self.agenda_pricing.agendas.first()
|
||||
self.serialized_event = None
|
||||
self.serialized_subscription = None
|
||||
self.check_type_slug = None
|
||||
self.booking_status = None
|
||||
super().__init__(*args, **kwargs)
|
||||
presence_check_types = (
|
||||
self.agenda.check_type_group.check_types.presences() if self.agenda.check_type_group else []
|
||||
self.agenda.check_type_group.check_types.presences()
|
||||
if self.agenda and self.agenda.check_type_group
|
||||
else []
|
||||
)
|
||||
absence_check_types = (
|
||||
self.agenda.check_type_group.check_types.absences() if self.agenda.check_type_group else []
|
||||
self.agenda.check_type_group.check_types.absences()
|
||||
if self.agenda and self.agenda.check_type_group
|
||||
else []
|
||||
)
|
||||
status_choices = [
|
||||
('presence', _('Presence')),
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
<span class="actions">
|
||||
{% with chrono_url=object.get_chrono_url %}{% if chrono_url %}<a href="{{ chrono_url }}">{% trans "Agenda options" %}</a>{% endif %}{% endwith %}
|
||||
<a href="{% url 'lingo-manager-agenda-export' pk=agenda.pk %}">{% trans 'Export' %}</a>
|
||||
<a rel="popup" href="{% url 'lingo-manager-agenda-pricing-add' pk=agenda.pk %}">{% trans 'New pricing' %}</a>
|
||||
</span>
|
||||
{% endblock %}
|
||||
|
||||
|
@ -25,7 +24,7 @@
|
|||
<ul class="objects-list single-links">
|
||||
{% for agenda_pricing in agenda_pricings %}
|
||||
<li>
|
||||
<a href="{% url 'lingo-manager-agenda-pricing-detail' agenda.pk agenda_pricing.pk %}">{{ agenda_pricing.pricing }} ({{ agenda_pricing.date_start|date:'d/m/Y' }} - {{ agenda_pricing.date_end|date:'d/m/Y' }})</a>
|
||||
<a href="{% url 'lingo-manager-agenda-pricing-detail' agenda_pricing.pk %}">{{ agenda_pricing.pricing }} ({{ agenda_pricing.date_start|date:'d/m/Y' }} - {{ agenda_pricing.date_end|date:'d/m/Y' }})</a>
|
||||
<a href="{% url 'lingo-manager-pricing-detail' agenda_pricing.pricing.pk %}" class="link-action-icon link">{% trans "see" %}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
@ -33,8 +32,7 @@
|
|||
{% else %}
|
||||
<div class="big-msg-info">
|
||||
{% blocktrans %}
|
||||
This agenda doesn't have any pricing defined yet. Click on the "New pricing" button in
|
||||
the top right of the page to add a first one.
|
||||
This agenda doesn't have any pricing defined yet.
|
||||
{% endblocktrans %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
{% extends "lingo/pricing/manager_agenda_detail.html" %}
|
||||
{% extends "lingo/pricing/manager_agenda_pricing_list.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
{{ block.super }}
|
||||
<a href="{% url 'lingo-manager-agenda-pricing-detail' agenda.pk object.pk %}">{{ object.pricing }}</a>
|
||||
<a href="{% url 'lingo-manager-agenda-pricing-detail' object.pk %}">{{ object.pricing }}</a>
|
||||
{% endblock %}
|
||||
|
||||
{% block appbar %}
|
||||
|
@ -13,8 +13,8 @@
|
|||
<span class="actions">
|
||||
<a class="extra-actions-menu-opener"></a>
|
||||
<ul class="extra-actions-menu">
|
||||
<li><a rel="popup" href="{% url 'lingo-manager-agenda-pricing-edit' agenda.pk object.pk %}">{% trans 'Options' %}</a></li>
|
||||
<li><a rel="popup" href="{% url 'lingo-manager-agenda-pricing-delete' agenda.pk object.pk %}">{% trans 'Delete' %}</a></li>
|
||||
<li><a rel="popup" href="{% url 'lingo-manager-agenda-pricing-edit' object.pk %}">{% trans 'Options' %}</a></li>
|
||||
<li><a rel="popup" href="{% url 'lingo-manager-agenda-pricing-delete' object.pk %}">{% trans 'Delete' %}</a></li>
|
||||
</ul>
|
||||
</span>
|
||||
{% endblock %}
|
||||
|
@ -66,7 +66,7 @@
|
|||
</tbody>
|
||||
</table>
|
||||
<p>
|
||||
<a class="pk-button" href="{% if matrix.criteria %}{% url 'lingo-manager-agenda-pricing-matrix-slug-edit' agenda.pk object.pk matrix.criteria.slug %}{% else %}{% url 'lingo-manager-agenda-pricing-matrix-edit' agenda.pk object.pk %}{% endif %}">{% trans "Edit pricing" %}</a>
|
||||
<a class="pk-button" href="{% if matrix.criteria %}{% url 'lingo-manager-agenda-pricing-matrix-slug-edit' object.pk matrix.criteria.slug %}{% else %}{% url 'lingo-manager-agenda-pricing-matrix-edit' object.pk %}{% endif %}">{% trans "Edit pricing" %}</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
{% extends "lingo/pricing/manager_agenda_detail.html" %}
|
||||
{% extends "lingo/pricing/manager_agenda_pricing_list.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
{{ block.super }}
|
||||
{% if form.instance.pk %}
|
||||
<a href="{% url 'lingo-manager-agenda-pricing-detail' agenda.pk object.pk %}">{{ object.pricing }}</a>
|
||||
<a href="{% url 'lingo-manager-agenda-pricing-edit' agenda.pk object.pk %}">{% trans "Edit" %}</a>
|
||||
<a href="{% url 'lingo-manager-agenda-pricing-detail' object.pk %}">{{ object.pricing }}</a>
|
||||
<a href="{% url 'lingo-manager-agenda-pricing-edit' object.pk %}">{% trans "Edit" %}</a>
|
||||
{% else %}
|
||||
<a href="{% url 'lingo-manager-agenda-pricing-add' agenda.pk %}">{% trans "New pricing" %}</a>
|
||||
<a href="{% url 'lingo-manager-agenda-pricing-add' %}">{% trans "New pricing" %}</a>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
|
@ -26,9 +26,9 @@
|
|||
<div class="buttons">
|
||||
<button class="submit-button">{% trans "Save" %}</button>
|
||||
{% if object.pk %}
|
||||
<a class="cancel" href="{% url 'lingo-manager-agenda-pricing-detail' agenda.pk object.pk %}">{% trans 'Cancel' %}</a>
|
||||
<a class="cancel" href="{% url 'lingo-manager-agenda-pricing-detail' object.pk %}">{% trans 'Cancel' %}</a>
|
||||
{% else %}
|
||||
<a class="cancel" href="{% url 'lingo-manager-agenda-detail' agenda.pk %}">{% trans 'Cancel' %}</a>
|
||||
<a class="cancel" href="{% url 'lingo-manager-agenda-pricing-list' %}">{% trans 'Cancel' %}</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
{% extends "lingo/pricing/manager_home.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
{{ block.super }}
|
||||
<a href="{% url 'lingo-manager-agenda-pricing-list' %}">{% trans "Pricings" context 'agenda pricing' %}</a>
|
||||
{% endblock %}
|
||||
|
||||
{% block appbar %}
|
||||
<h2>{% trans 'Pricings' context 'agenda pricing' %}</h2>
|
||||
<span class="actions">
|
||||
<a rel="popup" href="{% url 'lingo-manager-agenda-pricing-add' %}">{% trans 'New pricing' %}</a>
|
||||
</span>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="pk-information">
|
||||
<p>{% trans "Define here pricings to attach to events agendas." %}</p>
|
||||
</div>
|
||||
{% if object_list %}
|
||||
<div>
|
||||
<ul class="objects-list single-links">
|
||||
{% for object in object_list %}
|
||||
<li>
|
||||
<a href="{% url 'lingo-manager-agenda-pricing-detail' pk=object.pk %}">{{ object.pricing }} ({{ object.date_start|date:'d/m/Y' }} - {{ object.date_end|date:'d/m/Y' }})</a>
|
||||
<a href="{% url 'lingo-manager-pricing-detail' object.pricing.pk %}" class="link-action-icon link">{% trans "see" %}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="big-msg-info">
|
||||
{% blocktrans %}
|
||||
This site doesn't have any pricing yet. Click on the "New pricing" button in the top
|
||||
right of the page to add a first one.
|
||||
{% endblocktrans %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
|
@ -4,9 +4,9 @@
|
|||
{% block breadcrumb %}
|
||||
{{ block.super }}
|
||||
{% if matrix.criteria %}
|
||||
<a href="{% url 'lingo-manager-agenda-pricing-matrix-slug-edit' agenda.pk object.pk matrix.criteria.slug %}">{% trans "Edit pricing" %}</a>
|
||||
<a href="{% url 'lingo-manager-agenda-pricing-matrix-slug-edit' object.pk matrix.criteria.slug %}">{% trans "Edit pricing" %}</a>
|
||||
{% else %}
|
||||
<a href="{% url 'lingo-manager-agenda-pricing-matrix-edit' agenda.pk object.pk %}">{% trans "Edit pricing" %}</a>
|
||||
<a href="{% url 'lingo-manager-agenda-pricing-matrix-edit' object.pk %}">{% trans "Edit pricing" %}</a>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
|
@ -50,7 +50,7 @@
|
|||
</table>
|
||||
<div class="buttons">
|
||||
<button class="submit-button">{% trans "Save" %}</button>
|
||||
<a class="cancel" href="{% url 'lingo-manager-agenda-pricing-detail' agenda.pk object.pk %}">{% trans 'Cancel' %}</a>
|
||||
<a class="cancel" href="{% url 'lingo-manager-agenda-pricing-detail' object.pk %}">{% trans 'Cancel' %}</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
{% trans "Criterias" %}
|
||||
<p>{% trans "Define criterias to describe a pricing model." %}</p>
|
||||
</a>
|
||||
<a class="button button-paragraph" href="">
|
||||
<a class="button button-paragraph" href="{% url 'lingo-manager-agenda-pricing-list' %}">
|
||||
{% trans "Pricings" context 'agenda pricing' %}
|
||||
<p>{% trans "Pricing attached to events agendas." %}</p>
|
||||
</a>
|
||||
|
|
|
@ -154,32 +154,37 @@ urlpatterns = [
|
|||
name='lingo-manager-agenda-booking-check-settings',
|
||||
),
|
||||
url(
|
||||
r'^agenda/(?P<pk>\d+)/pricing/add/$',
|
||||
r'^agenda-pricings/$',
|
||||
views.agenda_pricing_list,
|
||||
name='lingo-manager-agenda-pricing-list',
|
||||
),
|
||||
url(
|
||||
r'^agenda-pricing/add/$',
|
||||
views.agenda_pricing_add,
|
||||
name='lingo-manager-agenda-pricing-add',
|
||||
),
|
||||
url(
|
||||
r'^agenda/(?P<pk>\d+)/pricing/(?P<pricing_pk>\d+)/$',
|
||||
r'^agenda-pricing/(?P<pk>\d+)/$',
|
||||
views.agenda_pricing_detail,
|
||||
name='lingo-manager-agenda-pricing-detail',
|
||||
),
|
||||
url(
|
||||
r'^agenda/(?P<pk>\d+)/pricing/(?P<pricing_pk>\d+)/edit/$',
|
||||
r'^agenda-pricing/(?P<pk>\d+)/edit/$',
|
||||
views.agenda_pricing_edit,
|
||||
name='lingo-manager-agenda-pricing-edit',
|
||||
),
|
||||
url(
|
||||
r'^agenda/(?P<pk>\d+)/pricing/(?P<pricing_pk>\d+)/delete/$',
|
||||
r'^agenda-pricing/(?P<pk>\d+)/delete/$',
|
||||
views.agenda_pricing_delete,
|
||||
name='lingo-manager-agenda-pricing-delete',
|
||||
),
|
||||
url(
|
||||
r'^agenda/(?P<pk>\d+)/pricing/(?P<pricing_pk>\d+)/matrix/edit/$',
|
||||
r'^agenda-pricing/(?P<pk>\d+)/matrix/edit/$',
|
||||
views.agenda_pricing_matrix_edit,
|
||||
name='lingo-manager-agenda-pricing-matrix-edit',
|
||||
),
|
||||
url(
|
||||
r'^agenda/(?P<pk>\d+)/pricing/(?P<pricing_pk>\d+)/matrix/(?P<slug>[-_a-zA-Z0-9]+)/edit/$',
|
||||
r'^agenda-pricing/(?P<pk>\d+)/matrix/(?P<slug>[-_a-zA-Z0-9]+)/edit/$',
|
||||
views.agenda_pricing_matrix_edit,
|
||||
name='lingo-manager-agenda-pricing-matrix-slug-edit',
|
||||
),
|
||||
|
|
|
@ -669,7 +669,7 @@ class AgendaDetailView(AgendaMixin, DetailView):
|
|||
|
||||
def get_context_data(self, **kwargs):
|
||||
kwargs['agenda_pricings'] = (
|
||||
AgendaPricing.objects.filter(agenda=self.agenda)
|
||||
AgendaPricing.objects.filter(agendas=self.agenda)
|
||||
.select_related('pricing')
|
||||
.order_by('date_start', 'date_end')
|
||||
)
|
||||
|
@ -719,27 +719,35 @@ class AgendaBookingCheckSettingsView(AgendaMixin, UpdateView):
|
|||
agenda_booking_check_settings = AgendaBookingCheckSettingsView.as_view()
|
||||
|
||||
|
||||
class AgendaPricingAddView(AgendaMixin, CreateView):
|
||||
class AgendaPricingListView(ListView):
|
||||
template_name = 'lingo/pricing/manager_agenda_pricing_list.html'
|
||||
model = AgendaPricing
|
||||
|
||||
def get_queryset(self):
|
||||
return AgendaPricing.objects.all().select_related('pricing').order_by('date_start', 'date_end')
|
||||
|
||||
|
||||
agenda_pricing_list = AgendaPricingListView.as_view()
|
||||
|
||||
|
||||
class AgendaPricingAddView(CreateView):
|
||||
template_name = 'lingo/pricing/manager_agenda_pricing_form.html'
|
||||
model = AgendaPricing
|
||||
form_class = AgendaPricingForm
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse('lingo-manager-agenda-pricing-detail', args=[self.agenda.pk, self.object.pk])
|
||||
return reverse('lingo-manager-agenda-pricing-detail', args=[self.object.pk])
|
||||
|
||||
|
||||
agenda_pricing_add = AgendaPricingAddView.as_view()
|
||||
|
||||
|
||||
class AgendaPricingDetailView(AgendaMixin, DetailView):
|
||||
class AgendaPricingDetailView(DetailView):
|
||||
model = AgendaPricing
|
||||
pk_url_kwarg = 'pricing_pk'
|
||||
template_name = 'lingo/pricing/manager_agenda_pricing_detail.html'
|
||||
|
||||
def get_queryset(self):
|
||||
return AgendaPricing.objects.filter(agenda=self.agenda).prefetch_related(
|
||||
'pricing__criterias__category'
|
||||
)
|
||||
return AgendaPricing.objects.all().prefetch_related('pricing__criterias__category')
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
form = PricingTestToolForm(
|
||||
|
@ -754,42 +762,34 @@ class AgendaPricingDetailView(AgendaMixin, DetailView):
|
|||
agenda_pricing_detail = AgendaPricingDetailView.as_view()
|
||||
|
||||
|
||||
class AgendaPricingEditView(AgendaMixin, UpdateView):
|
||||
class AgendaPricingEditView(UpdateView):
|
||||
template_name = 'lingo/pricing/manager_agenda_pricing_form.html'
|
||||
model = AgendaPricing
|
||||
pk_url_kwarg = 'pricing_pk'
|
||||
form_class = AgendaPricingForm
|
||||
|
||||
def get_queryset(self):
|
||||
return AgendaPricing.objects.filter(agenda=self.agenda)
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse('lingo-manager-agenda-pricing-detail', args=[self.agenda.pk, self.object.pk])
|
||||
return reverse('lingo-manager-agenda-pricing-detail', args=[self.object.pk])
|
||||
|
||||
|
||||
agenda_pricing_edit = AgendaPricingEditView.as_view()
|
||||
|
||||
|
||||
class AgendaPricingDeleteView(AgendaMixin, DeleteView):
|
||||
class AgendaPricingDeleteView(DeleteView):
|
||||
template_name = 'lingo/manager_confirm_delete.html'
|
||||
model = AgendaPricing
|
||||
pk_url_kwarg = 'pricing_pk'
|
||||
|
||||
def get_queryset(self):
|
||||
return AgendaPricing.objects.filter(agenda=self.agenda)
|
||||
def get_success_url(self):
|
||||
return reverse('lingo-manager-agenda-pricing-list')
|
||||
|
||||
|
||||
agenda_pricing_delete = AgendaPricingDeleteView.as_view()
|
||||
|
||||
|
||||
class AgendaPricingMatrixEdit(AgendaMixin, FormView):
|
||||
class AgendaPricingMatrixEdit(FormView):
|
||||
template_name = 'lingo/pricing/manager_agenda_pricing_matrix_form.html'
|
||||
|
||||
def set_agenda(self, **kwargs):
|
||||
super().set_agenda(**kwargs)
|
||||
self.object = get_object_or_404(
|
||||
AgendaPricing.objects.filter(agenda=self.agenda), pk=kwargs['pricing_pk']
|
||||
)
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
self.object = get_object_or_404(AgendaPricing, pk=kwargs['pk'])
|
||||
matrix_list = list(self.object.iter_pricing_matrix())
|
||||
if not matrix_list:
|
||||
raise Http404
|
||||
|
@ -806,6 +806,7 @@ class AgendaPricingMatrixEdit(AgendaMixin, FormView):
|
|||
self.matrix = matrix_list[0]
|
||||
if self.matrix is None:
|
||||
raise Http404
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
kwargs['object'] = self.object
|
||||
|
@ -857,7 +858,7 @@ class AgendaPricingMatrixEdit(AgendaMixin, FormView):
|
|||
return self.form_invalid(form)
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse('lingo-manager-agenda-pricing-detail', args=[self.agenda.pk, self.object.pk])
|
||||
return reverse('lingo-manager-agenda-pricing-detail', args=[self.object.pk])
|
||||
|
||||
|
||||
agenda_pricing_matrix_edit = AgendaPricingMatrixEdit.as_view()
|
||||
|
|
|
@ -44,12 +44,11 @@ def test_agenda_chrono_link(settings, app, admin_user):
|
|||
|
||||
|
||||
def test_add_agenda_pricing(app, admin_user):
|
||||
agenda = Agenda.objects.create(label='Foo Bar')
|
||||
pricing = Pricing.objects.create(label='Model')
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/agendas/')
|
||||
resp = resp.click(href='/manage/pricing/agenda/%s/' % agenda.pk)
|
||||
resp = app.get('/manage/pricing/')
|
||||
resp = resp.click(href='/manage/pricing/agenda-pricings/')
|
||||
resp = resp.click('New pricing')
|
||||
# first pricing, starts on today
|
||||
assert resp.form['date_start'].value == now().strftime('%Y-%m-%d')
|
||||
|
@ -61,117 +60,63 @@ def test_add_agenda_pricing(app, admin_user):
|
|||
resp.form['date_end'] = '2022-09-01'
|
||||
resp = resp.form.submit()
|
||||
agenda_pricing = AgendaPricing.objects.latest('pk')
|
||||
assert resp.location.endswith('/manage/pricing/agenda/%s/pricing/%s/' % (agenda.pk, agenda_pricing.pk))
|
||||
assert resp.location.endswith('/manage/pricing/agenda-pricing/%s/' % agenda_pricing.pk)
|
||||
assert agenda_pricing.pricing == pricing
|
||||
assert agenda_pricing.agenda == agenda
|
||||
assert list(agenda_pricing.agendas.all()) == []
|
||||
assert agenda_pricing.date_start == datetime.date(2021, 9, 1)
|
||||
assert agenda_pricing.date_end == datetime.date(2022, 9, 1)
|
||||
|
||||
resp = app.get('/manage/pricing/agenda/%s/pricing/add/' % agenda.pk)
|
||||
# starts on last date_end
|
||||
assert resp.form['date_start'].value == '2022-09-01'
|
||||
resp.form['pricing'] = pricing.pk
|
||||
resp.form['date_start'] = '2021-11-01'
|
||||
resp.form['date_end'] = '2022-11-01'
|
||||
resp = resp.form.submit()
|
||||
assert resp.context['form'].errors['__all__'] == ['Pricing overlaps existing pricings.']
|
||||
resp.form['date_start'] = '2020-09-01'
|
||||
resp.form['date_end'] = '2021-09-01'
|
||||
resp = resp.form.submit()
|
||||
agenda_pricing = AgendaPricing.objects.latest('pk')
|
||||
assert agenda_pricing.pricing == pricing
|
||||
assert agenda_pricing.agenda == agenda
|
||||
assert agenda_pricing.date_start == datetime.date(2020, 9, 1)
|
||||
assert agenda_pricing.date_end == datetime.date(2021, 9, 1)
|
||||
|
||||
resp = app.get('/manage/pricing/agenda/%s/' % agenda.pk)
|
||||
assert AgendaPricing.objects.filter(agenda=agenda, pricing=pricing).count() == 2
|
||||
assert resp.text.count('"/manage/pricing/model/%s/"' % pricing.pk) == 2
|
||||
|
||||
resp = app.get('/manage/pricing/agenda/%s/pricing/add/' % agenda.pk)
|
||||
resp = app.get('/manage/pricing/agenda-pricing/add/')
|
||||
# starts on last date_end
|
||||
assert resp.form['date_start'].value == '2022-09-01'
|
||||
|
||||
|
||||
def test_edit_agenda_pricing(app, admin_user):
|
||||
agenda = Agenda.objects.create(label='Foo Bar')
|
||||
pricing = Pricing.objects.create(label='Model')
|
||||
pricing2 = Pricing.objects.create(label='Model 2')
|
||||
agenda_pricing = AgendaPricing.objects.create(
|
||||
agenda=agenda,
|
||||
pricing=pricing,
|
||||
date_start=datetime.date(year=2021, month=9, day=1),
|
||||
date_end=datetime.date(year=2022, month=9, day=1),
|
||||
)
|
||||
agenda2 = Agenda.objects.create(label='Foo Bar')
|
||||
agenda_pricing2 = AgendaPricing.objects.create(
|
||||
agenda=agenda2,
|
||||
pricing=pricing,
|
||||
date_start=datetime.date(year=2021, month=9, day=1),
|
||||
date_end=datetime.date(year=2022, month=9, day=1),
|
||||
)
|
||||
AgendaPricing.objects.create(
|
||||
agenda=agenda,
|
||||
pricing=pricing,
|
||||
date_start=datetime.date(year=2022, month=9, day=1),
|
||||
date_end=datetime.date(year=2023, month=9, day=1),
|
||||
)
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/agenda/%s/pricing/%s/' % (agenda.pk, agenda_pricing.pk))
|
||||
resp = resp.click(href='/manage/pricing/agenda/%s/pricing/%s/edit/' % (agenda.pk, agenda_pricing.pk))
|
||||
resp = app.get('/manage/pricing/agenda-pricing/%s/' % agenda_pricing.pk)
|
||||
resp = resp.click(href='/manage/pricing/agenda-pricing/%s/edit/' % agenda_pricing.pk)
|
||||
assert resp.form['date_start'].value == '2021-09-01'
|
||||
resp.form['pricing'] = pricing2.pk
|
||||
resp.form['date_start'] = '2021-09-01'
|
||||
resp.form['date_end'] = '2021-09-01'
|
||||
resp = resp.form.submit()
|
||||
assert resp.context['form'].errors['date_end'] == ['End date must be greater than start date.']
|
||||
resp.form['date_start'] = '2021-11-01'
|
||||
resp.form['date_end'] = '2022-11-01'
|
||||
resp = resp.form.submit()
|
||||
assert resp.context['form'].errors['__all__'] == ['Pricing overlaps existing pricings.']
|
||||
resp.form['date_start'] = '2021-08-01'
|
||||
resp.form['date_end'] = '2022-09-01'
|
||||
resp = resp.form.submit()
|
||||
assert resp.location.endswith('/manage/pricing/agenda/%s/pricing/%s/' % (agenda.pk, agenda_pricing.pk))
|
||||
assert resp.location.endswith('/manage/pricing/agenda-pricing/%s/' % agenda_pricing.pk)
|
||||
agenda_pricing.refresh_from_db()
|
||||
assert agenda_pricing.pricing == pricing2
|
||||
assert agenda_pricing.agenda == agenda
|
||||
assert agenda_pricing.date_start == datetime.date(2021, 8, 1)
|
||||
assert agenda_pricing.date_end == datetime.date(2022, 9, 1)
|
||||
|
||||
app.get('/manage/pricing/agenda/%s/pricing/%s/edit/' % (agenda.pk, agenda_pricing2.pk), status=404)
|
||||
app.get('/manage/pricing/agenda/%s/pricing/%s/edit/' % (0, agenda_pricing.pk), status=404)
|
||||
app.get('/manage/pricing/agenda/%s/pricing/%s/edit/' % (agenda.pk, 0), status=404)
|
||||
app.get('/manage/pricing/agenda-pricing/%s/edit/' % 0, status=404)
|
||||
|
||||
|
||||
def test_delete_agenda_pricing(app, admin_user):
|
||||
agenda = Agenda.objects.create(label='Foo Bar')
|
||||
pricing = Pricing.objects.create(label='Model')
|
||||
agenda_pricing = AgendaPricing.objects.create(
|
||||
agenda=agenda,
|
||||
pricing=pricing,
|
||||
date_start=datetime.date(year=2021, month=9, day=1),
|
||||
date_end=datetime.date(year=2022, month=9, day=1),
|
||||
)
|
||||
agenda2 = Agenda.objects.create(label='Foo Bar')
|
||||
agenda_pricing2 = AgendaPricing.objects.create(
|
||||
agenda=agenda2,
|
||||
pricing=pricing,
|
||||
date_start=datetime.date(year=2021, month=9, day=1),
|
||||
date_end=datetime.date(year=2022, month=9, day=1),
|
||||
)
|
||||
|
||||
app = login(app)
|
||||
app.get('/manage/pricing/agenda/%s/pricing/%s/delete/' % (agenda.pk, agenda_pricing2.pk), status=404)
|
||||
app.get('/manage/pricing/agenda/%s/pricing/%s/delete/' % (0, agenda_pricing.pk), status=404)
|
||||
app.get('/manage/pricing/agenda/%s/pricing/%s/delete/' % (agenda.pk, 0), status=404)
|
||||
app.get('/manage/pricing/agenda-pricing/%s/delete/' % 0, status=404)
|
||||
|
||||
resp = app.get('/manage/pricing/agenda/%s/pricing/%s/' % (agenda.pk, agenda_pricing.pk))
|
||||
resp = resp.click(href='/manage/pricing/agenda/%s/pricing/%s/delete/' % (agenda.pk, agenda_pricing.pk))
|
||||
resp = app.get('/manage/pricing/agenda-pricing/%s/' % agenda_pricing.pk)
|
||||
resp = resp.click(href='/manage/pricing/agenda-pricing/%s/delete/' % agenda_pricing.pk)
|
||||
resp = resp.form.submit()
|
||||
assert resp.location.endswith('/manage/pricing/agenda/%s/' % agenda.pk)
|
||||
assert AgendaPricing.objects.filter(pk=agenda_pricing.pk).exists() is False
|
||||
assert resp.location.endswith('/manage/pricing/agenda-pricings/')
|
||||
assert AgendaPricing.objects.exists() is False
|
||||
|
||||
|
||||
def test_detail_agenda_redirect(app, admin_user):
|
||||
|
@ -183,29 +128,18 @@ def test_detail_agenda_redirect(app, admin_user):
|
|||
|
||||
|
||||
def test_detail_agenda_pricing(app, admin_user):
|
||||
agenda = Agenda.objects.create(label='Foo Bar')
|
||||
pricing = Pricing.objects.create(label='Model')
|
||||
agenda_pricing = AgendaPricing.objects.create(
|
||||
agenda=agenda,
|
||||
pricing=pricing,
|
||||
date_start=datetime.date(year=2021, month=9, day=1),
|
||||
date_end=datetime.date(year=2021, month=10, day=1),
|
||||
)
|
||||
agenda2 = Agenda.objects.create(label='Foo Bar')
|
||||
agenda_pricing2 = AgendaPricing.objects.create(
|
||||
agenda=agenda2,
|
||||
pricing=pricing,
|
||||
date_start=datetime.date(year=2021, month=9, day=1),
|
||||
date_end=datetime.date(year=2021, month=10, day=1),
|
||||
)
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/agenda/%s/' % agenda.pk)
|
||||
resp = resp.click(href='/manage/pricing/agenda/%s/pricing/%s/' % (agenda.pk, agenda_pricing.pk))
|
||||
resp = app.get('/manage/pricing/agenda-pricings/')
|
||||
resp = resp.click(href='/manage/pricing/agenda-pricing/%s/' % agenda_pricing.pk)
|
||||
|
||||
app.get('/manage/pricing/agenda/%s/pricing/%s/' % (agenda.pk, agenda_pricing2.pk), status=404)
|
||||
app.get('/manage/pricing/agenda/%s/pricing/%s/' % (0, agenda_pricing.pk), status=404)
|
||||
app.get('/manage/pricing/agenda/%s/pricing/%s/' % (agenda.pk, 0), status=404)
|
||||
app.get('/manage/pricing/agenda-pricing/%s/' % 0, status=404)
|
||||
|
||||
|
||||
def test_detail_agenda_pricing_3_categories(app, admin_user):
|
||||
|
@ -222,14 +156,12 @@ def test_detail_agenda_pricing_3_categories(app, admin_user):
|
|||
Criteria.objects.create(label='Crit 3-4', slug='crit-3-4', category=category3, order=4)
|
||||
Criteria.objects.create(label='Crit 3-2', slug='crit-3-2', category=category3, order=2)
|
||||
|
||||
agenda = Agenda.objects.create(label='Foo bar')
|
||||
pricing = Pricing.objects.create(label='Foo bar')
|
||||
pricing.categories.add(category1, through_defaults={'order': 1})
|
||||
pricing.categories.add(category2, through_defaults={'order': 2})
|
||||
pricing.categories.add(category3, through_defaults={'order': 3})
|
||||
pricing.criterias.set(Criteria.objects.all())
|
||||
agenda_pricing = AgendaPricing.objects.create(
|
||||
agenda=agenda,
|
||||
pricing=pricing,
|
||||
date_start=datetime.date(year=2021, month=9, day=1),
|
||||
date_end=datetime.date(year=2021, month=10, day=1),
|
||||
|
@ -253,7 +185,7 @@ def test_detail_agenda_pricing_3_categories(app, admin_user):
|
|||
)
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/agenda/%s/pricing/%s/' % (agenda.pk, agenda_pricing.pk))
|
||||
resp = app.get('/manage/pricing/agenda-pricing/%s/' % agenda_pricing.pk)
|
||||
assert '<h3>Crit 1-1</h3>' in resp
|
||||
ths = resp.pyquery.find('table.pricing-matrix-crit-1-1 thead th')
|
||||
assert len(ths) == 4
|
||||
|
@ -331,13 +263,11 @@ def test_detail_agenda_pricing_2_categories(app, admin_user):
|
|||
Criteria.objects.create(label='Crit 3-4', slug='crit-3-4', category=category3, order=4)
|
||||
Criteria.objects.create(label='Crit 3-2', slug='crit-3-2', category=category3, order=2)
|
||||
|
||||
agenda = Agenda.objects.create(label='Foo bar')
|
||||
pricing = Pricing.objects.create(label='Foo bar')
|
||||
pricing.categories.add(category2, through_defaults={'order': 1})
|
||||
pricing.categories.add(category3, through_defaults={'order': 2})
|
||||
pricing.criterias.set(Criteria.objects.all())
|
||||
agenda_pricing = AgendaPricing.objects.create(
|
||||
agenda=agenda,
|
||||
pricing=pricing,
|
||||
date_start=datetime.date(year=2021, month=9, day=1),
|
||||
date_end=datetime.date(year=2021, month=10, day=1),
|
||||
|
@ -354,7 +284,7 @@ def test_detail_agenda_pricing_2_categories(app, admin_user):
|
|||
)
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/agenda/%s/pricing/%s/' % (agenda.pk, agenda_pricing.pk))
|
||||
resp = app.get('/manage/pricing/agenda-pricing/%s/' % agenda_pricing.pk)
|
||||
assert len(resp.pyquery.find('div.section.prixing-matrix h3')) == 0
|
||||
ths = resp.pyquery.find('table thead th')
|
||||
assert len(ths) == 4
|
||||
|
@ -384,12 +314,10 @@ def test_detail_agenda_pricing_1_category(app, admin_user):
|
|||
Criteria.objects.create(label='Crit 3-4', slug='crit-3-4', category=category3, order=4)
|
||||
Criteria.objects.create(label='Crit 3-2', slug='crit-3-2', category=category3, order=2)
|
||||
|
||||
agenda = Agenda.objects.create(label='Foo bar')
|
||||
pricing = Pricing.objects.create(label='Foo bar')
|
||||
pricing.categories.add(category3, through_defaults={'order': 3})
|
||||
pricing.criterias.set(Criteria.objects.all())
|
||||
agenda_pricing = AgendaPricing.objects.create(
|
||||
agenda=agenda,
|
||||
pricing=pricing,
|
||||
date_start=datetime.date(year=2021, month=9, day=1),
|
||||
date_end=datetime.date(year=2021, month=10, day=1),
|
||||
|
@ -401,7 +329,7 @@ def test_detail_agenda_pricing_1_category(app, admin_user):
|
|||
)
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/agenda/%s/pricing/%s/' % (agenda.pk, agenda_pricing.pk))
|
||||
resp = app.get('/manage/pricing/agenda-pricing/%s/' % agenda_pricing.pk)
|
||||
assert len(resp.pyquery.find('div.section.prixing-matrix h3')) == 0
|
||||
ths = resp.pyquery.find('table thead')
|
||||
assert len(ths) == 0
|
||||
|
@ -422,14 +350,14 @@ def test_detail_agenda_pricing_test_tool(mock_pricing_data, mock_subscriptions,
|
|||
agenda = Agenda.objects.create(label='Foo bar')
|
||||
pricing = Pricing.objects.create(label='Foo bar')
|
||||
agenda_pricing = AgendaPricing.objects.create(
|
||||
agenda=agenda,
|
||||
pricing=pricing,
|
||||
date_start=datetime.date(year=2021, month=9, day=1),
|
||||
date_end=datetime.date(year=2021, month=10, day=1),
|
||||
)
|
||||
agenda_pricing.agendas.add(agenda)
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/agenda/%s/pricing/%s/' % (agenda.pk, agenda_pricing.pk))
|
||||
resp = app.get('/manage/pricing/agenda-pricing/%s/' % agenda_pricing.pk)
|
||||
assert 'Computed pricing data' not in resp
|
||||
|
||||
# check event date
|
||||
|
@ -532,16 +460,16 @@ def test_detail_agenda_pricing_test_tool_event_error(mock_subscriptions, mock_ev
|
|||
agenda = Agenda.objects.create(label='Foo bar')
|
||||
pricing = Pricing.objects.create(label='Foo bar')
|
||||
agenda_pricing = AgendaPricing.objects.create(
|
||||
agenda=agenda,
|
||||
pricing=pricing,
|
||||
date_start=datetime.date(year=2021, month=9, day=1),
|
||||
date_end=datetime.date(year=2021, month=10, day=1),
|
||||
)
|
||||
agenda_pricing.agendas.add(agenda)
|
||||
|
||||
mock_event.side_effect = ChronoError('foo bar foo-bar@foo-event')
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/agenda/%s/pricing/%s/' % (agenda.pk, agenda_pricing.pk))
|
||||
resp = app.get('/manage/pricing/agenda-pricing/%s/' % agenda_pricing.pk)
|
||||
resp.form['event_slug'] = 'foo-event'
|
||||
resp.form['user_external_id'] = 'user:1'
|
||||
resp.form['adult_external_id'] = 'adult:1'
|
||||
|
@ -563,17 +491,17 @@ def test_detail_agenda_pricing_test_tool_subscription_error(mock_subscriptions,
|
|||
agenda = Agenda.objects.create(label='Foo bar')
|
||||
pricing = Pricing.objects.create(label='Foo bar')
|
||||
agenda_pricing = AgendaPricing.objects.create(
|
||||
agenda=agenda,
|
||||
pricing=pricing,
|
||||
date_start=datetime.date(year=2021, month=9, day=1),
|
||||
date_end=datetime.date(year=2021, month=10, day=1),
|
||||
)
|
||||
agenda_pricing.agendas.add(agenda)
|
||||
|
||||
mock_event.return_value = {'start_datetime': '2021-09-01T12:00:00+02:00'}
|
||||
mock_subscriptions.side_effect = ChronoError('foo bar')
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/agenda/%s/pricing/%s/' % (agenda.pk, agenda_pricing.pk))
|
||||
resp = app.get('/manage/pricing/agenda-pricing/%s/' % agenda_pricing.pk)
|
||||
resp.form['event_slug'] = 'foo-event'
|
||||
resp.form['user_external_id'] = 'user:1'
|
||||
resp.form['adult_external_id'] = 'adult:1'
|
||||
|
@ -591,11 +519,11 @@ def test_detail_agenda_pricing_test_tool_booking_status(
|
|||
agenda = Agenda.objects.create(label='Foo bar')
|
||||
pricing = Pricing.objects.create(label='Foo bar')
|
||||
agenda_pricing = AgendaPricing.objects.create(
|
||||
agenda=agenda,
|
||||
pricing=pricing,
|
||||
date_start=datetime.date(year=2021, month=9, day=1),
|
||||
date_end=datetime.date(year=2021, month=10, day=1),
|
||||
)
|
||||
agenda_pricing.agendas.add(agenda)
|
||||
|
||||
mock_event.return_value = {'start_datetime': '2021-09-01T12:00:00+02:00'}
|
||||
mock_subscriptions.return_value = [
|
||||
|
@ -606,7 +534,7 @@ def test_detail_agenda_pricing_test_tool_booking_status(
|
|||
]
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/agenda/%s/pricing/%s/' % (agenda.pk, agenda_pricing.pk))
|
||||
resp = app.get('/manage/pricing/agenda-pricing/%s/' % agenda_pricing.pk)
|
||||
assert resp.form['booking_status'].options == [
|
||||
('presence', False, 'Presence'),
|
||||
('absence', False, 'Absence'),
|
||||
|
@ -618,7 +546,7 @@ def test_detail_agenda_pricing_test_tool_booking_status(
|
|||
agenda.check_type_group = group
|
||||
agenda.save()
|
||||
|
||||
resp = app.get('/manage/pricing/agenda/%s/pricing/%s/' % (agenda.pk, agenda_pricing.pk))
|
||||
resp = app.get('/manage/pricing/agenda-pricing/%s/' % agenda_pricing.pk)
|
||||
assert resp.form['booking_status'].options == [
|
||||
('presence', False, 'Presence'),
|
||||
('presence::foo-presence-reason', False, 'Presence (Foo presence reason)'),
|
||||
|
@ -671,14 +599,12 @@ def test_edit_agenda_pricing_matrix_3_categories(app, admin_user):
|
|||
Criteria.objects.create(label='Crit 3-4', slug='crit-3-4', category=category3, order=4)
|
||||
Criteria.objects.create(label='Crit 3-2', slug='crit-3-2', category=category3, order=2)
|
||||
|
||||
agenda = Agenda.objects.create(label='Foo bar')
|
||||
pricing = Pricing.objects.create(label='Foo bar')
|
||||
pricing.categories.add(category1, through_defaults={'order': 1})
|
||||
pricing.categories.add(category2, through_defaults={'order': 2})
|
||||
pricing.categories.add(category3, through_defaults={'order': 3})
|
||||
pricing.criterias.set(Criteria.objects.all())
|
||||
agenda_pricing = AgendaPricing.objects.create(
|
||||
agenda=agenda,
|
||||
pricing=pricing,
|
||||
date_start=datetime.date(year=2021, month=9, day=1),
|
||||
date_end=datetime.date(year=2021, month=10, day=1),
|
||||
|
@ -702,10 +628,9 @@ def test_edit_agenda_pricing_matrix_3_categories(app, admin_user):
|
|||
)
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/agenda/%s/pricing/%s/' % (agenda.pk, agenda_pricing.pk))
|
||||
resp = app.get('/manage/pricing/agenda-pricing/%s/' % agenda_pricing.pk)
|
||||
resp = resp.click(
|
||||
href='/manage/pricing/agenda/%s/pricing/%s/matrix/%s/edit/'
|
||||
% (agenda.pk, agenda_pricing.pk, criteria11.slug)
|
||||
href='/manage/pricing/agenda-pricing/%s/matrix/%s/edit/' % (agenda_pricing.pk, criteria11.slug)
|
||||
)
|
||||
assert resp.form['form-0-crit_0'].value == '111'
|
||||
assert resp.form['form-0-crit_1'].value == ''
|
||||
|
@ -731,7 +656,7 @@ def test_edit_agenda_pricing_matrix_3_categories(app, admin_user):
|
|||
resp.form['form-3-crit_1'] = '124'
|
||||
resp.form['form-3-crit_2'] = '134'
|
||||
resp = resp.form.submit()
|
||||
assert resp.location.endswith('/manage/pricing/agenda/%s/pricing/%s/' % (agenda.pk, agenda_pricing.pk))
|
||||
assert resp.location.endswith('/manage/pricing/agenda-pricing/%s/' % agenda_pricing.pk)
|
||||
agenda_pricing.refresh_from_db()
|
||||
assert agenda_pricing.pricing_data == {
|
||||
'cat-1:crit-1-1': {
|
||||
|
@ -761,45 +686,24 @@ def test_edit_agenda_pricing_matrix_3_categories(app, admin_user):
|
|||
},
|
||||
}
|
||||
app.get(
|
||||
'/manage/pricing/agenda/%s/pricing/%s/matrix/%s/edit/'
|
||||
% (agenda.pk, agenda_pricing.pk, criteria12.slug),
|
||||
'/manage/pricing/agenda-pricing/%s/matrix/%s/edit/' % (agenda_pricing.pk, criteria12.slug),
|
||||
status=200,
|
||||
)
|
||||
|
||||
agenda2 = Agenda.objects.create(label='Foo Bar')
|
||||
agenda_pricing2 = AgendaPricing.objects.create(
|
||||
agenda=agenda2,
|
||||
pricing=pricing,
|
||||
date_start=datetime.date(year=2021, month=9, day=1),
|
||||
date_end=datetime.date(year=2022, month=9, day=1),
|
||||
)
|
||||
app.get('/manage/pricing/agenda-pricing/%s/matrix/%s/edit/' % (0, criteria11.slug), status=404)
|
||||
app.get(
|
||||
'/manage/pricing/agenda/%s/pricing/%s/matrix/%s/edit/'
|
||||
% (agenda.pk, agenda_pricing2.pk, criteria11.slug),
|
||||
'/manage/pricing/agenda-pricing/%s/matrix/%s/edit/' % (agenda_pricing.pk, 'unknown'),
|
||||
status=404,
|
||||
)
|
||||
app.get(
|
||||
'/manage/pricing/agenda/%s/pricing/%s/matrix/%s/edit/' % (0, agenda_pricing.pk, criteria11.slug),
|
||||
'/manage/pricing/agenda-pricing/%s/matrix/%s/edit/' % (agenda_pricing.pk, criteria21.slug),
|
||||
status=404,
|
||||
)
|
||||
app.get(
|
||||
'/manage/pricing/agenda/%s/pricing/%s/matrix/%s/edit/' % (agenda.pk, 0, criteria11.slug), status=404
|
||||
)
|
||||
app.get(
|
||||
'/manage/pricing/agenda/%s/pricing/%s/matrix/%s/edit/' % (agenda.pk, agenda_pricing.pk, 'unknown'),
|
||||
'/manage/pricing/agenda-pricing/%s/matrix/%s/edit/' % (agenda_pricing.pk, criteria31.slug),
|
||||
status=404,
|
||||
)
|
||||
app.get(
|
||||
'/manage/pricing/agenda/%s/pricing/%s/matrix/%s/edit/'
|
||||
% (agenda.pk, agenda_pricing.pk, criteria21.slug),
|
||||
status=404,
|
||||
)
|
||||
app.get(
|
||||
'/manage/pricing/agenda/%s/pricing/%s/matrix/%s/edit/'
|
||||
% (agenda.pk, agenda_pricing.pk, criteria31.slug),
|
||||
status=404,
|
||||
)
|
||||
app.get('/manage/pricing/agenda/%s/pricing/%s/matrix/edit/' % (agenda.pk, agenda_pricing.pk), status=404)
|
||||
app.get('/manage/pricing/agenda-pricing/%s/matrix/edit/' % agenda_pricing.pk, status=404)
|
||||
|
||||
|
||||
def test_edit_agenda_pricing_matrix_2_categories(app, admin_user):
|
||||
|
@ -813,13 +717,11 @@ def test_edit_agenda_pricing_matrix_2_categories(app, admin_user):
|
|||
Criteria.objects.create(label='Crit 3-4', slug='crit-3-4', category=category3, order=4)
|
||||
Criteria.objects.create(label='Crit 3-2', slug='crit-3-2', category=category3, order=2)
|
||||
|
||||
agenda = Agenda.objects.create(label='Foo bar')
|
||||
pricing = Pricing.objects.create(label='Foo bar')
|
||||
pricing.categories.add(category2, through_defaults={'order': 1})
|
||||
pricing.categories.add(category3, through_defaults={'order': 2})
|
||||
pricing.criterias.set(Criteria.objects.all())
|
||||
agenda_pricing = AgendaPricing.objects.create(
|
||||
agenda=agenda,
|
||||
pricing=pricing,
|
||||
date_start=datetime.date(year=2021, month=9, day=1),
|
||||
date_end=datetime.date(year=2021, month=10, day=1),
|
||||
|
@ -836,10 +738,8 @@ def test_edit_agenda_pricing_matrix_2_categories(app, admin_user):
|
|||
)
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/agenda/%s/pricing/%s/' % (agenda.pk, agenda_pricing.pk))
|
||||
resp = resp.click(
|
||||
href='/manage/pricing/agenda/%s/pricing/%s/matrix/edit/' % (agenda.pk, agenda_pricing.pk)
|
||||
)
|
||||
resp = app.get('/manage/pricing/agenda-pricing/%s/' % agenda_pricing.pk)
|
||||
resp = resp.click(href='/manage/pricing/agenda-pricing/%s/matrix/edit/' % agenda_pricing.pk)
|
||||
assert resp.form['form-0-crit_0'].value == '111'
|
||||
assert resp.form['form-0-crit_1'].value == ''
|
||||
assert resp.form['form-0-crit_2'].value == ''
|
||||
|
@ -864,7 +764,7 @@ def test_edit_agenda_pricing_matrix_2_categories(app, admin_user):
|
|||
resp.form['form-3-crit_1'] = '124'
|
||||
resp.form['form-3-crit_2'] = '134'
|
||||
resp = resp.form.submit()
|
||||
assert resp.location.endswith('/manage/pricing/agenda/%s/pricing/%s/' % (agenda.pk, agenda_pricing.pk))
|
||||
assert resp.location.endswith('/manage/pricing/agenda-pricing/%s/' % agenda_pricing.pk)
|
||||
agenda_pricing.refresh_from_db()
|
||||
assert agenda_pricing.pricing_data == {
|
||||
'cat-2:crit-2-1': {
|
||||
|
@ -887,24 +787,13 @@ def test_edit_agenda_pricing_matrix_2_categories(app, admin_user):
|
|||
},
|
||||
}
|
||||
|
||||
agenda2 = Agenda.objects.create(label='Foo Bar')
|
||||
agenda_pricing2 = AgendaPricing.objects.create(
|
||||
agenda=agenda2,
|
||||
pricing=pricing,
|
||||
date_start=datetime.date(year=2021, month=9, day=1),
|
||||
date_end=datetime.date(year=2022, month=9, day=1),
|
||||
)
|
||||
app.get('/manage/pricing/agenda/%s/pricing/%s/matrix/edit/' % (agenda.pk, agenda_pricing2.pk), status=404)
|
||||
app.get('/manage/pricing/agenda/%s/pricing/%s/matrix/edit/' % (0, agenda_pricing.pk), status=404)
|
||||
app.get('/manage/pricing/agenda/%s/pricing/%s/matrix/edit/' % (agenda.pk, 0), status=404)
|
||||
app.get('/manage/pricing/agenda-pricing/%s/matrix/edit/' % 0, status=404)
|
||||
app.get(
|
||||
'/manage/pricing/agenda/%s/pricing/%s/matrix/%s/edit/'
|
||||
% (agenda.pk, agenda_pricing.pk, criteria21.slug),
|
||||
'/manage/pricing/agenda-pricing/%s/matrix/%s/edit/' % (agenda_pricing.pk, criteria21.slug),
|
||||
status=404,
|
||||
)
|
||||
app.get(
|
||||
'/manage/pricing/agenda/%s/pricing/%s/matrix/%s/edit/'
|
||||
% (agenda.pk, agenda_pricing.pk, criteria31.slug),
|
||||
'/manage/pricing/agenda-pricing/%s/matrix/%s/edit/' % (agenda_pricing.pk, criteria31.slug),
|
||||
status=404,
|
||||
)
|
||||
|
||||
|
@ -916,12 +805,10 @@ def test_edit_agenda_pricing_matrix_1_category(app, admin_user):
|
|||
Criteria.objects.create(label='Crit 3-4', slug='crit-3-4', category=category3, order=4)
|
||||
Criteria.objects.create(label='Crit 3-2', slug='crit-3-2', category=category3, order=2)
|
||||
|
||||
agenda = Agenda.objects.create(label='Foo bar')
|
||||
pricing = Pricing.objects.create(label='Foo bar')
|
||||
pricing.categories.add(category3, through_defaults={'order': 3})
|
||||
pricing.criterias.set(Criteria.objects.all())
|
||||
agenda_pricing = AgendaPricing.objects.create(
|
||||
agenda=agenda,
|
||||
pricing=pricing,
|
||||
date_start=datetime.date(year=2021, month=9, day=1),
|
||||
date_end=datetime.date(year=2021, month=10, day=1),
|
||||
|
@ -933,10 +820,8 @@ def test_edit_agenda_pricing_matrix_1_category(app, admin_user):
|
|||
)
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/agenda/%s/pricing/%s/' % (agenda.pk, agenda_pricing.pk))
|
||||
resp = resp.click(
|
||||
href='/manage/pricing/agenda/%s/pricing/%s/matrix/edit/' % (agenda.pk, agenda_pricing.pk)
|
||||
)
|
||||
resp = app.get('/manage/pricing/agenda-pricing/%s/' % agenda_pricing.pk)
|
||||
resp = resp.click(href='/manage/pricing/agenda-pricing/%s/matrix/edit/' % agenda_pricing.pk)
|
||||
assert resp.form['form-0-crit_0'].value == '111'
|
||||
assert resp.form['form-1-crit_0'].value == ''
|
||||
assert resp.form['form-2-crit_0'].value == ''
|
||||
|
@ -945,7 +830,7 @@ def test_edit_agenda_pricing_matrix_1_category(app, admin_user):
|
|||
resp.form['form-2-crit_0'] = '113'
|
||||
resp.form['form-3-crit_0'] = '914'
|
||||
resp = resp.form.submit()
|
||||
assert resp.location.endswith('/manage/pricing/agenda/%s/pricing/%s/' % (agenda.pk, agenda_pricing.pk))
|
||||
assert resp.location.endswith('/manage/pricing/agenda-pricing/%s/' % agenda_pricing.pk)
|
||||
agenda_pricing.refresh_from_db()
|
||||
assert agenda_pricing.pricing_data == {
|
||||
'cat-3:crit-3-1': 111,
|
||||
|
@ -954,35 +839,23 @@ def test_edit_agenda_pricing_matrix_1_category(app, admin_user):
|
|||
'cat-3:crit-3-4': 914,
|
||||
}
|
||||
|
||||
agenda2 = Agenda.objects.create(label='Foo Bar')
|
||||
agenda_pricing2 = AgendaPricing.objects.create(
|
||||
agenda=agenda2,
|
||||
pricing=pricing,
|
||||
date_start=datetime.date(year=2021, month=9, day=1),
|
||||
date_end=datetime.date(year=2022, month=9, day=1),
|
||||
)
|
||||
app.get('/manage/pricing/agenda/%s/pricing/%s/matrix/edit/' % (agenda.pk, agenda_pricing2.pk), status=404)
|
||||
app.get('/manage/pricing/agenda/%s/pricing/%s/matrix/edit/' % (0, agenda_pricing.pk), status=404)
|
||||
app.get('/manage/pricing/agenda/%s/pricing/%s/matrix/edit/' % (agenda.pk, 0), status=404)
|
||||
app.get('/manage/pricing/agenda-pricing/%s/matrix/edit/' % 0, status=404)
|
||||
app.get(
|
||||
'/manage/pricing/agenda/%s/pricing/%s/matrix/%s/edit/'
|
||||
% (agenda.pk, agenda_pricing.pk, criteria31.slug),
|
||||
'/manage/pricing/agenda-pricing/%s/matrix/%s/edit/' % (agenda_pricing.pk, criteria31.slug),
|
||||
status=404,
|
||||
)
|
||||
|
||||
|
||||
def test_edit_agenda_pricing_matrix_empty(app, admin_user):
|
||||
agenda = Agenda.objects.create(label='Foo bar')
|
||||
pricing = Pricing.objects.create(label='Foo bar')
|
||||
agenda_pricing = AgendaPricing.objects.create(
|
||||
agenda=agenda,
|
||||
pricing=pricing,
|
||||
date_start=datetime.date(year=2021, month=9, day=1),
|
||||
date_end=datetime.date(year=2021, month=10, day=1),
|
||||
)
|
||||
|
||||
app = login(app)
|
||||
app.get('/manage/pricing/agenda/%s/pricing/%s/matrix/edit/' % (agenda.pk, agenda_pricing.pk), status=404)
|
||||
app.get('/manage/pricing/agenda-pricing/%s/matrix/edit/' % agenda_pricing.pk, status=404)
|
||||
|
||||
|
||||
def test_edit_agenda_check_type_group(app, admin_user):
|
||||
|
|
Loading…
Reference in New Issue