pricing: move pricing config in a parameters page (#89605)
This commit is contained in:
parent
bee75028ca
commit
30f9c86784
|
@ -1,4 +1,4 @@
|
|||
{% extends "lingo/pricing/manager_pricing_detail.html" %}
|
||||
{% extends "lingo/pricing/manager_pricing_parameters.html" %}
|
||||
{% load gadjo i18n %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
|
@ -16,7 +16,10 @@
|
|||
{{ form|with_template }}
|
||||
<div class="buttons">
|
||||
<button class="submit-button">{% trans "Save" %}</button>
|
||||
<a class="cancel" href="{% url 'lingo-manager-pricing-detail' object.pk %}">{% trans 'Cancel' %}</a>
|
||||
<a class="cancel" href="{% url 'lingo-manager-pricing-parameters' object.pk %}">{% trans 'Cancel' %}</a>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends "lingo/pricing/manager_pricing_detail.html" %}
|
||||
{% extends "lingo/pricing/manager_pricing_parameters.html" %}
|
||||
{% load gadjo i18n %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
|
@ -24,7 +24,10 @@
|
|||
{{ form|with_template }}
|
||||
<div class="buttons">
|
||||
<button class="submit-button">{% trans "Save" %}</button>
|
||||
<a class="cancel" href="{% url 'lingo-manager-pricing-detail' object.pk %}">{% trans 'Cancel' %}</a>
|
||||
<a class="cancel" href="{% url 'lingo-manager-pricing-parameters' object.pk %}">{% trans 'Cancel' %}</a>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
{% extends "lingo/pricing/manager_pricing_list.html" %}
|
||||
{% extends "lingo/pricing/manager_pricing_parameters.html" %}
|
||||
{% load gadjo i18n %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
{{ block.super }}
|
||||
<a href="{% url 'lingo-manager-pricing-detail' object.pk %}">{{ object }}</a>
|
||||
{% if category %}
|
||||
<a href="{% url 'lingo-manager-pricing-criteria-category-edit' object.pk category.pk %}">{% trans "Select criterias" %}</a>
|
||||
{% else %}
|
||||
|
@ -25,7 +24,10 @@
|
|||
{{ form|with_template }}
|
||||
<div class="buttons">
|
||||
<button class="submit-button">{% trans "Save" %}</button>
|
||||
<a class="cancel" href="{% url 'lingo-manager-pricing-detail' object.pk %}">{% trans 'Cancel' %}</a>
|
||||
<a class="cancel" href="{% url 'lingo-manager-pricing-parameters' object.pk %}">{% trans 'Cancel' %}</a>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -11,281 +11,90 @@
|
|||
{{ object }}
|
||||
<span class="identifier">[{% trans "identifier:" %} {{ object.slug }}]</span>
|
||||
</h2>
|
||||
<span class="actions">
|
||||
<a class="extra-actions-menu-opener"></a>
|
||||
<ul class="extra-actions-menu">
|
||||
<li><a rel="popup" class="action-duplicate" href="{% url 'lingo-manager-pricing-duplicate' pk=object.pk %}">{% trans 'Duplicate' %}</a></li>
|
||||
<li><a rel="popup" href="{% url 'lingo-manager-pricing-delete' object.pk %}">{% trans 'Delete' %}</a></li>
|
||||
</ul>
|
||||
</span>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% with iter_matrix=object.iter_pricing_matrix|list agendas=object.agendas.all %}
|
||||
<div class="section">
|
||||
<div class="pk-tabs">
|
||||
<div class="pk-tabs--tab-list" role="tablist">
|
||||
<button aria-controls="panel-options" aria-selected="true" id="tab-options" role="tab" tabindex="0">{% trans "Options" %}</button>
|
||||
<button aria-controls="panel-variables" aria-selected="false" id="tab-variables" role="tab" tabindex="-1">{% trans "Variables" %}</button>
|
||||
<button aria-controls="panel-criterias" aria-selected="false" id="tab-criterias" role="tab" tabindex="-1">{% trans "Criterias" %}</button>
|
||||
{% if object.kind != 'basic' %}
|
||||
<button aria-controls="panel-pricing-options" aria-selected="false" id="tab-pricing-options" role="tab" tabindex="0">{% trans "Pricing options" %}</button>
|
||||
{% endif %}
|
||||
{% if object.subscription_required %}
|
||||
<button aria-controls="panel-agendas" aria-selected="false" id="tab-agendas" role="tab" tabindex="0">{% trans "Agendas" %}</button>
|
||||
{% endif %}
|
||||
<button aria-controls="panel-debug" aria-selected="false" id="tab-debug" role="tab" tabindex="0">{% trans "Test tool" %}</button>
|
||||
{% if object.flat_fee_schedule %}
|
||||
<button aria-controls="panel-billing-dates" aria-selected="false" id="tab-billing-dates" role="tab" tabindex="0">{% trans "Billing dates" %}</button>
|
||||
{% endif %}
|
||||
{% for matrix in iter_matrix %}
|
||||
<button aria-controls="panel-matrix-{{ matrix.criteria.slug }}" aria-selected="false" id="tab-matrix-{{ matrix.criteria.slug }}" role="tab" tabindex="-1">{% trans "Pricings" context 'amount' %}{% if matrix.criteria %} - {{ matrix.criteria.label }}{% endif %}</button>
|
||||
{% empty %}
|
||||
<button aria-controls="panel-matrix" aria-selected="false" id="tab-matrix" role="tab" tabindex="-1">{% trans "Pricings" context 'amount' %}</button>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="pk-tabs--container">
|
||||
<div class="section">
|
||||
<div class="pk-tabs">
|
||||
<div class="pk-tabs--tab-list" role="tablist">
|
||||
<button aria-controls="panel-matrix" aria-selected="true" id="tab-matrix" role="tab" tabindex="0">{% trans "Pricings" context 'amount' %}</button>
|
||||
{% if object.kind != 'basic' %}
|
||||
<button aria-controls="panel-pricing-options" aria-selected="false" id="tab-pricing-options" role="tab" tabindex="-1">{% trans "Pricing options" %}</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="pk-tabs--container">
|
||||
|
||||
<div aria-labelledby="tab-options" id="panel-options" role="tabpanel" tabindex="0">
|
||||
<ul>
|
||||
<li>{% blocktrans trimmed with start=object.date_start|date:'d/m/Y' end=object.date_end|date:'d/m/Y' %}From {{ start }} to {{ end }}{% endblocktrans %}</li>
|
||||
<li>{% trans "Flat fee schedule:" %} {{ object.flat_fee_schedule|yesno }}</li>
|
||||
{% if object.flat_fee_schedule %}
|
||||
<li>{% trans "Subscription required:" %} {{ object.subscription_required|yesno }}</li>
|
||||
{% endif %}
|
||||
<li>{% trans "Kind of pricing:"%} {{ object.get_kind_display }}</li>
|
||||
{% if object.kind == 'reduction' %}
|
||||
<li>{% trans "Reduction rate (template):" %} <pre>{{ object.reduction_rate }}</pre></li>
|
||||
{% elif object.kind == 'effort' %}
|
||||
<li>{% trans "Pricing to be multiplied by the effort rate (template):" %} <pre>{{ object.effort_rate_target }}</pre></li>
|
||||
{% endif %}
|
||||
<li>{% trans "Accounting code (template):" %} <pre>{{ object.accounting_code }}</pre></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div aria-labelledby="tab-variables" hidden="" id="panel-variables" role="tabpanel" tabindex="0">
|
||||
{% if object.extra_variables %}
|
||||
<label>{% trans 'Extra variables:' %}</label>
|
||||
<dl>
|
||||
{% for key in object.get_extra_variables_keys %}
|
||||
<dt><b>{% blocktrans %}{{ key }}:{% endblocktrans %}</b></dt>
|
||||
<dd><pre>{{ object.extra_variables|get:key }}</pre></dd>
|
||||
{% endfor %}
|
||||
</dl>
|
||||
{% endif %}
|
||||
<div class="panel--buttons">
|
||||
<a class="pk-button" rel="popup" href="{% url 'lingo-manager-pricing-variable-edit' pk=object.pk %}">{% trans 'Define variables' %}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div aria-labelledby="tab-criterias" hidden="" id="panel-criterias" role="tabpanel" tabindex="0">
|
||||
{% with criterias=object.criterias.all categories=object.categories.all %}
|
||||
{% if categories %}
|
||||
<div>
|
||||
{% blocktrans trimmed %}Use drag and drop with the ⣿ handles to reorder categories.{% endblocktrans %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="sortable" data-order-url="{% url 'lingo-manager-pricing-criteria-category-order' object.pk %}">
|
||||
{% for category in categories %}
|
||||
<div class="paragraph sortable-item" data-item-id="{{ category.pk }}">
|
||||
<h4><span class="handle">⣿</span>{% trans "Category:" %} {{ category }}</h4>
|
||||
<p>{% trans "Selected criterias:" %}</p>
|
||||
<ul>
|
||||
{% for criteria in criterias %}
|
||||
{% if criteria.category == category %}
|
||||
<li>{{ criteria }}</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<p>
|
||||
<a rel="popup" class="pk-button" href="{% url 'lingo-manager-pricing-criteria-category-edit' pk=object.pk category_pk=category.pk %}">{% trans "Change criterias selection" %}</a>
|
||||
<a rel="popup" class="pk-button" href="{% url 'lingo-manager-pricing-criteria-category-delete' pk=object.pk category_pk=category.pk %}">{% trans "Remove this category" %}</a>
|
||||
</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% if object.categories.count < 3 %}
|
||||
<div class="panel--buttons">
|
||||
<a rel="popup" class="pk-button" href="{% url 'lingo-manager-pricing-criteria-category-add' pk=object.pk %}">{% trans "Add a category" %} <span class="extra-info">({% trans "max 3 categories" %})</span></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endwith %}
|
||||
</div>
|
||||
|
||||
{% if object.kind != 'basic' %}
|
||||
<div aria-labelledby="tab-pricing-options" hidden id="panel-pricing-options" role="tabpanel" tabindex="0">
|
||||
<ul>
|
||||
<li>{% trans "Minimal pricing:" %} {{ object.min_pricing|default_if_none:"" }}</li>
|
||||
</ul>
|
||||
{% if object.kind == 'effort' %}
|
||||
<ul>
|
||||
<li>{% trans "Maximal pricing:" %} {{ object.max_pricing|default_if_none:"" }}</li>
|
||||
</ul>
|
||||
{% endif %}
|
||||
<div class="panel--buttons">
|
||||
<a class="pk-button" rel="popup" href="{% url 'lingo-manager-pricing-pricingoptions-edit' object.pk %}">{% trans "Edit pricing options" %}</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if object.subscription_required %}
|
||||
<div aria-labelledby="tab-agendas" hidden id="panel-agendas" role="tabpanel" tabindex="0">
|
||||
<ul class="objects-list single-links">
|
||||
{% for agenda in agendas %}
|
||||
<li>
|
||||
<a href="{% url 'lingo-manager-agenda-detail' pk=agenda.pk %}">
|
||||
{{ agenda.label }}
|
||||
</a>
|
||||
<a class="delete" rel="popup" href="{% url 'lingo-manager-pricing-agenda-delete' object.pk agenda.pk %}">{% trans "remove"%}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<div class="panel--buttons">
|
||||
<a class="pk-button" rel="popup" href="{% url 'lingo-manager-pricing-agenda-add' object.pk %}">{% trans "Add an agenda" %}</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div aria-labelledby="tab-debug" hidden id="panel-debug" role="tabpanel" tabindex="0">
|
||||
<form method="get" enctype="multipart/form-data" action="{% url 'lingo-manager-pricing-test-tool' object.pk %}">
|
||||
{{ test_tool_form|with_template }}
|
||||
{% if not object.flat_fee_schedule %}
|
||||
<script>
|
||||
$(function() {
|
||||
var presences = {};
|
||||
var absences = {};
|
||||
{% for agenda in agendas %}
|
||||
presences['{{ agenda.pk }}'] = [];
|
||||
absences['{{ agenda.pk }}'] = [];
|
||||
{% for check_type in agenda.check_type_group.check_types.all %}
|
||||
{% if check_type.kind == "presence" %}
|
||||
presences['{{ agenda.pk }}'].push({slug: '{{ check_type.slug }}', label: '{{ check_type.label }}'});
|
||||
{% else %}
|
||||
absences['{{ agenda.pk }}'].push({slug: '{{ check_type.slug }}', label: '{{ check_type.label }}'});
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<div aria-labelledby="tab-matrix" id="panel-matrix" role="tabpanel" tabindex="0">
|
||||
{% with iter_matrix=object.iter_pricing_matrix|list %}
|
||||
{% for matrix in iter_matrix %}
|
||||
<div class="section">
|
||||
{% if matrix.criteria %}<h3>{{ matrix.criteria.label }}</h3>{% endif %}
|
||||
<table class="main pricing-matrix-{{ matrix.criteria.slug }}">
|
||||
{% if matrix.rows.0.cells.0.criteria %}
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
{% for cell in matrix.rows.0.cells %}<th scope="col">{{ cell.criteria.label }}</th>{% endfor %}
|
||||
</tr>
|
||||
</thead>
|
||||
{% endif %}
|
||||
<tbody>
|
||||
{% for row in matrix.rows %}
|
||||
<tr class="pricing-row-{{ row.criteria.slug }}">
|
||||
<th scope="row">{{ row.criteria.label }}</th>
|
||||
{% for cell in row.cells %}
|
||||
<td class="pricing-cell-{{ cell.criteria.slug }}">{% spaceless %}
|
||||
{% if object.kind == 'effort' %}
|
||||
{{ cell.value|floatformat:"4"|default_if_none:"" }}
|
||||
{% else %}
|
||||
{{ cell.value|floatformat:"2"|default_if_none:"" }}
|
||||
{% endif %}
|
||||
{% endspaceless %}</td>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
$('#id_agenda').on('change', function() {
|
||||
var agenda_id = $(this).val();
|
||||
var $select = $('#id_booking_status');
|
||||
var current_value = $select.val();
|
||||
$select.find('option').remove().end().append('<option value="presence">' + '{% trans "Presence" %}' + '</option>');
|
||||
if (presences[agenda_id]) {
|
||||
$.each(presences[agenda_id], function(index, value) {
|
||||
$select.append('<option value="presence::' + value.slug + '">' + '{% trans "Presence" %} (' + value.label + ')</option>');
|
||||
});
|
||||
}
|
||||
$select.append('<option value="absence">' + '{% trans "Absence" %}' + '</option>');
|
||||
if (absences[agenda_id]) {
|
||||
$.each(absences[agenda_id], function(index, value) {
|
||||
$select.append('<option value="absence::' + value.slug + '">' + '{% trans "Absence" %} (' + value.label + ')</option>');
|
||||
});
|
||||
}
|
||||
$select.val(current_value);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endif %}
|
||||
<div class="buttons">
|
||||
<button class="submit-button">{% trans "Compute" %}</button>
|
||||
</div>
|
||||
</form>
|
||||
{% if request.GET and test_tool_form.is_valid %}
|
||||
{% with test_tool_form.compute as pricing_data %}
|
||||
<div class="test-tool-result">
|
||||
<div class="infonotice">
|
||||
<h3>{% trans "Computed pricing data" %}</h3>
|
||||
{% if pricing_data.pricing is not None %}<p>{% trans "Pricing:" %} {{ pricing_data.pricing|stringformat:".2f" }}</p>{% endif %}
|
||||
<pre>{{ pricing_data|pprint }}</pre>
|
||||
</div>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="panel--buttons">
|
||||
<a class="pk-button" href="{% if matrix.criteria %}{% url 'lingo-manager-pricing-matrix-slug-edit' object.pk matrix.criteria.slug %}{% else %}{% url 'lingo-manager-pricing-matrix-edit' object.pk %}{% endif %}">{% trans "Edit pricing" context 'matrix' %}</a>
|
||||
</div>
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if object.flat_fee_schedule %}
|
||||
<div aria-labelledby="tab-billing-dates" hidden id="panel-billing-dates" role="tabpanel" tabindex="0">
|
||||
{% if billing_dates %}
|
||||
<ul class="objects-list single-links">
|
||||
{% for billing_date in billing_dates %}
|
||||
<li>
|
||||
<a rel="popup" href="{% url 'lingo-manager-pricing-billing-date-edit' object.pk billing_date.pk %}">
|
||||
{{ billing_date }}
|
||||
</a>
|
||||
<a class="delete" rel="popup" href="{% url 'lingo-manager-pricing-billing-date-delete' object.pk billing_date.pk %}">{% trans "remove"%}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<div class="big-msg-info">
|
||||
{% blocktrans trimmed with date_start=object.date_start|date:'d/m/Y' %}
|
||||
No billing dates. The start date of the pricing ({{ date_start }}) is used as the only available billing date.
|
||||
{% endblocktrans %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="panel--buttons">
|
||||
<a class="pk-button" rel="popup" href="{% url 'lingo-manager-pricing-billing-date-add' object.pk %}">{% trans "New billing date" %}</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% for matrix in iter_matrix %}
|
||||
<div aria-labelledby="tab-matrix-{{ matrix.criteria.slug }}" hidden="" id="panel-matrix-{{ matrix.criteria.slug }}" role="tabpanel" tabindex="0">
|
||||
<table class="main pricing-matrix-{{ matrix.criteria.slug }}">
|
||||
{% if matrix.rows.0.cells.0.criteria %}
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
{% for cell in matrix.rows.0.cells %}<th scope="col">{{ cell.criteria.label }}</th>{% endfor %}
|
||||
</tr>
|
||||
</thead>
|
||||
{% endif %}
|
||||
<tbody>
|
||||
{% for row in matrix.rows %}
|
||||
<tr class="pricing-row-{{ row.criteria.slug }}">
|
||||
<th scope="row">{{ row.criteria.label }}</th>
|
||||
{% for cell in row.cells %}
|
||||
<td class="pricing-cell-{{ cell.criteria.slug }}">{% spaceless %}
|
||||
{% if object.kind == 'effort' %}
|
||||
{{ cell.value|floatformat:"4"|default_if_none:"" }}
|
||||
{% else %}
|
||||
{{ cell.value|floatformat:"2"|default_if_none:"" }}
|
||||
{% endif %}
|
||||
{% endspaceless %}</td>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="panel--buttons">
|
||||
<a class="pk-button" href="{% if matrix.criteria %}{% url 'lingo-manager-pricing-matrix-slug-edit' object.pk matrix.criteria.slug %}{% else %}{% url 'lingo-manager-pricing-matrix-edit' object.pk %}{% endif %}">{% trans "Edit pricing" %}</a>
|
||||
</div>
|
||||
</div>
|
||||
{% empty %}
|
||||
<div aria-labelledby="tab-matrix" hidden="" id="panel-matrix" role="tabpanel" tabindex="0">
|
||||
{% empty %}
|
||||
<div class="big-msg-info">
|
||||
{% blocktrans trimmed %}
|
||||
This pricing is misconfigured.
|
||||
{% endblocktrans %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
{% endfor %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
|
||||
{% if object.kind != 'basic' %}
|
||||
<div aria-labelledby="tab-pricing-options" hidden="" id="panel-pricing-options" role="tabpanel" tabindex="0">
|
||||
<ul>
|
||||
<li>{% trans "Minimal pricing:" %} {{ object.min_pricing|default_if_none:"" }}</li>
|
||||
</ul>
|
||||
{% if object.kind == 'effort' %}
|
||||
<ul>
|
||||
<li>{% trans "Maximal pricing:" %} {{ object.max_pricing|default_if_none:"" }}</li>
|
||||
</ul>
|
||||
{% endif %}
|
||||
<div class="panel--buttons">
|
||||
<a class="pk-button" rel="popup" href="{% url 'lingo-manager-pricing-pricingoptions-edit' object.pk %}">{% trans "Edit pricing options" %}</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endwith %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar %}
|
||||
<aside id="sidebar">
|
||||
|
||||
<h3>{% trans "Actions" %}</h3>
|
||||
<a class="button button-paragraph" rel="popup" href="{% url 'lingo-manager-pricing-edit' object.pk %}">{% trans 'Options' %}</a>
|
||||
<a class="button button-paragraph" href="{% url 'lingo-manager-pricing-export' pk=object.pk %}">{% trans 'Export' %}</a>
|
||||
|
||||
{% url 'lingo-manager-pricing-list' as object_list_url %}
|
||||
{% include 'lingo/includes/application_detail_fragment.html' %}
|
||||
<a class="button button-paragraph" href="{% url 'lingo-manager-pricing-parameters' object.pk %}">{% trans 'Parameters' %}</a>
|
||||
|
||||
</aside>
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends "lingo/pricing/manager_pricing_detail.html" %}
|
||||
{% extends "lingo/pricing/manager_pricing_parameters.html" %}
|
||||
{% load gadjo i18n %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
|
@ -16,7 +16,7 @@
|
|||
{{ form|with_template }}
|
||||
<div class="buttons">
|
||||
<button class="submit-button">{% trans "Duplicate" %}</button>
|
||||
<a class="cancel" href="{% url 'lingo-manager-pricing-detail' object.pk %}">{% trans 'Cancel' %}</a>
|
||||
<a class="cancel" href="{% url 'lingo-manager-pricing-parameters' object.pk %}">{% trans 'Cancel' %}</a>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
{{ block.super }}
|
||||
{% if form.instance.pk %}
|
||||
<a href="{% url 'lingo-manager-pricing-detail' object.pk %}">{{ object }}</a>
|
||||
<a href="{% url 'lingo-manager-pricing-edit' object.pk %}">{% trans "Edit" %}</a>
|
||||
<a href="{% url 'lingo-manager-pricing-parameters' object.pk %}">{% trans "Parameters" %}</a>
|
||||
<a href="{% url 'lingo-manager-pricing-edit' object.pk %}">{% trans "Options" %}</a>
|
||||
{% else %}
|
||||
<a href="{% url 'lingo-manager-pricing-add' %}">{% trans "New pricing" %}</a>
|
||||
{% endif %}
|
||||
|
@ -38,7 +39,7 @@
|
|||
<div class="buttons">
|
||||
<button class="submit-button">{% trans "Save" %}</button>
|
||||
{% if object.pk %}
|
||||
<a class="cancel" href="{% url 'lingo-manager-pricing-detail' object.pk %}">{% trans 'Cancel' %}</a>
|
||||
<a class="cancel" href="{% url 'lingo-manager-pricing-parameters' object.pk %}">{% trans 'Cancel' %}</a>
|
||||
{% else %}
|
||||
<a class="cancel" href="{% url 'lingo-manager-pricing-list' %}">{% trans 'Cancel' %}</a>
|
||||
{% endif %}
|
||||
|
|
|
@ -56,3 +56,6 @@
|
|||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -0,0 +1,225 @@
|
|||
{% extends "lingo/pricing/manager_pricing_detail.html" %}
|
||||
{% load gadjo i18n %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
{{ block.super }}
|
||||
<a href="{% url 'lingo-manager-pricing-parameters' object.pk %}">{% trans "Parameters" %}</a>
|
||||
{% endblock %}
|
||||
|
||||
{% block appbar %}
|
||||
<h2>
|
||||
{{ object }}
|
||||
<span class="identifier">[{% trans "identifier:" %} {{ object.slug }}]</span>
|
||||
</h2>
|
||||
<span class="actions">
|
||||
<a class="extra-actions-menu-opener"></a>
|
||||
<ul class="extra-actions-menu">
|
||||
<li><a rel="popup" class="action-duplicate" href="{% url 'lingo-manager-pricing-duplicate' pk=object.pk %}">{% trans 'Duplicate' %}</a></li>
|
||||
<li><a rel="popup" href="{% url 'lingo-manager-pricing-delete' object.pk %}">{% trans 'Delete' %}</a></li>
|
||||
</ul>
|
||||
</span>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% with agendas=object.agendas.all %}
|
||||
<div class="section">
|
||||
<div class="pk-tabs">
|
||||
<div class="pk-tabs--tab-list" role="tablist">
|
||||
<button aria-controls="panel-options" aria-selected="true" id="tab-options" role="tab" tabindex="0">{% trans "Options" %}</button>
|
||||
<button aria-controls="panel-variables" aria-selected="false" id="tab-variables" role="tab" tabindex="-1">{% trans "Variables" %}</button>
|
||||
<button aria-controls="panel-criterias" aria-selected="false" id="tab-criterias" role="tab" tabindex="-1">{% trans "Criterias" %}</button>
|
||||
{% if object.subscription_required %}
|
||||
<button aria-controls="panel-agendas" aria-selected="false" id="tab-agendas" role="tab" tabindex="-1">{% trans "Agendas" %}</button>
|
||||
{% endif %}
|
||||
<button aria-controls="panel-debug" aria-selected="false" id="tab-debug" role="tab" tabindex="-1">{% trans "Test tool" %}</button>
|
||||
{% if object.flat_fee_schedule %}
|
||||
<button aria-controls="panel-billing-dates" aria-selected="false" id="tab-billing-dates" role="tab" tabindex="-1">{% trans "Billing dates" %}</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="pk-tabs--container">
|
||||
|
||||
<div aria-labelledby="tab-options" id="panel-options" role="tabpanel" tabindex="0">
|
||||
<ul>
|
||||
<li>{% blocktrans trimmed with start=object.date_start|date:'d/m/Y' end=object.date_end|date:'d/m/Y' %}From {{ start }} to {{ end }}{% endblocktrans %}</li>
|
||||
<li>{% trans "Flat fee schedule:" %} {{ object.flat_fee_schedule|yesno }}</li>
|
||||
{% if object.flat_fee_schedule %}
|
||||
<li>{% trans "Subscription required:" %} {{ object.subscription_required|yesno }}</li>
|
||||
{% endif %}
|
||||
<li>{% trans "Kind of pricing:"%} {{ object.get_kind_display }}</li>
|
||||
{% if object.kind == 'reduction' %}
|
||||
<li>{% trans "Reduction rate (template):" %} <pre>{{ object.reduction_rate }}</pre></li>
|
||||
{% elif object.kind == 'effort' %}
|
||||
<li>{% trans "Pricing to be multiplied by the effort rate (template):" %} <pre>{{ object.effort_rate_target }}</pre></li>
|
||||
{% endif %}
|
||||
<li>{% trans "Accounting code (template):" %} <pre>{{ object.accounting_code }}</pre></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div aria-labelledby="tab-variables" hidden="" id="panel-variables" role="tabpanel" tabindex="0">
|
||||
{% if object.extra_variables %}
|
||||
<label>{% trans 'Extra variables:' %}</label>
|
||||
<dl>
|
||||
{% for key in object.get_extra_variables_keys %}
|
||||
<dt><b>{% blocktrans %}{{ key }}:{% endblocktrans %}</b></dt>
|
||||
<dd><pre>{{ object.extra_variables|get:key }}</pre></dd>
|
||||
{% endfor %}
|
||||
</dl>
|
||||
{% endif %}
|
||||
<div class="panel--buttons">
|
||||
<a class="pk-button" rel="popup" href="{% url 'lingo-manager-pricing-variable-edit' pk=object.pk %}">{% trans 'Define variables' %}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div aria-labelledby="tab-criterias" hidden="" id="panel-criterias" role="tabpanel" tabindex="0">
|
||||
{% with criterias=object.criterias.all categories=object.categories.all %}
|
||||
{% if categories %}
|
||||
<div>
|
||||
{% blocktrans trimmed %}Use drag and drop with the ⣿ handles to reorder categories.{% endblocktrans %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="sortable" data-order-url="{% url 'lingo-manager-pricing-criteria-category-order' object.pk %}">
|
||||
{% for category in categories %}
|
||||
<div class="paragraph sortable-item" data-item-id="{{ category.pk }}">
|
||||
<h4><span class="handle">⣿</span>{% trans "Category:" %} {{ category }}</h4>
|
||||
<p>{% trans "Selected criterias:" %}</p>
|
||||
<ul>
|
||||
{% for criteria in criterias %}
|
||||
{% if criteria.category == category %}
|
||||
<li>{{ criteria }}</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<p>
|
||||
<a rel="popup" class="pk-button" href="{% url 'lingo-manager-pricing-criteria-category-edit' pk=object.pk category_pk=category.pk %}">{% trans "Change criterias selection" %}</a>
|
||||
<a rel="popup" class="pk-button" href="{% url 'lingo-manager-pricing-criteria-category-delete' pk=object.pk category_pk=category.pk %}">{% trans "Remove this category" %}</a>
|
||||
</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% if object.categories.count < 3 %}
|
||||
<div class="panel--buttons">
|
||||
<a rel="popup" class="pk-button" href="{% url 'lingo-manager-pricing-criteria-category-add' pk=object.pk %}">{% trans "Add a category" %} <span class="extra-info">({% trans "max 3 categories" %})</span></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endwith %}
|
||||
</div>
|
||||
|
||||
{% if object.subscription_required %}
|
||||
<div aria-labelledby="tab-agendas" hidden id="panel-agendas" role="tabpanel" tabindex="0">
|
||||
<ul class="objects-list single-links">
|
||||
{% for agenda in agendas %}
|
||||
<li>
|
||||
<a href="{% url 'lingo-manager-agenda-detail' pk=agenda.pk %}">
|
||||
{{ agenda.label }}
|
||||
</a>
|
||||
<a class="delete" rel="popup" href="{% url 'lingo-manager-pricing-agenda-delete' object.pk agenda.pk %}">{% trans "remove"%}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<div class="panel--buttons">
|
||||
<a class="pk-button" rel="popup" href="{% url 'lingo-manager-pricing-agenda-add' object.pk %}">{% trans "Add an agenda" %}</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div aria-labelledby="tab-debug" hidden id="panel-debug" role="tabpanel" tabindex="0">
|
||||
<form method="get" enctype="multipart/form-data" action="{% url 'lingo-manager-pricing-test-tool' object.pk %}">
|
||||
{{ test_tool_form|with_template }}
|
||||
{% if not object.flat_fee_schedule %}
|
||||
<script>
|
||||
$(function() {
|
||||
var presences = {};
|
||||
var absences = {};
|
||||
{% for agenda in agendas %}
|
||||
presences['{{ agenda.pk }}'] = [];
|
||||
absences['{{ agenda.pk }}'] = [];
|
||||
{% for check_type in agenda.check_type_group.check_types.all %}
|
||||
{% if check_type.kind == "presence" %}
|
||||
presences['{{ agenda.pk }}'].push({slug: '{{ check_type.slug }}', label: '{{ check_type.label }}'});
|
||||
{% else %}
|
||||
absences['{{ agenda.pk }}'].push({slug: '{{ check_type.slug }}', label: '{{ check_type.label }}'});
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
$('#id_agenda').on('change', function() {
|
||||
var agenda_id = $(this).val();
|
||||
var $select = $('#id_booking_status');
|
||||
var current_value = $select.val();
|
||||
$select.find('option').remove().end().append('<option value="presence">' + '{% trans "Presence" %}' + '</option>');
|
||||
if (presences[agenda_id]) {
|
||||
$.each(presences[agenda_id], function(index, value) {
|
||||
$select.append('<option value="presence::' + value.slug + '">' + '{% trans "Presence" %} (' + value.label + ')</option>');
|
||||
});
|
||||
}
|
||||
$select.append('<option value="absence">' + '{% trans "Absence" %}' + '</option>');
|
||||
if (absences[agenda_id]) {
|
||||
$.each(absences[agenda_id], function(index, value) {
|
||||
$select.append('<option value="absence::' + value.slug + '">' + '{% trans "Absence" %} (' + value.label + ')</option>');
|
||||
});
|
||||
}
|
||||
$select.val(current_value);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endif %}
|
||||
<div class="buttons">
|
||||
<button class="submit-button">{% trans "Compute" %}</button>
|
||||
</div>
|
||||
</form>
|
||||
{% if request.GET and test_tool_form.is_valid %}
|
||||
{% with test_tool_form.compute as pricing_data %}
|
||||
<div class="test-tool-result">
|
||||
<div class="infonotice">
|
||||
<h3>{% trans "Computed pricing data" %}</h3>
|
||||
{% if pricing_data.pricing is not None %}<p>{% trans "Pricing:" %} {{ pricing_data.pricing|stringformat:".2f" }}</p>{% endif %}
|
||||
<pre>{{ pricing_data|pprint }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if object.flat_fee_schedule %}
|
||||
<div aria-labelledby="tab-billing-dates" hidden id="panel-billing-dates" role="tabpanel" tabindex="0">
|
||||
{% if billing_dates %}
|
||||
<ul class="objects-list single-links">
|
||||
{% for billing_date in billing_dates %}
|
||||
<li>
|
||||
<a rel="popup" href="{% url 'lingo-manager-pricing-billing-date-edit' object.pk billing_date.pk %}">
|
||||
{{ billing_date }}
|
||||
</a>
|
||||
<a class="delete" rel="popup" href="{% url 'lingo-manager-pricing-billing-date-delete' object.pk billing_date.pk %}">{% trans "remove"%}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<div class="big-msg-info">
|
||||
{% blocktrans trimmed with date_start=object.date_start|date:'d/m/Y' %}
|
||||
No billing dates. The start date of the pricing ({{ date_start }}) is used as the only available billing date.
|
||||
{% endblocktrans %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="panel--buttons">
|
||||
<a class="pk-button" rel="popup" href="{% url 'lingo-manager-pricing-billing-date-add' object.pk %}">{% trans "New billing date" %}</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endwith %}
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar %}
|
||||
<aside id="sidebar">
|
||||
|
||||
<h3>{% trans "Actions" %}</h3>
|
||||
<a class="button button-paragraph" rel="popup" href="{% url 'lingo-manager-pricing-edit' object.pk %}">{% trans 'Options' %}</a>
|
||||
<a class="button button-paragraph" href="{% url 'lingo-manager-pricing-export' pk=object.pk %}">{% trans 'Export' %}</a>
|
||||
|
||||
{% url 'lingo-manager-pricing-list' as object_list_url %}
|
||||
{% include 'lingo/includes/application_detail_fragment.html' %}
|
||||
|
||||
</aside>
|
||||
{% endblock %}
|
|
@ -1,4 +1,4 @@
|
|||
{% extends "lingo/pricing/manager_pricing_detail.html" %}
|
||||
{% extends "lingo/pricing/manager_pricing_parameters.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
|
@ -38,7 +38,10 @@
|
|||
<button id="add-pricing-variable-form" type="button">{% trans "Add another variable" %}</button>
|
||||
<div class="buttons">
|
||||
<button class="submit-button">{% trans "Save" %}</button>
|
||||
<a class="cancel" href="{% url 'lingo-manager-pricing-detail' object.pk %}">{% trans 'Cancel' %}</a>
|
||||
<a class="cancel" href="{% url 'lingo-manager-pricing-parameters' object.pk %}">{% trans 'Cancel' %}</a>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -116,6 +116,11 @@ urlpatterns = [
|
|||
views.pricing_detail,
|
||||
name='lingo-manager-pricing-detail',
|
||||
),
|
||||
path(
|
||||
'<int:pk>/parameters/',
|
||||
views.pricing_parameters,
|
||||
name='lingo-manager-pricing-parameters',
|
||||
),
|
||||
path(
|
||||
'<int:pk>/edit/',
|
||||
views.pricing_edit,
|
||||
|
|
|
@ -536,10 +536,29 @@ class PricingDetailView(DetailView):
|
|||
pricing_detail = PricingDetailView.as_view()
|
||||
|
||||
|
||||
class PricingParametersView(DetailView):
|
||||
model = Pricing
|
||||
template_name = 'lingo/pricing/manager_pricing_parameters.html'
|
||||
|
||||
def get_queryset(self):
|
||||
return Pricing.objects.all().prefetch_related('criterias__category')
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
form = PricingTestToolForm(pricing=self.object, request=self.request, data=self.request.GET or None)
|
||||
if self.request.GET:
|
||||
form.is_valid()
|
||||
kwargs['test_tool_form'] = form
|
||||
kwargs['billing_dates'] = self.object.billingdates.order_by('date_start')
|
||||
return super().get_context_data(**kwargs)
|
||||
|
||||
|
||||
pricing_parameters = PricingParametersView.as_view()
|
||||
|
||||
|
||||
class PricingTestToolView(RedirectView):
|
||||
def get_redirect_url(self, *args, **kwargs):
|
||||
return '%s?%s#open:debug' % (
|
||||
reverse('lingo-manager-pricing-detail', args=[kwargs['pk']]),
|
||||
reverse('lingo-manager-pricing-parameters', args=[kwargs['pk']]),
|
||||
self.request.GET.urlencode(),
|
||||
)
|
||||
|
||||
|
@ -553,7 +572,7 @@ class PricingEditView(UpdateView):
|
|||
form_class = PricingForm
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse('lingo-manager-pricing-detail', args=[self.object.pk])
|
||||
return reverse('lingo-manager-pricing-parameters', args=[self.object.pk])
|
||||
|
||||
|
||||
pricing_edit = PricingEditView.as_view()
|
||||
|
@ -588,7 +607,7 @@ class PricingVariableEdit(FormView):
|
|||
return HttpResponseRedirect(self.get_success_url())
|
||||
|
||||
def get_success_url(self):
|
||||
return '%s#open:variables' % reverse('lingo-manager-pricing-detail', args=[self.object.pk])
|
||||
return '%s#open:variables' % reverse('lingo-manager-pricing-parameters', args=[self.object.pk])
|
||||
|
||||
|
||||
pricing_variable_edit = PricingVariableEdit.as_view()
|
||||
|
@ -619,7 +638,7 @@ class PricingCriteriaCategoryAddView(FormView):
|
|||
return super().form_valid(form)
|
||||
|
||||
def get_success_url(self):
|
||||
return '%s#open:criterias' % reverse('lingo-manager-pricing-detail', args=[self.object.pk])
|
||||
return '%s#open:criterias' % reverse('lingo-manager-pricing-parameters', args=[self.object.pk])
|
||||
|
||||
|
||||
pricing_criteria_category_add = PricingCriteriaCategoryAddView.as_view()
|
||||
|
@ -655,7 +674,7 @@ class PricingCriteriaCategoryEditView(FormView):
|
|||
return super().form_valid(form)
|
||||
|
||||
def get_success_url(self):
|
||||
return '%s#open:criterias' % reverse('lingo-manager-pricing-detail', args=[self.object.pk])
|
||||
return '%s#open:criterias' % reverse('lingo-manager-pricing-parameters', args=[self.object.pk])
|
||||
|
||||
|
||||
pricing_criteria_category_edit = PricingCriteriaCategoryEditView.as_view()
|
||||
|
@ -680,7 +699,7 @@ class PricingCriteriaCategoryDeleteView(DeleteView):
|
|||
return HttpResponseRedirect(self.get_success_url())
|
||||
|
||||
def get_success_url(self):
|
||||
return '%s#open:criterias' % reverse('lingo-manager-pricing-detail', args=[self.pricing.pk])
|
||||
return '%s#open:criterias' % reverse('lingo-manager-pricing-parameters', args=[self.pricing.pk])
|
||||
|
||||
|
||||
pricing_criteria_category_delete = PricingCriteriaCategoryDeleteView.as_view()
|
||||
|
@ -798,7 +817,7 @@ class PricingAgendaAddView(FormView):
|
|||
return super().form_valid(form)
|
||||
|
||||
def get_success_url(self):
|
||||
return '%s#open:agendas' % reverse('lingo-manager-pricing-detail', args=[self.object.pk])
|
||||
return '%s#open:agendas' % reverse('lingo-manager-pricing-parameters', args=[self.object.pk])
|
||||
|
||||
|
||||
pricing_agenda_add = PricingAgendaAddView.as_view()
|
||||
|
@ -822,7 +841,7 @@ class PricingAgendaDeleteView(DeleteView):
|
|||
return HttpResponseRedirect(self.get_success_url())
|
||||
|
||||
def get_success_url(self):
|
||||
return '%s#open:agendas' % reverse('lingo-manager-pricing-detail', args=[self.pricing.pk])
|
||||
return '%s#open:agendas' % reverse('lingo-manager-pricing-parameters', args=[self.pricing.pk])
|
||||
|
||||
|
||||
pricing_agenda_delete = PricingAgendaDeleteView.as_view()
|
||||
|
@ -851,7 +870,7 @@ class PricingBillingDateAddView(FormView):
|
|||
return super().form_valid(form)
|
||||
|
||||
def get_success_url(self):
|
||||
return '%s#open:billing-dates' % reverse('lingo-manager-pricing-detail', args=[self.object.pk])
|
||||
return '%s#open:billing-dates' % reverse('lingo-manager-pricing-parameters', args=[self.object.pk])
|
||||
|
||||
|
||||
pricing_billing_date_add = PricingBillingDateAddView.as_view()
|
||||
|
@ -881,7 +900,7 @@ class PricingBillingDateEditView(FormView):
|
|||
return super().form_valid(form)
|
||||
|
||||
def get_success_url(self):
|
||||
return '%s#open:billing-dates' % reverse('lingo-manager-pricing-detail', args=[self.pricing.pk])
|
||||
return '%s#open:billing-dates' % reverse('lingo-manager-pricing-parameters', args=[self.pricing.pk])
|
||||
|
||||
|
||||
pricing_billing_date_edit = PricingBillingDateEditView.as_view()
|
||||
|
@ -904,7 +923,7 @@ class PricingBillingDateDeleteView(DeleteView):
|
|||
return HttpResponseRedirect(self.get_success_url())
|
||||
|
||||
def get_success_url(self):
|
||||
return '%s#open:billing-dates' % reverse('lingo-manager-pricing-detail', args=[self.pricing.pk])
|
||||
return '%s#open:billing-dates' % reverse('lingo-manager-pricing-parameters', args=[self.pricing.pk])
|
||||
|
||||
|
||||
pricing_billing_date_delete = PricingBillingDateDeleteView.as_view()
|
||||
|
@ -983,10 +1002,7 @@ class PricingMatrixEdit(FormView):
|
|||
return self.form_invalid(form)
|
||||
|
||||
def get_success_url(self):
|
||||
return '%s#open:matrix-%s' % (
|
||||
reverse('lingo-manager-pricing-detail', args=[self.object.pk]),
|
||||
self.kwargs.get('slug') or '',
|
||||
)
|
||||
return '%s#open:matrix' % (reverse('lingo-manager-pricing-detail', args=[self.object.pk]),)
|
||||
|
||||
|
||||
pricing_matrix_edit = PricingMatrixEdit.as_view()
|
||||
|
|
|
@ -73,6 +73,7 @@ def test_edit_pricing(app, admin_user):
|
|||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/%s/' % pricing.pk)
|
||||
resp = resp.click(href='/manage/pricing/%s/parameters/' % pricing.pk)
|
||||
resp = resp.click(href='/manage/pricing/%s/edit/' % pricing.pk)
|
||||
assert resp.form['date_start'].value == '2021-09-01'
|
||||
resp.form['label'] = 'Foo Baz'
|
||||
|
@ -88,7 +89,7 @@ def test_edit_pricing(app, admin_user):
|
|||
resp.form['date_start'] = '2021-08-01'
|
||||
resp.form['date_end'] = '2022-09-01'
|
||||
resp = resp.form.submit()
|
||||
assert resp.location.endswith('/manage/pricing/%s/' % pricing.pk)
|
||||
assert resp.location.endswith('/manage/pricing/%s/parameters/' % pricing.pk)
|
||||
pricing.refresh_from_db()
|
||||
assert pricing.slug == 'foo-bazz'
|
||||
assert pricing.date_start == datetime.date(2021, 8, 1)
|
||||
|
@ -127,7 +128,7 @@ def test_edit_pricing(app, admin_user):
|
|||
]
|
||||
resp.form['effort_rate_target'] = 'foo'
|
||||
resp = resp.form.submit()
|
||||
assert resp.location.endswith('/manage/pricing/%s/' % pricing.pk)
|
||||
assert resp.location.endswith('/manage/pricing/%s/parameters/' % pricing.pk)
|
||||
pricing.refresh_from_db()
|
||||
assert pricing.kind == 'effort'
|
||||
assert pricing.reduction_rate == ''
|
||||
|
@ -148,7 +149,7 @@ def test_edit_pricing(app, admin_user):
|
|||
pricing.save()
|
||||
resp = app.get('/manage/pricing/%s/edit/' % pricing.pk)
|
||||
resp = resp.form.submit()
|
||||
assert resp.location.endswith('/manage/pricing/%s/' % pricing.pk)
|
||||
assert resp.location.endswith('/manage/pricing/%s/parameters/' % pricing.pk)
|
||||
|
||||
pricing.flat_fee_schedule = True
|
||||
pricing.save()
|
||||
|
@ -457,7 +458,7 @@ def test_delete_pricing(app, admin_user):
|
|||
app = login(app)
|
||||
app.get('/manage/pricing/%s/delete/' % 0, status=404)
|
||||
|
||||
resp = app.get('/manage/pricing/%s/' % pricing.pk)
|
||||
resp = app.get('/manage/pricing/%s/parameters/' % pricing.pk)
|
||||
resp = resp.click(href='/manage/pricing/%s/delete/' % pricing.pk)
|
||||
resp = resp.form.submit()
|
||||
assert resp.location.endswith('/manage/pricing/')
|
||||
|
@ -473,7 +474,7 @@ def test_duplicate_pricing(app, admin_user):
|
|||
assert Pricing.objects.count() == 1
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/%s/' % pricing.pk)
|
||||
resp = app.get('/manage/pricing/%s/parameters/' % pricing.pk)
|
||||
resp = resp.click(href='/manage/pricing/%s/duplicate/' % pricing.pk)
|
||||
resp = resp.form.submit()
|
||||
assert Pricing.objects.count() == 2
|
||||
|
@ -485,6 +486,7 @@ def test_duplicate_pricing(app, admin_user):
|
|||
resp = resp.follow()
|
||||
assert 'copy-of-a-pricing' in resp.text
|
||||
|
||||
resp = resp.click(href='/manage/pricing/%s/parameters/' % new_pricing.pk)
|
||||
resp = resp.click(href='/manage/pricing/%s/duplicate/' % new_pricing.pk)
|
||||
resp.form['label'] = 'hop'
|
||||
resp.form['date_start'] = '2022-09-01'
|
||||
|
@ -506,7 +508,7 @@ def test_pricing_edit_extra_variables(app, admin_user):
|
|||
assert pricing.extra_variables == {}
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/%s/' % pricing.pk)
|
||||
resp = app.get('/manage/pricing/%s/parameters/' % pricing.pk)
|
||||
assert '<label>Extra variables:</label>' not in resp.text
|
||||
resp = resp.click(href='/manage/pricing/%s/variable/' % pricing.pk)
|
||||
resp.form['form-0-key'] = 'foo'
|
||||
|
@ -570,7 +572,7 @@ 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 = app.get('/manage/pricing/%s/parameters/' % pricing.pk)
|
||||
resp = resp.click(href='/manage/pricing/%s/category/add/' % pricing.pk)
|
||||
assert list(resp.context['form'].fields['category'].queryset) == [
|
||||
category1,
|
||||
|
@ -580,7 +582,7 @@ def test_pricing_add_category(app, admin_user):
|
|||
]
|
||||
resp.form['category'] = category1.pk
|
||||
resp = resp.form.submit()
|
||||
assert resp.location.endswith('/manage/pricing/%s/#open:criterias' % pricing.pk)
|
||||
assert resp.location.endswith('/manage/pricing/%s/parameters/#open:criterias' % pricing.pk)
|
||||
resp = resp.follow()
|
||||
assert '/manage/pricing/%s/category/add/' % pricing.pk in resp
|
||||
assert list(
|
||||
|
@ -636,7 +638,7 @@ 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 = app.get('/manage/pricing/%s/parameters/' % pricing.pk)
|
||||
resp = resp.click(href='/manage/pricing/%s/category/%s/edit/' % (pricing.pk, category1.pk))
|
||||
assert list(resp.context['form'].fields['criterias'].queryset) == [
|
||||
criteria1,
|
||||
|
@ -647,7 +649,7 @@ 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/#open:criterias' % pricing.pk)
|
||||
assert resp.location.endswith('/manage/pricing/%s/parameters/#open:criterias' % pricing.pk)
|
||||
resp = resp.follow()
|
||||
assert list(pricing.criterias.order_by('pk')) == [criteria1, criteria3]
|
||||
|
||||
|
@ -680,10 +682,10 @@ 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 = app.get('/manage/pricing/%s/parameters/' % pricing.pk)
|
||||
resp = resp.click(href='/manage/pricing/%s/category/%s/delete/' % (pricing.pk, category1.pk))
|
||||
resp = resp.form.submit()
|
||||
assert resp.location.endswith('/manage/pricing/%s/#open:criterias' % pricing.pk)
|
||||
assert resp.location.endswith('/manage/pricing/%s/parameters/#open:criterias' % pricing.pk)
|
||||
resp = resp.follow()
|
||||
assert list(pricing.categories.all()) == [category2]
|
||||
assert list(pricing.criterias.all()) == [criteria2]
|
||||
|
@ -777,7 +779,7 @@ def test_pricing_add_agenda(app, admin_user):
|
|||
agenda3 = Agenda.objects.create(label='Foo bar 3')
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/%s/' % pricing.pk)
|
||||
resp = app.get('/manage/pricing/%s/parameters/' % pricing.pk)
|
||||
resp = resp.click(href='/manage/pricing/%s/agenda/add/' % pricing.pk)
|
||||
assert list(resp.context['form'].fields['agenda'].queryset) == [
|
||||
agenda1,
|
||||
|
@ -786,7 +788,7 @@ def test_pricing_add_agenda(app, admin_user):
|
|||
]
|
||||
resp.form['agenda'] = agenda1.pk
|
||||
resp = resp.form.submit()
|
||||
assert resp.location.endswith('/manage/pricing/%s/#open:agendas' % pricing.pk)
|
||||
assert resp.location.endswith('/manage/pricing/%s/parameters/#open:agendas' % pricing.pk)
|
||||
resp = resp.follow()
|
||||
assert list(pricing.agendas.all()) == [agenda1]
|
||||
|
||||
|
@ -847,10 +849,10 @@ def test_pricing_delete_agenda(app, admin_user):
|
|||
pricing.agendas.add(agenda1, agenda2)
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/%s/' % pricing.pk)
|
||||
resp = app.get('/manage/pricing/%s/parameters/' % pricing.pk)
|
||||
resp = resp.click(href='/manage/pricing/%s/agenda/%s/delete/' % (pricing.pk, agenda1.pk))
|
||||
resp = resp.form.submit()
|
||||
assert resp.location.endswith('/manage/pricing/%s/#open:agendas' % pricing.pk)
|
||||
assert resp.location.endswith('/manage/pricing/%s/parameters/#open:agendas' % pricing.pk)
|
||||
resp = resp.follow()
|
||||
assert list(pricing.agendas.all()) == [agenda2]
|
||||
|
||||
|
@ -873,7 +875,7 @@ def test_pricing_add_billing_date(app, admin_user):
|
|||
)
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/%s/' % pricing.pk)
|
||||
resp = app.get('/manage/pricing/%s/parameters/' % pricing.pk)
|
||||
resp = resp.click(href='/manage/pricing/%s/billing-date/add/' % pricing.pk)
|
||||
resp.form['date_start'] = '2021-08-31'
|
||||
resp.form['label'] = 'Foo'
|
||||
|
@ -888,7 +890,7 @@ def test_pricing_add_billing_date(app, admin_user):
|
|||
]
|
||||
resp.form['date_start'] = '2022-08-31'
|
||||
resp = resp.form.submit()
|
||||
assert resp.location.endswith('/manage/pricing/%s/#open:billing-dates' % pricing.pk)
|
||||
assert resp.location.endswith('/manage/pricing/%s/parameters/#open:billing-dates' % pricing.pk)
|
||||
|
||||
assert pricing.billingdates.count() == 1
|
||||
billing_date = BillingDate.objects.latest('pk')
|
||||
|
@ -913,7 +915,7 @@ def test_pricing_edit_billing_date(app, admin_user):
|
|||
)
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/%s/' % pricing.pk)
|
||||
resp = app.get('/manage/pricing/%s/parameters/' % pricing.pk)
|
||||
resp = resp.click(href=r'/manage/pricing/%s/billing-date/%s/$' % (pricing.pk, billing_date.pk))
|
||||
resp.form['label'] = 'Bar'
|
||||
resp = resp.form.submit()
|
||||
|
@ -927,7 +929,7 @@ def test_pricing_edit_billing_date(app, admin_user):
|
|||
]
|
||||
resp.form['date_start'] = '2022-08-31'
|
||||
resp = resp.form.submit()
|
||||
assert resp.location.endswith('/manage/pricing/%s/#open:billing-dates' % pricing.pk)
|
||||
assert resp.location.endswith('/manage/pricing/%s/parameters/#open:billing-dates' % pricing.pk)
|
||||
|
||||
assert pricing.billingdates.count() == 1
|
||||
billing_date.refresh_from_db()
|
||||
|
@ -959,10 +961,10 @@ def test_pricing_delete_billing_date(app, admin_user):
|
|||
)
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/%s/' % pricing.pk)
|
||||
resp = app.get('/manage/pricing/%s/parameters/' % pricing.pk)
|
||||
resp = resp.click(href='/manage/pricing/%s/billing-date/%s/delete' % (pricing.pk, billing_date1.pk))
|
||||
resp = resp.form.submit()
|
||||
assert resp.location.endswith('/manage/pricing/%s/#open:billing-dates' % pricing.pk)
|
||||
assert resp.location.endswith('/manage/pricing/%s/parameters/#open:billing-dates' % pricing.pk)
|
||||
|
||||
assert pricing.billingdates.count() == 1
|
||||
|
||||
|
@ -1028,7 +1030,7 @@ def test_detail_pricing_3_categories(app, admin_user):
|
|||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/%s/' % pricing.pk)
|
||||
assert '>Pricings - Crit 1-1</button>' in resp
|
||||
assert '<h3>Crit 1-1</h3>' in resp
|
||||
ths = resp.pyquery.find('table.pricing-matrix-crit-1-1 thead th')
|
||||
assert len(ths) == 4
|
||||
assert ths[0].text is None
|
||||
|
@ -1069,7 +1071,7 @@ def test_detail_pricing_3_categories(app, admin_user):
|
|||
].text
|
||||
== '132.00'
|
||||
)
|
||||
assert '>Pricings - Crit 1-2</button>' in resp
|
||||
assert '<h3>Crit 1-2</h3>' in resp
|
||||
ths = resp.pyquery.find('table.pricing-matrix-crit-1-2 thead th')
|
||||
assert len(ths) == 4
|
||||
assert ths[0].text is None
|
||||
|
@ -1215,7 +1217,7 @@ def test_detail_pricing_test_tool_for_event(mock_pricing_data_event, mock_event,
|
|||
pricing.agendas.add(agenda)
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/%s/' % pricing.pk)
|
||||
resp = app.get('/manage/pricing/%s/parameters/' % pricing.pk)
|
||||
assert 'billing_date' not in resp.context['test_tool_form'].fields
|
||||
assert 'Computed pricing data' not in resp
|
||||
|
||||
|
@ -1311,7 +1313,7 @@ def test_detail_pricing_test_tool_for_event_event_error(mock_event, app, admin_u
|
|||
mock_event.side_effect = ChronoError('foo bar foo-event')
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/%s/' % pricing.pk)
|
||||
resp = app.get('/manage/pricing/%s/parameters/' % pricing.pk)
|
||||
resp.form['agenda'] = agenda.pk
|
||||
resp.form['event_slug'] = 'foo-event'
|
||||
resp.form['user_external_id'] = 'user:1'
|
||||
|
@ -1337,7 +1339,7 @@ def test_detail_pricing_test_tool_for_event_booking_status(
|
|||
mock_event.return_value = {'start_datetime': '2021-09-01T12:00:00+02:00'}
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/%s/' % pricing.pk)
|
||||
resp = app.get('/manage/pricing/%s/parameters/' % pricing.pk)
|
||||
assert resp.form['booking_status'].options == [
|
||||
('presence', False, 'Presence'),
|
||||
('absence', False, 'Absence'),
|
||||
|
@ -1349,7 +1351,7 @@ def test_detail_pricing_test_tool_for_event_booking_status(
|
|||
agenda.check_type_group = group
|
||||
agenda.save()
|
||||
|
||||
resp = app.get('/manage/pricing/%s/' % pricing.pk)
|
||||
resp = app.get('/manage/pricing/%s/parameters/' % pricing.pk)
|
||||
assert resp.form['booking_status'].options == [
|
||||
('presence', False, 'Presence'),
|
||||
('absence', False, 'Absence'),
|
||||
|
@ -1409,7 +1411,7 @@ def test_detail_pricing_test_tool_for_flat_fee_schedule(mock_pricing_data, app,
|
|||
pricing.agendas.add(agenda)
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pricing/%s/' % pricing.pk)
|
||||
resp = app.get('/manage/pricing/%s/parameters/' % pricing.pk)
|
||||
assert 'event_slug' not in resp.context['test_tool_form'].fields
|
||||
assert 'booking_status' not in resp.context['test_tool_form'].fields
|
||||
assert 'billing_date' not in resp.context['test_tool_form'].fields
|
||||
|
@ -1464,7 +1466,7 @@ def test_detail_pricing_test_tool_for_flat_fee_schedule(mock_pricing_data, app,
|
|||
|
||||
# check with billing dates
|
||||
mock_pricing_data.reset_mock()
|
||||
resp = app.get('/manage/pricing/%s/' % pricing.pk)
|
||||
resp = app.get('/manage/pricing/%s/parameters/' % pricing.pk)
|
||||
resp.form['agenda'] = agenda.pk
|
||||
resp.form['billing_date'] = billing_date1.pk
|
||||
resp.form['user_external_id'] = 'user:1'
|
||||
|
@ -1495,7 +1497,7 @@ def test_detail_pricing_test_tool_for_flat_fee_schedule(mock_pricing_data, app,
|
|||
pricing.subscription_required = False
|
||||
pricing.save()
|
||||
mock_pricing_data.reset_mock()
|
||||
resp = app.get('/manage/pricing/%s/' % pricing.pk)
|
||||
resp = app.get('/manage/pricing/%s/parameters/' % pricing.pk)
|
||||
assert 'agenda' not in resp.context['test_tool_form'].fields
|
||||
resp.form['billing_date'] = billing_date1.pk
|
||||
resp.form['user_external_id'] = 'user:1'
|
||||
|
@ -1579,7 +1581,7 @@ def test_edit_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/%s/#open:matrix-crit-1-1' % pricing.pk)
|
||||
assert resp.location.endswith('/manage/pricing/%s/#open:matrix' % pricing.pk)
|
||||
pricing.refresh_from_db()
|
||||
assert pricing.pricing_data == {
|
||||
'cat-1:crit-1-1': {
|
||||
|
@ -1694,7 +1696,7 @@ def test_edit_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/%s/#open:matrix-' % pricing.pk)
|
||||
assert resp.location.endswith('/manage/pricing/%s/#open:matrix' % pricing.pk)
|
||||
pricing.refresh_from_db()
|
||||
assert pricing.pricing_data == {
|
||||
'cat-2:crit-2-1': {
|
||||
|
@ -1767,7 +1769,7 @@ def test_edit_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/%s/#open:matrix-' % pricing.pk)
|
||||
assert resp.location.endswith('/manage/pricing/%s/#open:matrix' % pricing.pk)
|
||||
pricing.refresh_from_db()
|
||||
assert pricing.pricing_data == {
|
||||
'cat-3:crit-3-1': 111,
|
||||
|
|
|
@ -281,10 +281,10 @@ def test_pricing(app, admin_user, application_with_icon, application_without_ico
|
|||
)
|
||||
|
||||
# check detail page
|
||||
resp = app.get('/manage/pricing/%s/' % pricing1.pk)
|
||||
resp = app.get('/manage/pricing/%s/parameters/' % pricing1.pk)
|
||||
assert len(resp.pyquery('h3:contains("Applications")')) == 0
|
||||
assert len(resp.pyquery('h3:contains("Applications") + .button-paragraph')) == 0
|
||||
resp = app.get('/manage/pricing/%s/' % pricing2.pk)
|
||||
resp = app.get('/manage/pricing/%s/parameters/' % pricing2.pk)
|
||||
assert resp.pyquery('h3:contains("Applications") + .button-paragraph').text() == application.name
|
||||
if icon:
|
||||
assert len(resp.pyquery('h3:contains("Applications") + .button-paragraph img.application-icon')) == 1
|
||||
|
@ -298,7 +298,7 @@ def test_pricing(app, admin_user, application_with_icon, application_without_ico
|
|||
assert len(resp.pyquery('h3:contains("Applications")')) == 0
|
||||
assert len(resp.pyquery('ul.objects-list img')) == 0
|
||||
app.get('/manage/pricing/?application=%s' % application.slug, status=404)
|
||||
resp = app.get('/manage/pricing/%s/' % pricing2.pk)
|
||||
resp = app.get('/manage/pricing/%s/parameters/' % pricing2.pk)
|
||||
assert len(resp.pyquery('h3:contains("Applications")')) == 0
|
||||
assert len(resp.pyquery('h3:contains("Applications") + .button-paragraph')) == 0
|
||||
|
||||
|
|
Loading…
Reference in New Issue