This commit is contained in:
parent
2626a5c27d
commit
18602448cb
|
@ -1,4 +1,4 @@
|
|||
{% extends "lingo/invoicing/manager_home.html" %}
|
||||
{% extends "lingo/invoicing/manager_regie_list.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
|
@ -16,7 +16,7 @@
|
|||
{{ form.as_p }}
|
||||
<div class="buttons">
|
||||
<button class="submit-button">{% trans "Export" %}</button>
|
||||
<a class="cancel" href="{% url 'lingo-manager-invoicing-home' %}">{% trans 'Cancel' %}</a>
|
||||
<a class="cancel" href="{% url 'lingo-manager-invoicing-regie-list' %}">{% trans 'Cancel' %}</a>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends "lingo/invoicing/manager_home.html" %}
|
||||
{% extends "lingo/invoicing/manager_regie_list.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
|
@ -16,7 +16,7 @@
|
|||
{{ form.as_p }}
|
||||
<div class="buttons">
|
||||
<button class="submit-button">{% trans "Import" %}</button>
|
||||
<a class="cancel" href="{% url 'lingo-manager-invoicing-home' %}">{% trans 'Cancel' %}</a>
|
||||
<a class="cancel" href="{% url 'lingo-manager-invoicing-regie-list' %}">{% trans 'Cancel' %}</a>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
{% extends "lingo/manager_base.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
{{ block.super }}
|
||||
<a href="{% url 'lingo-manager-invoicing-home' %}">{% trans 'Invoicing' %}</a>
|
||||
{% endblock %}
|
||||
|
||||
{% block appbar %}
|
||||
<h2>{% trans 'Invoicing' %}</h2>
|
||||
<span class="actions">
|
||||
<a class="extra-actions-menu-opener"></a>
|
||||
<ul class="extra-actions-menu">
|
||||
<li><a rel="popup" href="{% url 'lingo-manager-invoicing-config-import' %}">{% trans 'Import' %}</a></li>
|
||||
<li><a rel="popup" href="{% url 'lingo-manager-invoicing-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-invoicing-regie-list' %}">
|
||||
{% trans "Regies" %}
|
||||
<p>{% trans "Invoicing regies." %}</p>
|
||||
</a>
|
||||
<a class="button button-paragraph" href="{% url 'lingo-manager-invoicing-payer-list' %}">
|
||||
{% trans "Payers" %}
|
||||
<p>{% trans "Define here how payers are determined." %}</p>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -1,4 +1,4 @@
|
|||
{% extends "lingo/invoicing/manager_home.html" %}
|
||||
{% extends "lingo/invoicing/manager_regie_list.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
|
@ -9,15 +9,6 @@
|
|||
{% block appbar %}
|
||||
<h2>{% trans 'Payers' %}</h2>
|
||||
<span class="actions">
|
||||
<a class="extra-actions-menu-opener"></a>
|
||||
<ul class="extra-actions-menu">
|
||||
<li>
|
||||
<a href="{# url 'lingo-manager-invoicing-payer-import' #}">{% trans 'Import' %}</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{# url 'lingo-manager-invoicing-payer-export' #}">{% trans 'Export' %}</a>
|
||||
</li>
|
||||
</ul>
|
||||
<a rel="popup" href="{% url 'lingo-manager-invoicing-payer-add' %}">{% trans 'New payer' %}</a>
|
||||
</span>
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends "lingo/invoicing/manager_home.html" %}
|
||||
{% extends "lingo/manager_homepage.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
|
@ -9,6 +9,12 @@
|
|||
{% block appbar %}
|
||||
<h2>{% trans 'Regies' %}</h2>
|
||||
<span class="actions">
|
||||
<a class="extra-actions-menu-opener"></a>
|
||||
<ul class="extra-actions-menu">
|
||||
<li><a rel="popup" href="{% url 'lingo-manager-invoicing-config-import' %}">{% trans 'Import' %}</a></li>
|
||||
<li><a rel="popup" href="{% url 'lingo-manager-invoicing-config-export' %}" data-autoclose-dialog="true">{% trans 'Export' %}</a></li>
|
||||
<li><a href="{% url 'lingo-manager-invoicing-payer-list' %}">{% trans "Payers" %}</a></li>
|
||||
</ul>
|
||||
<a rel="popup" href="{% url 'lingo-manager-invoicing-regie-add' %}">{% trans 'New regie' %}</a>
|
||||
</span>
|
||||
{% endblock %}
|
||||
|
|
|
@ -23,7 +23,6 @@ from .views import pool as pool_views
|
|||
from .views import regie as regie_views
|
||||
|
||||
urlpatterns = [
|
||||
path('', home_views.home, name='lingo-manager-invoicing-home'),
|
||||
path('import/', home_views.config_import, name='lingo-manager-invoicing-config-import'),
|
||||
path('export/', home_views.config_export, name='lingo-manager-invoicing-config-export'),
|
||||
path('regies/', regie_views.regies_list, name='lingo-manager-invoicing-regie-list'),
|
||||
|
|
|
@ -23,20 +23,13 @@ from django.urls import reverse, reverse_lazy
|
|||
from django.utils.encoding import force_str
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils.translation import ngettext
|
||||
from django.views.generic import FormView, TemplateView
|
||||
from django.views.generic import FormView
|
||||
|
||||
from lingo.invoicing.forms import ExportForm, ImportForm
|
||||
from lingo.invoicing.utils import export_site, import_site
|
||||
from lingo.utils.misc import LingoImportError
|
||||
|
||||
|
||||
class HomeView(TemplateView):
|
||||
template_name = 'lingo/invoicing/manager_home.html'
|
||||
|
||||
|
||||
home = HomeView.as_view()
|
||||
|
||||
|
||||
class ConfigExportView(FormView):
|
||||
form_class = ExportForm
|
||||
template_name = 'lingo/invoicing/export.html'
|
||||
|
@ -57,7 +50,7 @@ config_export = ConfigExportView.as_view()
|
|||
class ConfigImportView(FormView):
|
||||
form_class = ImportForm
|
||||
template_name = 'lingo/invoicing/import.html'
|
||||
success_url = reverse_lazy('lingo-manager-invoicing-home')
|
||||
success_url = reverse_lazy('lingo-manager-invoicing-regie-list')
|
||||
|
||||
def form_valid(self, form):
|
||||
try:
|
||||
|
|
|
@ -3,8 +3,19 @@
|
|||
|
||||
{% block appbar %}
|
||||
<h2>{% trans 'Payments' context 'lingo title' %}</h2>
|
||||
<span class="actions">
|
||||
<a href="{% url 'lingo-manager-pricing-home' %}">{% trans 'Pricing' context 'pricing' %}</a>
|
||||
<a href="{% url 'lingo-manager-invoicing-home' %}">{% trans 'Invoicing' %}</a>
|
||||
</span>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div id="lingo-manager-main">
|
||||
<div class="fx-grid--t3">
|
||||
<a class="button button-paragraph" href="{% url 'lingo-manager-agenda-pricing-list' %}">
|
||||
{% trans "Pricing - Pricings"%}
|
||||
<p>{% trans "Pricings attached to events agendas." %}</p>
|
||||
</a>
|
||||
<a class="button button-paragraph" href="{% url 'lingo-manager-invoicing-regie-list' %}">
|
||||
{% trans "Invoicing - Regies" %}
|
||||
<p>{% trans "Regies and their campaigns, invoices, payments." %}</p>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends "lingo/pricing/manager_home.html" %}
|
||||
{% extends "lingo/pricing/manager_agenda_pricing_list.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
|
@ -16,7 +16,7 @@
|
|||
{{ form.as_p }}
|
||||
<div class="buttons">
|
||||
<button class="submit-button">{% trans "Export" %}</button>
|
||||
<a class="cancel" href="{% url 'lingo-manager-pricing-home' %}">{% trans 'Cancel' %}</a>
|
||||
<a class="cancel" href="{% url 'lingo-manager-agenda-pricing-list' %}">{% trans 'Cancel' %}</a>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends "lingo/pricing/manager_home.html" %}
|
||||
{% extends "lingo/pricing/manager_agenda_pricing_list.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
|
@ -16,7 +16,7 @@
|
|||
{{ form.as_p }}
|
||||
<div class="buttons">
|
||||
<button class="submit-button">{% trans "Import" %}</button>
|
||||
<a class="cancel" href="{% url 'lingo-manager-pricing-home' %}">{% trans 'Cancel' %}</a>
|
||||
<a class="cancel" href="{% url 'lingo-manager-agenda-pricing-list' %}">{% trans 'Cancel' %}</a>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends "lingo/pricing/manager_home.html" %}
|
||||
{% extends "lingo/pricing/manager_agenda_pricing_list.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends "lingo/pricing/manager_home.html" %}
|
||||
{% extends "lingo/manager_homepage.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
|
@ -9,6 +9,15 @@
|
|||
{% block appbar %}
|
||||
<h2>{% trans 'Pricings' context 'agenda 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>
|
||||
<li><a href="{% url 'lingo-manager-pricing-list' %}">{% trans "Pricing models" %}</a></li>
|
||||
<li><a href="{% url 'lingo-manager-pricing-criteria-list' %}">{% trans "Criterias" %}</a></li>
|
||||
<li><a href="{% url 'lingo-manager-agenda-list' %}">{% trans "Agendas" %}</a></li>
|
||||
<li><a href="{% url 'lingo-manager-check-type-list' %}">{% trans "Check types" %}</a></li>
|
||||
</ul>
|
||||
<a rel="popup" href="{% url 'lingo-manager-agenda-pricing-add' %}">{% trans 'New pricing' %}</a>
|
||||
</span>
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends "lingo/pricing/manager_home.html" %}
|
||||
{% extends "lingo/pricing/manager_agenda_pricing_list.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends "lingo/pricing/manager_home.html" %}
|
||||
{% extends "lingo/pricing/manager_agenda_pricing_list.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
{% 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="{% url 'lingo-manager-agenda-pricing-list' %}">
|
||||
{% trans "Pricings" context 'agenda pricing' %}
|
||||
<p>{% trans "Pricings 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,4 +1,4 @@
|
|||
{% extends "lingo/pricing/manager_home.html" %}
|
||||
{% extends "lingo/pricing/manager_agenda_pricing_list.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
|
|
|
@ -19,7 +19,6 @@ from django.urls import path, re_path
|
|||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path('', views.home, name='lingo-manager-pricing-home'),
|
||||
path('import/', views.config_import, name='lingo-manager-pricing-config-import'),
|
||||
path('export/', views.config_export, name='lingo-manager-pricing-config-export'),
|
||||
path('models/', views.pricing_list, name='lingo-manager-pricing-list'),
|
||||
|
|
|
@ -35,7 +35,6 @@ from django.views.generic import (
|
|||
FormView,
|
||||
ListView,
|
||||
RedirectView,
|
||||
TemplateView,
|
||||
UpdateView,
|
||||
)
|
||||
from django.views.generic.detail import SingleObjectMixin
|
||||
|
@ -73,13 +72,6 @@ from lingo.pricing.utils import export_site, import_site
|
|||
from lingo.utils.misc import LingoImportError
|
||||
|
||||
|
||||
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'
|
||||
|
@ -100,7 +92,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-home')
|
||||
success_url = reverse_lazy('lingo-manager-agenda-pricing-list')
|
||||
|
||||
def form_valid(self, form):
|
||||
try:
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
import pytest
|
||||
from django.urls import reverse
|
||||
|
||||
from tests.utils import login
|
||||
|
||||
pytestmark = pytest.mark.django_db
|
||||
|
||||
|
||||
def test_manager_home_show_invoicing(app, admin_user):
|
||||
app = login(app)
|
||||
resp = app.get('/manage/')
|
||||
anchor = resp.pyquery('div#appbar span.actions a[href="%s"]' % reverse('lingo-manager-invoicing-home'))
|
||||
assert anchor.text() == 'Invoicing'
|
||||
|
||||
|
||||
def test_manager_invoicing_home(app, admin_user):
|
||||
app = login(app)
|
||||
resp = app.get(reverse('lingo-manager-invoicing-home'))
|
||||
h2 = resp.pyquery('div#appbar h2')
|
||||
assert h2.text() == 'Invoicing'
|
||||
anchor = resp.pyquery(
|
||||
'div#lingo-manager-main div a[href="%s"]' % reverse('lingo-manager-invoicing-regie-list')
|
||||
)
|
||||
assert anchor.text().startswith('Regies')
|
||||
anchor = resp.pyquery(
|
||||
'div#lingo-manager-main div a[href="%s"]' % reverse('lingo-manager-invoicing-payer-list')
|
||||
)
|
||||
assert anchor.text().strip().startswith('Payers')
|
|
@ -13,7 +13,7 @@ pytestmark = pytest.mark.django_db
|
|||
def test_export_site(freezer, app, admin_user):
|
||||
freezer.move_to('2020-06-15')
|
||||
login(app)
|
||||
resp = app.get('/manage/invoicing/')
|
||||
resp = app.get('/manage/invoicing/regies/')
|
||||
resp = resp.click('Export')
|
||||
|
||||
resp = resp.form.submit()
|
||||
|
@ -57,7 +57,7 @@ def test_import_regie(app, admin_user):
|
|||
regie_export = resp.text
|
||||
|
||||
# existing regie
|
||||
resp = app.get('/manage/invoicing/', status=200)
|
||||
resp = app.get('/manage/invoicing/regies/')
|
||||
resp = resp.click('Import')
|
||||
resp.form['config_json'] = Upload('export.json', regie_export.encode('utf-8'), 'application/json')
|
||||
resp = resp.form.submit()
|
||||
|
@ -68,7 +68,7 @@ def test_import_regie(app, admin_user):
|
|||
|
||||
# new regie
|
||||
Regie.objects.all().delete()
|
||||
resp = app.get('/manage/invoicing/', status=200)
|
||||
resp = app.get('/manage/invoicing/regies/')
|
||||
resp = resp.click('Import')
|
||||
resp.form['config_json'] = Upload('export.json', regie_export.encode('utf-8'), 'application/json')
|
||||
resp = resp.form.submit()
|
||||
|
@ -87,17 +87,17 @@ def test_import_regie(app, admin_user):
|
|||
regies['regies'][2]['label'] = 'Foo bar 3'
|
||||
regies['regies'][2]['slug'] = 'foo-bar-3'
|
||||
|
||||
resp = app.get('/manage/invoicing/', status=200)
|
||||
resp = app.get('/manage/invoicing/regies/')
|
||||
resp = resp.click('Import')
|
||||
resp.form['config_json'] = Upload('export.json', json.dumps(regies).encode('utf-8'), 'application/json')
|
||||
resp = resp.form.submit()
|
||||
assert resp.location.endswith('/manage/invoicing/')
|
||||
assert resp.location.endswith('/manage/invoicing/regies/')
|
||||
resp = resp.follow()
|
||||
assert '2 regies have been created. A regie has been updated.' in resp.text
|
||||
assert Regie.objects.count() == 3
|
||||
|
||||
Regie.objects.all().delete()
|
||||
resp = app.get('/manage/invoicing/', status=200)
|
||||
resp = app.get('/manage/invoicing/regies/')
|
||||
resp = resp.click('Import')
|
||||
resp.form['config_json'] = Upload('export.json', json.dumps(regies).encode('utf-8'), 'application/json')
|
||||
resp = resp.form.submit().follow()
|
||||
|
@ -117,7 +117,7 @@ def test_import_payer(app, admin_user):
|
|||
payer_export = resp.text
|
||||
|
||||
# existing payer
|
||||
resp = app.get('/manage/invoicing/', status=200)
|
||||
resp = app.get('/manage/invoicing/regies/')
|
||||
resp = resp.click('Import')
|
||||
resp.form['config_json'] = Upload('export.json', payer_export.encode('utf-8'), 'application/json')
|
||||
resp = resp.form.submit()
|
||||
|
@ -128,7 +128,7 @@ def test_import_payer(app, admin_user):
|
|||
|
||||
# new payer
|
||||
Payer.objects.all().delete()
|
||||
resp = app.get('/manage/invoicing/', status=200)
|
||||
resp = app.get('/manage/invoicing/regies/')
|
||||
resp = resp.click('Import')
|
||||
resp.form['config_json'] = Upload('export.json', payer_export.encode('utf-8'), 'application/json')
|
||||
resp = resp.form.submit()
|
||||
|
@ -147,17 +147,17 @@ def test_import_payer(app, admin_user):
|
|||
payers['payers'][2]['label'] = 'Foo bar 3'
|
||||
payers['payers'][2]['slug'] = 'foo-bar-3'
|
||||
|
||||
resp = app.get('/manage/invoicing/', status=200)
|
||||
resp = app.get('/manage/invoicing/regies/')
|
||||
resp = resp.click('Import')
|
||||
resp.form['config_json'] = Upload('export.json', json.dumps(payers).encode('utf-8'), 'application/json')
|
||||
resp = resp.form.submit()
|
||||
assert resp.location.endswith('/manage/invoicing/')
|
||||
assert resp.location.endswith('/manage/invoicing/regies/')
|
||||
resp = resp.follow()
|
||||
assert '2 payers have been created. A payer has been updated.' in resp.text
|
||||
assert Payer.objects.count() == 3
|
||||
|
||||
Payer.objects.all().delete()
|
||||
resp = app.get('/manage/invoicing/', status=200)
|
||||
resp = app.get('/manage/invoicing/regies/')
|
||||
resp = resp.click('Import')
|
||||
resp.form['config_json'] = Upload('export.json', json.dumps(payers).encode('utf-8'), 'application/json')
|
||||
resp = resp.form.submit().follow()
|
||||
|
|
|
@ -12,7 +12,7 @@ pytestmark = pytest.mark.django_db
|
|||
@mock.patch('requests.Session.send', side_effect=mocked_requests_send)
|
||||
def test_add_payer(mock_send, app, admin_user):
|
||||
app = login(app)
|
||||
resp = app.get('/manage/invoicing/')
|
||||
resp = app.get('/manage/invoicing/regies/')
|
||||
resp = resp.click('Payers')
|
||||
resp = resp.click('New payer')
|
||||
assert resp.context['form'].fields['carddef_reference'].widget.choices == [
|
||||
|
|
|
@ -3,7 +3,7 @@ from decimal import Decimal
|
|||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
from django.utils.timezone import make_aware, now
|
||||
from django.utils.timezone import now
|
||||
|
||||
from lingo.agendas.chrono import ChronoError
|
||||
from lingo.agendas.models import Agenda, CheckType, CheckTypeGroup
|
||||
|
@ -17,7 +17,7 @@ def test_add_agenda_pricing(app, admin_user):
|
|||
pricing = Pricing.objects.create(label='Model')
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/')
|
||||
resp = app.get('/manage/')
|
||||
resp = resp.click(href='/manage/pricing/agenda-pricings/')
|
||||
resp = resp.click('New pricing')
|
||||
# first pricing, starts on today
|
||||
|
|
|
@ -8,7 +8,7 @@ pytestmark = pytest.mark.django_db
|
|||
|
||||
def test_add_group(app, admin_user):
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/')
|
||||
resp = app.get('/manage/pricing/agenda-pricings/')
|
||||
resp = resp.click('Check types')
|
||||
resp = resp.click('New group')
|
||||
resp.form['label'] = 'Foo bar'
|
||||
|
|
|
@ -15,7 +15,7 @@ pytestmark = pytest.mark.django_db
|
|||
def test_export_site(freezer, app, admin_user):
|
||||
freezer.move_to('2020-06-15')
|
||||
login(app)
|
||||
resp = app.get('/manage/pricing/')
|
||||
resp = app.get('/manage/pricing/agenda-pricings/')
|
||||
resp = resp.click('Export')
|
||||
|
||||
resp = resp.form.submit()
|
||||
|
@ -67,7 +67,7 @@ def test_import_pricing(app, admin_user):
|
|||
pricing_export = resp.text
|
||||
|
||||
# existing pricing
|
||||
resp = app.get('/manage/pricing/', status=200)
|
||||
resp = app.get('/manage/pricing/agenda-pricings/')
|
||||
resp = resp.click('Import')
|
||||
resp.form['config_json'] = Upload('export.json', pricing_export.encode('utf-8'), 'application/json')
|
||||
resp = resp.form.submit()
|
||||
|
@ -78,7 +78,7 @@ def test_import_pricing(app, admin_user):
|
|||
|
||||
# new pricing
|
||||
Pricing.objects.all().delete()
|
||||
resp = app.get('/manage/pricing/', status=200)
|
||||
resp = app.get('/manage/pricing/agenda-pricings/')
|
||||
resp = resp.click('Import')
|
||||
resp.form['config_json'] = Upload('export.json', pricing_export.encode('utf-8'), 'application/json')
|
||||
resp = resp.form.submit()
|
||||
|
@ -97,17 +97,17 @@ def test_import_pricing(app, admin_user):
|
|||
pricings['pricing_models'][2]['label'] = 'Foo bar 3'
|
||||
pricings['pricing_models'][2]['slug'] = 'foo-bar-3'
|
||||
|
||||
resp = app.get('/manage/pricing/', status=200)
|
||||
resp = app.get('/manage/pricing/agenda-pricings/')
|
||||
resp = resp.click('Import')
|
||||
resp.form['config_json'] = Upload('export.json', json.dumps(pricings).encode('utf-8'), 'application/json')
|
||||
resp = resp.form.submit()
|
||||
assert resp.location.endswith('/manage/pricing/')
|
||||
assert resp.location.endswith('/manage/pricing/agenda-pricings/')
|
||||
resp = resp.follow()
|
||||
assert '2 pricing models have been created. A pricing model has been updated.' in resp.text
|
||||
assert Pricing.objects.count() == 3
|
||||
|
||||
Pricing.objects.all().delete()
|
||||
resp = app.get('/manage/pricing/', status=200)
|
||||
resp = app.get('/manage/pricing/agenda-pricings/')
|
||||
resp = resp.click('Import')
|
||||
resp.form['config_json'] = Upload('export.json', json.dumps(pricings).encode('utf-8'), 'application/json')
|
||||
resp = resp.form.submit().follow()
|
||||
|
@ -131,7 +131,7 @@ def test_import_criteria_category(app, admin_user):
|
|||
category_export = resp.text
|
||||
|
||||
# existing category
|
||||
resp = app.get('/manage/pricing/', status=200)
|
||||
resp = app.get('/manage/pricing/agenda-pricings/')
|
||||
resp = resp.click('Import')
|
||||
resp.form['config_json'] = Upload('export.json', category_export.encode('utf-8'), 'application/json')
|
||||
resp = resp.form.submit()
|
||||
|
@ -145,7 +145,7 @@ def test_import_criteria_category(app, admin_user):
|
|||
|
||||
# new category
|
||||
CriteriaCategory.objects.all().delete()
|
||||
resp = app.get('/manage/pricing/', status=200)
|
||||
resp = app.get('/manage/pricing/agenda-pricings/')
|
||||
resp = resp.click('Import')
|
||||
resp.form['config_json'] = Upload('export.json', category_export.encode('utf-8'), 'application/json')
|
||||
resp = resp.form.submit()
|
||||
|
@ -166,13 +166,13 @@ def test_import_criteria_category(app, admin_user):
|
|||
categories['pricing_categories'][2]['label'] = 'Foo bar 3'
|
||||
categories['pricing_categories'][2]['slug'] = 'foo-bar-3'
|
||||
|
||||
resp = app.get('/manage/pricing/', status=200)
|
||||
resp = app.get('/manage/pricing/agenda-pricings/')
|
||||
resp = resp.click('Import')
|
||||
resp.form['config_json'] = Upload(
|
||||
'export.json', json.dumps(categories).encode('utf-8'), 'application/json'
|
||||
)
|
||||
resp = resp.form.submit()
|
||||
assert resp.location.endswith('/manage/pricing/')
|
||||
assert resp.location.endswith('/manage/pricing/agenda-pricings/')
|
||||
resp = resp.follow()
|
||||
assert (
|
||||
'2 pricing criteria categories have been created. A pricing criteria category has been updated.'
|
||||
|
@ -182,7 +182,7 @@ def test_import_criteria_category(app, admin_user):
|
|||
assert Criteria.objects.count() == 6
|
||||
|
||||
CriteriaCategory.objects.all().delete()
|
||||
resp = app.get('/manage/pricing/', status=200)
|
||||
resp = app.get('/manage/pricing/agenda-pricings/')
|
||||
resp = resp.click('Import')
|
||||
resp.form['config_json'] = Upload(
|
||||
'export.json', json.dumps(categories).encode('utf-8'), 'application/json'
|
||||
|
@ -210,7 +210,7 @@ def test_import_agenda(app, admin_user):
|
|||
agenda_export = resp.text
|
||||
|
||||
# existing agenda
|
||||
resp = app.get('/manage/pricing/', status=200)
|
||||
resp = app.get('/manage/pricing/agenda-pricings/')
|
||||
resp = resp.click('Import')
|
||||
resp.form['config_json'] = Upload('export.json', agenda_export.encode('utf-8'), 'application/json')
|
||||
resp = resp.form.submit()
|
||||
|
@ -221,7 +221,7 @@ def test_import_agenda(app, admin_user):
|
|||
|
||||
# unknown agenda
|
||||
Agenda.objects.all().delete()
|
||||
resp = app.get('/manage/pricing/', status=200)
|
||||
resp = app.get('/manage/pricing/agenda-pricings/')
|
||||
resp = resp.click('Import')
|
||||
resp.form['config_json'] = Upload('export.json', agenda_export.encode('utf-8'), 'application/json')
|
||||
resp = resp.form.submit()
|
||||
|
@ -234,11 +234,11 @@ def test_import_agenda(app, admin_user):
|
|||
agendas['agendas'].append(copy.copy(agendas['agendas'][0]))
|
||||
agendas['agendas'][1]['slug'] = 'foo-bar-2'
|
||||
|
||||
resp = app.get('/manage/pricing/', status=200)
|
||||
resp = app.get('/manage/pricing/agenda-pricings/')
|
||||
resp = resp.click('Import')
|
||||
resp.form['config_json'] = Upload('export.json', json.dumps(agendas).encode('utf-8'), 'application/json')
|
||||
resp = resp.form.submit()
|
||||
assert resp.location.endswith('/manage/pricing/')
|
||||
assert resp.location.endswith('/manage/pricing/agenda-pricings/')
|
||||
resp = resp.follow()
|
||||
assert '2 agendas have been updated.' in resp.text
|
||||
assert Agenda.objects.count() == 2
|
||||
|
@ -260,7 +260,7 @@ def test_import_check_type_group(app, admin_user):
|
|||
group_export = resp.text
|
||||
|
||||
# existing group
|
||||
resp = app.get('/manage/pricing/', status=200)
|
||||
resp = app.get('/manage/pricing/agenda-pricings/')
|
||||
resp = resp.click('Import')
|
||||
resp.form['config_json'] = Upload('export.json', group_export.encode('utf-8'), 'application/json')
|
||||
resp = resp.form.submit()
|
||||
|
@ -272,7 +272,7 @@ def test_import_check_type_group(app, admin_user):
|
|||
|
||||
# new group
|
||||
CheckTypeGroup.objects.all().delete()
|
||||
resp = app.get('/manage/pricing/', status=200)
|
||||
resp = app.get('/manage/pricing/agenda-pricings/')
|
||||
resp = resp.click('Import')
|
||||
resp.form['config_json'] = Upload('export.json', group_export.encode('utf-8'), 'application/json')
|
||||
resp = resp.form.submit()
|
||||
|
@ -291,18 +291,18 @@ def test_import_check_type_group(app, admin_user):
|
|||
groups['check_type_groups'][2]['label'] = 'Foo bar 3'
|
||||
groups['check_type_groups'][2]['slug'] = 'foo-bar-3'
|
||||
|
||||
resp = app.get('/manage/pricing/', status=200)
|
||||
resp = app.get('/manage/pricing/agenda-pricings/')
|
||||
resp = resp.click('Import')
|
||||
resp.form['config_json'] = Upload('export.json', json.dumps(groups).encode('utf-8'), 'application/json')
|
||||
resp = resp.form.submit()
|
||||
assert resp.location.endswith('/manage/pricing/')
|
||||
assert resp.location.endswith('/manage/pricing/agenda-pricings/')
|
||||
resp = resp.follow()
|
||||
assert '2 check type groups have been created. A check type group has been updated.' in resp.text
|
||||
assert CheckTypeGroup.objects.count() == 3
|
||||
assert CheckType.objects.count() == 6
|
||||
|
||||
CheckTypeGroup.objects.all().delete()
|
||||
resp = app.get('/manage/pricing/', status=200)
|
||||
resp = app.get('/manage/pricing/agenda-pricings/')
|
||||
resp = resp.click('Import')
|
||||
resp.form['config_json'] = Upload('export.json', json.dumps(groups).encode('utf-8'), 'application/json')
|
||||
resp = resp.form.submit().follow()
|
||||
|
@ -327,7 +327,7 @@ def test_import_agenda_pricing(app, admin_user):
|
|||
agenda_pricing_export = resp.text
|
||||
|
||||
# existing agenda_pricing
|
||||
resp = app.get('/manage/pricing/', status=200)
|
||||
resp = app.get('/manage/pricing/agenda-pricings/')
|
||||
resp = resp.click('Import')
|
||||
resp.form['config_json'] = Upload(
|
||||
'export.json', agenda_pricing_export.encode('utf-8'), 'application/json'
|
||||
|
@ -340,7 +340,7 @@ def test_import_agenda_pricing(app, admin_user):
|
|||
|
||||
# new agenda_pricing
|
||||
AgendaPricing.objects.all().delete()
|
||||
resp = app.get('/manage/pricing/', status=200)
|
||||
resp = app.get('/manage/pricing/agenda-pricings/')
|
||||
resp = resp.click('Import')
|
||||
resp.form['config_json'] = Upload(
|
||||
'export.json', agenda_pricing_export.encode('utf-8'), 'application/json'
|
||||
|
@ -361,19 +361,19 @@ def test_import_agenda_pricing(app, admin_user):
|
|||
agenda_pricings['pricings'][2]['label'] = 'Foo bar 3'
|
||||
agenda_pricings['pricings'][2]['slug'] = 'foo-bar-3'
|
||||
|
||||
resp = app.get('/manage/pricing/', status=200)
|
||||
resp = app.get('/manage/pricing/agenda-pricings/')
|
||||
resp = resp.click('Import')
|
||||
resp.form['config_json'] = Upload(
|
||||
'export.json', json.dumps(agenda_pricings).encode('utf-8'), 'application/json'
|
||||
)
|
||||
resp = resp.form.submit()
|
||||
assert resp.location.endswith('/manage/pricing/')
|
||||
assert resp.location.endswith('/manage/pricing/agenda-pricings/')
|
||||
resp = resp.follow()
|
||||
assert '2 pricings have been created. A pricing has been updated.' in resp.text
|
||||
assert AgendaPricing.objects.count() == 3
|
||||
|
||||
AgendaPricing.objects.all().delete()
|
||||
resp = app.get('/manage/pricing/', status=200)
|
||||
resp = app.get('/manage/pricing/agenda-pricings/')
|
||||
resp = resp.click('Import')
|
||||
resp.form['config_json'] = Upload(
|
||||
'export.json', json.dumps(agenda_pricings).encode('utf-8'), 'application/json'
|
||||
|
|
Loading…
Reference in New Issue