pricing: new home page, change some urls and breadcrumbs (#67196)
This commit is contained in:
parent
369fbb8602
commit
4cf25a1bca
|
@ -1,3 +1,5 @@
|
|||
$mobile-limit: 760px;
|
||||
|
||||
li span.identifier {
|
||||
font-size: 80%;
|
||||
opacity: 0.6;
|
||||
|
@ -22,6 +24,46 @@ div.paragraph {
|
|||
}
|
||||
}
|
||||
|
||||
a.button.button-paragraph {
|
||||
text-align: left;
|
||||
box-sizing: border-box;
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
a.button.button-paragraph p {
|
||||
font-weight: normal;
|
||||
color: #333;
|
||||
margin: 0;
|
||||
line-height: 150%;
|
||||
}
|
||||
|
||||
a.button.button-paragraph p:last-child {
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
a.button.button-paragraph:hover p {
|
||||
color: white;
|
||||
}
|
||||
|
||||
#lingo-manager-main {
|
||||
background: none bottom right no-repeat;
|
||||
// TODO background-image
|
||||
min-height: 80vh;
|
||||
background-size: 600px auto;
|
||||
@media screen and (max-width: 1200px) {
|
||||
background-size: 100% auto;
|
||||
}
|
||||
width: 99%;
|
||||
height: 90%;
|
||||
@media screen and (max-width: $mobile-limit) {
|
||||
background: none !important;
|
||||
min-height: 0;
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.sortable {
|
||||
span.handle {
|
||||
cursor: move;
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
{% extends "lingo/base.html" %}
|
||||
{% load static %}
|
||||
{% load i18n static %}
|
||||
|
||||
{% block extrascripts %}
|
||||
{{ block.super }}
|
||||
<script src="{% static 'js/lingo.manager.js' %}"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
{{ block.super }}
|
||||
<a href="{% url 'lingo-manager-homepage' %}">{% trans "Payments" %}</a>
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
{% extends "lingo/base.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block appbar %}
|
||||
<h2>{% trans 'Payments' %}</h2>
|
||||
<span class="actions">
|
||||
<a href="{% url 'lingo-manager-pricing-list' %}">{% trans 'Pricing' context 'pricing' %}</a>
|
||||
<a href="{% url 'lingo-manager-pricing-home' %}">{% trans 'Pricing' context 'pricing' %}</a>
|
||||
</span>
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends "lingo/pricing/manager_pricing_list.html" %}
|
||||
{% extends "lingo/pricing/manager_home.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
|
@ -10,7 +10,6 @@
|
|||
<h2>{% trans 'Agendas' %}</h2>
|
||||
<span class="actions">
|
||||
<a href="{% url 'lingo-manager-agenda-sync' %}">{% trans 'Refresh agendas' %}</a>
|
||||
<a href="{% url 'lingo-manager-check-type-list' %}">{% trans 'Check types' %}</a>
|
||||
</span>
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends "lingo/pricing/manager_agenda_list.html" %}
|
||||
{% extends "lingo/pricing/manager_home.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends "lingo/pricing/manager_pricing_list.html" %}
|
||||
{% extends "lingo/pricing/manager_home.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
{% extends "lingo/manager_base.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
{{ block.super }}
|
||||
<a href="{% url 'lingo-manager-pricing-home' %}">{% trans "Pricing" context 'pricing' %}</a>
|
||||
{% endblock %}
|
||||
|
||||
{% block appbar %}
|
||||
<h2>{% trans 'Pricing' context 'pricing' %}</h2>
|
||||
<span class="actions">
|
||||
<a class="extra-actions-menu-opener"></a>
|
||||
<ul class="extra-actions-menu">
|
||||
<li><a rel="popup" href="{% url 'lingo-manager-pricing-config-import' %}">{% trans 'Import' %}</a></li>
|
||||
<li><a rel="popup" href="{% url 'lingo-manager-pricing-config-export' %}" data-autoclose-dialog="true">{% trans 'Export' %}</a></li>
|
||||
</ul>
|
||||
</span>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div id="lingo-manager-main">
|
||||
<div class="fx-grid--t3">
|
||||
<a class="button button-paragraph" href="{% url 'lingo-manager-pricing-list' %}">
|
||||
{% trans "Pricing models" %}
|
||||
<p>{% trans "Pricing models are used to define pricing on events agendas." %}</p>
|
||||
</a>
|
||||
<a class="button button-paragraph" href="{% url 'lingo-manager-pricing-criteria-list' %}">
|
||||
{% trans "Criterias" %}
|
||||
<p>{% trans "Define criterias to describe a pricing model." %}</p>
|
||||
</a>
|
||||
<a class="button button-paragraph" href="">
|
||||
{% trans "Pricings" context 'agenda pricing' %}
|
||||
<p>{% trans "Pricing attached to events agendas." %}</p>
|
||||
</a>
|
||||
<a class="button button-paragraph" href="{% url 'lingo-manager-agenda-list' %}">
|
||||
{% trans "Agendas" %}
|
||||
<p>{% trans "Configure avent agendas." %}</p>
|
||||
</a>
|
||||
<a class="button button-paragraph" href="{% url 'lingo-manager-check-type-list' %}">
|
||||
{% trans "Check types" %}
|
||||
<p>{% trans "Check types are used to check bookings." %}</p>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -1,21 +1,14 @@
|
|||
{% extends "lingo/manager_base.html" %}
|
||||
{% extends "lingo/pricing/manager_home.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
{{ block.super }}
|
||||
<a href="{% url 'lingo-manager-pricing-list' %}">{% trans "Pricing" context 'pricing' %}</a>
|
||||
<a href="{% url 'lingo-manager-pricing-list' %}">{% trans "Pricing models" %}</a>
|
||||
{% endblock %}
|
||||
|
||||
{% block appbar %}
|
||||
<h2>{% trans 'Pricing' context 'pricing' %}</h2>
|
||||
<span class="actions">
|
||||
<a class="extra-actions-menu-opener"></a>
|
||||
<ul class="extra-actions-menu">
|
||||
<li><a rel="popup" href="{% url 'lingo-manager-pricing-config-import' %}">{% trans 'Import' %}</a></li>
|
||||
<li><a rel="popup" href="{% url 'lingo-manager-pricing-config-export' %}" data-autoclose-dialog="true">{% trans 'Export' %}</a></li>
|
||||
</ul>
|
||||
<a href="{% url 'lingo-manager-agenda-list' %}">{% trans 'Agendas' %}</a>
|
||||
<a href="{% url 'lingo-manager-pricing-criteria-list' %}">{% trans 'Criterias' %}</a>
|
||||
<a rel="popup" href="{% url 'lingo-manager-pricing-add' %}">{% trans 'New pricing model' %}</a>
|
||||
</span>
|
||||
{% endblock %}
|
||||
|
|
|
@ -19,61 +19,62 @@ from django.conf.urls import url
|
|||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', views.pricing_list, name='lingo-manager-pricing-list'),
|
||||
url(r'^$', views.home, name='lingo-manager-pricing-home'),
|
||||
url(r'^import/$', views.config_import, name='lingo-manager-pricing-config-import'),
|
||||
url(r'^export/$', views.config_export, name='lingo-manager-pricing-config-export'),
|
||||
url(r'^models/$', views.pricing_list, name='lingo-manager-pricing-list'),
|
||||
url(
|
||||
r'^add/$',
|
||||
r'^model/add/$',
|
||||
views.pricing_add,
|
||||
name='lingo-manager-pricing-add',
|
||||
),
|
||||
url(
|
||||
r'^(?P<pk>\d+)/$',
|
||||
r'^model/(?P<pk>\d+)/$',
|
||||
views.pricing_detail,
|
||||
name='lingo-manager-pricing-detail',
|
||||
),
|
||||
url(
|
||||
r'^(?P<pk>\d+)/edit/$',
|
||||
r'^model/(?P<pk>\d+)/edit/$',
|
||||
views.pricing_edit,
|
||||
name='lingo-manager-pricing-edit',
|
||||
),
|
||||
url(
|
||||
r'^(?P<pk>\d+)/delete/$',
|
||||
r'^model/(?P<pk>\d+)/delete/$',
|
||||
views.pricing_delete,
|
||||
name='lingo-manager-pricing-delete',
|
||||
),
|
||||
url(
|
||||
r'^(?P<pk>\d+)/duplicate/$',
|
||||
r'^model/(?P<pk>\d+)/duplicate/$',
|
||||
views.pricing_duplicate,
|
||||
name='lingo-manager-pricing-duplicate',
|
||||
),
|
||||
url(
|
||||
r'^(?P<pk>\d+)/export/$',
|
||||
r'^model/(?P<pk>\d+)/export/$',
|
||||
views.pricing_export,
|
||||
name='lingo-manager-pricing-export',
|
||||
),
|
||||
url(
|
||||
r'^(?P<pk>\d+)/variable/$',
|
||||
r'^model/(?P<pk>\d+)/variable/$',
|
||||
views.pricing_variable_edit,
|
||||
name='lingo-manager-pricing-variable-edit',
|
||||
),
|
||||
url(
|
||||
r'^(?P<pk>\d+)/category/add/$',
|
||||
r'^model/(?P<pk>\d+)/category/add/$',
|
||||
views.pricing_criteria_category_add,
|
||||
name='lingo-manager-pricing-criteria-category-add',
|
||||
),
|
||||
url(
|
||||
r'^(?P<pk>\d+)/category/(?P<category_pk>\d+)/edit/$',
|
||||
r'^model/(?P<pk>\d+)/category/(?P<category_pk>\d+)/edit/$',
|
||||
views.pricing_criteria_category_edit,
|
||||
name='lingo-manager-pricing-criteria-category-edit',
|
||||
),
|
||||
url(
|
||||
r'^(?P<pk>\d+)/category/(?P<category_pk>\d+)/delete/$',
|
||||
r'^model/(?P<pk>\d+)/category/(?P<category_pk>\d+)/delete/$',
|
||||
views.pricing_criteria_category_delete,
|
||||
name='lingo-manager-pricing-criteria-category-delete',
|
||||
),
|
||||
url(
|
||||
r'^(?P<pk>\d+)/order/$',
|
||||
r'^model/(?P<pk>\d+)/order/$',
|
||||
views.pricing_criteria_category_order,
|
||||
name='lingo-manager-pricing-criteria-category-order',
|
||||
),
|
||||
|
|
|
@ -35,6 +35,7 @@ from django.views.generic import (
|
|||
FormView,
|
||||
ListView,
|
||||
RedirectView,
|
||||
TemplateView,
|
||||
UpdateView,
|
||||
)
|
||||
from django.views.generic.detail import SingleObjectMixin
|
||||
|
@ -62,6 +63,13 @@ from lingo.pricing.utils import export_site, import_site
|
|||
from lingo.utils.misc import AgendaImportError
|
||||
|
||||
|
||||
class HomeView(TemplateView):
|
||||
template_name = 'lingo/pricing/manager_home.html'
|
||||
|
||||
|
||||
home = HomeView.as_view()
|
||||
|
||||
|
||||
class ConfigExportView(FormView):
|
||||
form_class = ExportForm
|
||||
template_name = 'lingo/pricing/export.html'
|
||||
|
@ -82,7 +90,7 @@ config_export = ConfigExportView.as_view()
|
|||
class ConfigImportView(FormView):
|
||||
form_class = ImportForm
|
||||
template_name = 'lingo/pricing/import.html'
|
||||
success_url = reverse_lazy('lingo-manager-pricing-list')
|
||||
success_url = reverse_lazy('lingo-manager-pricing-home')
|
||||
|
||||
def form_valid(self, form):
|
||||
try:
|
||||
|
|
|
@ -86,7 +86,7 @@ def test_add_agenda_pricing(app, admin_user):
|
|||
|
||||
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/%s/"' % pricing.pk) == 2
|
||||
assert resp.text.count('"/manage/pricing/model/%s/"' % pricing.pk) == 2
|
||||
|
||||
resp = app.get('/manage/pricing/agenda/%s/pricing/add/' % agenda.pk)
|
||||
# starts on last date_end
|
||||
|
|
|
@ -8,7 +8,7 @@ pytestmark = pytest.mark.django_db
|
|||
|
||||
def test_add_group(app, admin_user):
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/agendas/')
|
||||
resp = app.get('/manage/pricing/')
|
||||
resp = resp.click('Check types')
|
||||
resp = resp.click('New group')
|
||||
resp.form['label'] = 'Foo bar'
|
||||
|
|
|
@ -58,7 +58,7 @@ def test_import_pricing(app, admin_user):
|
|||
pricing = Pricing.objects.create(label='Model')
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/%s/export/' % pricing.id)
|
||||
resp = app.get('/manage/pricing/model/%s/export/' % pricing.pk)
|
||||
assert resp.headers['content-type'] == 'application/json'
|
||||
assert resp.headers['content-disposition'] == 'attachment; filename="export_pricing_model_20210708.json"'
|
||||
pricing_export = resp.text
|
||||
|
@ -68,7 +68,7 @@ def test_import_pricing(app, admin_user):
|
|||
resp = resp.click('Import')
|
||||
resp.form['config_json'] = Upload('export.json', pricing_export.encode('utf-8'), 'application/json')
|
||||
resp = resp.form.submit()
|
||||
assert resp.location.endswith('/manage/pricing/%s/' % pricing.pk)
|
||||
assert resp.location.endswith('/manage/pricing/model/%s/' % pricing.pk)
|
||||
resp = resp.follow()
|
||||
assert 'No pricing model created. A pricing model has been updated.' not in resp.text
|
||||
assert Pricing.objects.count() == 1
|
||||
|
@ -80,7 +80,7 @@ def test_import_pricing(app, admin_user):
|
|||
resp.form['config_json'] = Upload('export.json', pricing_export.encode('utf-8'), 'application/json')
|
||||
resp = resp.form.submit()
|
||||
pricing = Pricing.objects.latest('pk')
|
||||
assert resp.location.endswith('/manage/pricing/%s/' % pricing.pk)
|
||||
assert resp.location.endswith('/manage/pricing/model/%s/' % pricing.pk)
|
||||
resp = resp.follow()
|
||||
assert 'A pricing model has been created. No pricing model updated.' not in resp.text
|
||||
assert Pricing.objects.count() == 1
|
||||
|
|
|
@ -13,11 +13,12 @@ def test_add_pricing(app, admin_user):
|
|||
app = login(app)
|
||||
resp = app.get('/manage/')
|
||||
resp = resp.click('Pricing')
|
||||
resp = resp.click(href='/manage/pricing/models/')
|
||||
resp = resp.click('New pricing model')
|
||||
resp.form['label'] = 'Pricing model for lunch'
|
||||
resp = resp.form.submit()
|
||||
pricing = Pricing.objects.latest('pk')
|
||||
assert resp.location.endswith('/manage/pricing/%s/' % pricing.pk)
|
||||
assert resp.location.endswith('/manage/pricing/model/%s/' % pricing.pk)
|
||||
assert pricing.label == 'Pricing model for lunch'
|
||||
assert pricing.slug == 'pricing-model-for-lunch'
|
||||
|
||||
|
@ -26,10 +27,10 @@ def test_detail_pricing(app, admin_user):
|
|||
pricing = Pricing.objects.create(label='Model')
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/')
|
||||
resp = resp.click(href='/manage/pricing/%s/' % pricing.pk)
|
||||
assert '/manage/pricing/%s/edit/' % pricing.pk in resp
|
||||
assert '/manage/pricing/%s/delete/' % pricing.pk in resp
|
||||
resp = app.get('/manage/pricing/models/')
|
||||
resp = resp.click(href='/manage/pricing/model/%s/' % pricing.pk)
|
||||
assert '/manage/pricing/model/%s/edit/' % pricing.pk in resp
|
||||
assert '/manage/pricing/model/%s/delete/' % pricing.pk in resp
|
||||
|
||||
agenda = Agenda.objects.create(label='Foo Bar')
|
||||
AgendaPricing.objects.create(
|
||||
|
@ -44,7 +45,7 @@ def test_detail_pricing(app, admin_user):
|
|||
date_start=datetime.date(year=2022, month=9, day=1),
|
||||
date_end=datetime.date(year=2023, month=9, day=1),
|
||||
)
|
||||
resp = app.get('/manage/pricing/%s/' % pricing.pk)
|
||||
resp = app.get('/manage/pricing/model/%s/' % pricing.pk)
|
||||
assert resp.text.count('"/manage/pricing/agenda/%s/"' % agenda.pk) == 1
|
||||
|
||||
|
||||
|
@ -53,8 +54,8 @@ def test_edit_pricing(app, admin_user):
|
|||
pricing2 = Pricing.objects.create(label='Model 2')
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/%s/' % pricing.pk)
|
||||
resp = resp.click(href='/manage/pricing/%s/edit/' % pricing.pk)
|
||||
resp = app.get('/manage/pricing/model/%s/' % pricing.pk)
|
||||
resp = resp.click(href='/manage/pricing/model/%s/edit/' % pricing.pk)
|
||||
resp.form['label'] = 'Model Foo'
|
||||
resp.form['slug'] = pricing2.slug
|
||||
resp = resp.form.submit()
|
||||
|
@ -62,7 +63,7 @@ def test_edit_pricing(app, admin_user):
|
|||
|
||||
resp.form['slug'] = 'foo-bar'
|
||||
resp = resp.form.submit()
|
||||
assert resp.location.endswith('/manage/pricing/%s/' % pricing.pk)
|
||||
assert resp.location.endswith('/manage/pricing/model/%s/' % pricing.pk)
|
||||
pricing.refresh_from_db()
|
||||
assert pricing.label == 'Model Foo'
|
||||
assert pricing.slug == 'foo-bar'
|
||||
|
@ -72,10 +73,10 @@ def test_delete_pricing(app, admin_user):
|
|||
pricing = Pricing.objects.create(label='Model')
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/%s/' % pricing.pk)
|
||||
resp = resp.click(href='/manage/pricing/%s/delete/' % pricing.pk)
|
||||
resp = app.get('/manage/pricing/model/%s/' % pricing.pk)
|
||||
resp = resp.click(href='/manage/pricing/model/%s/delete/' % pricing.pk)
|
||||
resp = resp.form.submit()
|
||||
assert resp.location.endswith('/manage/pricing/')
|
||||
assert resp.location.endswith('/manage/pricing/models/')
|
||||
assert Pricing.objects.exists() is False
|
||||
|
||||
|
||||
|
@ -84,19 +85,19 @@ def test_duplicate_pricing(app, admin_user):
|
|||
assert Pricing.objects.count() == 1
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/%s/' % pricing.pk)
|
||||
resp = resp.click(href='/manage/pricing/%s/duplicate/' % pricing.pk)
|
||||
resp = app.get('/manage/pricing/model/%s/' % pricing.pk)
|
||||
resp = resp.click(href='/manage/pricing/model/%s/duplicate/' % pricing.pk)
|
||||
resp = resp.form.submit()
|
||||
assert Pricing.objects.count() == 2
|
||||
|
||||
new_pricing = Pricing.objects.latest('pk')
|
||||
assert resp.location == '/manage/pricing/%s/' % new_pricing.pk
|
||||
assert resp.location == '/manage/pricing/model/%s/' % new_pricing.pk
|
||||
assert new_pricing.pk != pricing.pk
|
||||
|
||||
resp = resp.follow()
|
||||
assert 'copy-of-model' in resp.text
|
||||
|
||||
resp = resp.click(href='/manage/pricing/%s/duplicate/' % new_pricing.pk)
|
||||
resp = resp.click(href='/manage/pricing/model/%s/duplicate/' % new_pricing.pk)
|
||||
resp.form['label'] = 'hop'
|
||||
resp = resp.form.submit().follow()
|
||||
assert 'hop' in resp.text
|
||||
|
@ -107,9 +108,9 @@ def test_pricing_edit_extra_variables(app, admin_user):
|
|||
assert pricing.extra_variables == {}
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/%s/' % pricing.id)
|
||||
resp = app.get('/manage/pricing/model/%s/' % pricing.pk)
|
||||
assert '<label>Extra variables:</label>' not in resp.text
|
||||
resp = resp.click(href='/manage/pricing/%s/variable/' % pricing.id)
|
||||
resp = resp.click(href='/manage/pricing/model/%s/variable/' % pricing.pk)
|
||||
resp.form['form-0-key'] = 'foo'
|
||||
resp.form['form-0-value'] = 'bar'
|
||||
resp = resp.form.submit().follow()
|
||||
|
@ -118,7 +119,7 @@ def test_pricing_edit_extra_variables(app, admin_user):
|
|||
assert '<label>Extra variables:</label>' in resp.text
|
||||
assert '<i>foo</i>' in resp
|
||||
|
||||
resp = resp.click(href='/manage/pricing/%s/variable/' % pricing.id)
|
||||
resp = resp.click(href='/manage/pricing/model/%s/variable/' % pricing.pk)
|
||||
assert resp.form['form-TOTAL_FORMS'].value == '2'
|
||||
assert resp.form['form-0-key'].value == 'foo'
|
||||
assert resp.form['form-0-value'].value == 'bar'
|
||||
|
@ -135,7 +136,7 @@ def test_pricing_edit_extra_variables(app, admin_user):
|
|||
}
|
||||
assert '<i>blah</i>, <i>foo</i>' in resp
|
||||
|
||||
resp = resp.click(href='/manage/pricing/%s/variable/' % pricing.id)
|
||||
resp = resp.click(href='/manage/pricing/model/%s/variable/' % pricing.pk)
|
||||
assert resp.form['form-TOTAL_FORMS'].value == '3'
|
||||
assert resp.form['form-0-key'].value == 'blah'
|
||||
assert resp.form['form-0-value'].value == 'baz'
|
||||
|
@ -162,8 +163,8 @@ def test_pricing_add_category(app, admin_user):
|
|||
category4 = CriteriaCategory.objects.create(label='Cat 4')
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/%s/' % pricing.pk)
|
||||
resp = resp.click(href='/manage/pricing/%s/category/add/' % pricing.pk)
|
||||
resp = app.get('/manage/pricing/model/%s/' % pricing.pk)
|
||||
resp = resp.click(href='/manage/pricing/model/%s/category/add/' % pricing.pk)
|
||||
assert list(resp.context['form'].fields['category'].queryset) == [
|
||||
category1,
|
||||
category2,
|
||||
|
@ -172,9 +173,9 @@ def test_pricing_add_category(app, admin_user):
|
|||
]
|
||||
resp.form['category'] = category1.pk
|
||||
resp = resp.form.submit()
|
||||
assert resp.location.endswith('/manage/pricing/%s/' % pricing.pk)
|
||||
assert resp.location.endswith('/manage/pricing/model/%s/' % pricing.pk)
|
||||
resp = resp.follow()
|
||||
assert '/manage/pricing/%s/category/add/' % pricing.pk in resp
|
||||
assert '/manage/pricing/model/%s/category/add/' % pricing.pk in resp
|
||||
assert list(
|
||||
PricingCriteriaCategory.objects.filter(pricing=pricing).values_list('category', flat=True)
|
||||
) == [category1.pk]
|
||||
|
@ -182,7 +183,7 @@ def test_pricing_add_category(app, admin_user):
|
|||
1
|
||||
]
|
||||
|
||||
resp = app.get('/manage/pricing/%s/category/add/' % pricing.pk)
|
||||
resp = app.get('/manage/pricing/model/%s/category/add/' % pricing.pk)
|
||||
assert list(resp.context['form'].fields['category'].queryset) == [category2, category3, category4]
|
||||
resp.form['category'] = category4.pk
|
||||
resp = resp.form.submit().follow()
|
||||
|
@ -194,11 +195,11 @@ def test_pricing_add_category(app, admin_user):
|
|||
2,
|
||||
]
|
||||
|
||||
resp = app.get('/manage/pricing/%s/category/add/' % pricing.pk)
|
||||
resp = app.get('/manage/pricing/model/%s/category/add/' % pricing.pk)
|
||||
assert list(resp.context['form'].fields['category'].queryset) == [category2, category3]
|
||||
resp.form['category'] = category2.pk
|
||||
resp = resp.form.submit().follow()
|
||||
assert '/manage/pricing/%s/category/add/' % pricing.pk not in resp
|
||||
assert '/manage/pricing/model/%s/category/add/' % pricing.pk not in resp
|
||||
assert list(
|
||||
PricingCriteriaCategory.objects.filter(pricing=pricing).values_list('category', flat=True)
|
||||
) == [category1.pk, category4.pk, category2.pk]
|
||||
|
@ -208,7 +209,7 @@ def test_pricing_add_category(app, admin_user):
|
|||
3,
|
||||
]
|
||||
|
||||
app.get('/manage/pricing/%s/category/add/' % pricing.pk, status=404)
|
||||
app.get('/manage/pricing/model/%s/category/add/' % pricing.pk, status=404)
|
||||
|
||||
|
||||
def test_pricing_edit_category(app, admin_user):
|
||||
|
@ -224,8 +225,8 @@ def test_pricing_edit_category(app, admin_user):
|
|||
pricing.categories.add(category2, through_defaults={'order': 2})
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/%s/' % pricing.pk)
|
||||
resp = resp.click(href='/manage/pricing/%s/category/%s/edit/' % (pricing.pk, category1.pk))
|
||||
resp = app.get('/manage/pricing/model/%s/' % pricing.pk)
|
||||
resp = resp.click(href='/manage/pricing/model/%s/category/%s/edit/' % (pricing.pk, category1.pk))
|
||||
assert list(resp.context['form'].fields['criterias'].queryset) == [
|
||||
criteria1,
|
||||
criteria2,
|
||||
|
@ -235,17 +236,17 @@ def test_pricing_edit_category(app, admin_user):
|
|||
assert list(resp.context['form'].initial['criterias']) == []
|
||||
resp.form['criterias'] = [criteria1.pk, criteria3.pk]
|
||||
resp = resp.form.submit()
|
||||
assert resp.location.endswith('/manage/pricing/%s/' % pricing.pk)
|
||||
assert resp.location.endswith('/manage/pricing/model/%s/' % pricing.pk)
|
||||
resp = resp.follow()
|
||||
assert list(pricing.criterias.order_by('pk')) == [criteria1, criteria3]
|
||||
|
||||
resp = app.get('/manage/pricing/%s/category/%s/edit/' % (pricing.pk, category1.pk))
|
||||
resp = app.get('/manage/pricing/model/%s/category/%s/edit/' % (pricing.pk, category1.pk))
|
||||
assert list(resp.context['form'].initial['criterias']) == [criteria1, criteria3]
|
||||
resp.form['criterias'] = [criteria1.pk, criteria4.pk]
|
||||
resp = resp.form.submit().follow()
|
||||
assert list(pricing.criterias.order_by('pk')) == [criteria1, criteria4]
|
||||
|
||||
resp = app.get('/manage/pricing/%s/category/%s/edit/' % (pricing.pk, category2.pk))
|
||||
resp = app.get('/manage/pricing/model/%s/category/%s/edit/' % (pricing.pk, category2.pk))
|
||||
assert list(resp.context['form'].fields['criterias'].queryset) == [criteria5]
|
||||
assert list(resp.context['form'].initial['criterias']) == []
|
||||
resp.form['criterias'] = [criteria5.pk]
|
||||
|
@ -264,18 +265,18 @@ def test_pricing_delete_category(app, admin_user):
|
|||
pricing.criterias.add(criteria1, criteria2)
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/%s/' % pricing.pk)
|
||||
resp = resp.click(href='/manage/pricing/%s/category/%s/delete/' % (pricing.pk, category1.pk))
|
||||
resp = app.get('/manage/pricing/model/%s/' % pricing.pk)
|
||||
resp = resp.click(href='/manage/pricing/model/%s/category/%s/delete/' % (pricing.pk, category1.pk))
|
||||
resp = resp.form.submit()
|
||||
assert resp.location.endswith('/manage/pricing/%s/' % pricing.pk)
|
||||
assert resp.location.endswith('/manage/pricing/model/%s/' % pricing.pk)
|
||||
resp = resp.follow()
|
||||
assert list(pricing.categories.all()) == [category2]
|
||||
assert list(pricing.criterias.all()) == [criteria2]
|
||||
|
||||
# not linked
|
||||
app.get('/manage/pricing/%s/category/%s/delete/' % (pricing.pk, category1.pk), status=404)
|
||||
app.get('/manage/pricing/model/%s/category/%s/delete/' % (pricing.pk, category1.pk), status=404)
|
||||
# unknown
|
||||
app.get('/manage/pricing/%s/category/%s/delete/' % (pricing.pk, 0), status=404)
|
||||
app.get('/manage/pricing/model/%s/category/%s/delete/' % (pricing.pk, 0), status=404)
|
||||
|
||||
|
||||
def test_pricing_reorder_categories(app, admin_user):
|
||||
|
@ -298,7 +299,7 @@ def test_pricing_reorder_categories(app, admin_user):
|
|||
|
||||
app = login(app)
|
||||
# missing get params
|
||||
app.get('/manage/pricing/%s/order/' % (pricing.pk), status=400)
|
||||
app.get('/manage/pricing/model/%s/order/' % (pricing.pk), status=400)
|
||||
|
||||
# bad new-order param
|
||||
bad_params = [
|
||||
|
@ -314,7 +315,7 @@ def test_pricing_reorder_categories(app, admin_user):
|
|||
]
|
||||
for bad_param in bad_params:
|
||||
app.get(
|
||||
'/manage/pricing/%s/order/' % (pricing.pk),
|
||||
'/manage/pricing/model/%s/order/' % (pricing.pk),
|
||||
params={'new-order': bad_param},
|
||||
status=400,
|
||||
)
|
||||
|
@ -330,7 +331,7 @@ def test_pricing_reorder_categories(app, admin_user):
|
|||
|
||||
# change order
|
||||
app.get(
|
||||
'/manage/pricing/%s/order/' % (pricing.pk),
|
||||
'/manage/pricing/model/%s/order/' % (pricing.pk),
|
||||
params={'new-order': ','.join(str(x) for x in [category3.pk, category1.pk, category2.pk])},
|
||||
)
|
||||
assert list(
|
||||
|
|
Loading…
Reference in New Issue