0001-manager-add-a-link-to-go-on-agenda-s-lingo-config-65.patch
chrono/agendas/models.py | ||
---|---|---|
283 | 283 |
def get_settings_url(self): |
284 | 284 |
return reverse('chrono-manager-agenda-settings', kwargs={'pk': self.id}) |
285 | 285 | |
286 |
def get_lingo_url(self): |
|
287 |
if not settings.KNOWN_SERVICES.get('lingo'): |
|
288 |
return |
|
289 |
lingo = list(settings.KNOWN_SERVICES['lingo'].values())[0] |
|
290 |
lingo_url = lingo.get('url') or '' |
|
291 |
if not lingo_url.endswith('/'): |
|
292 |
lingo_url += '/' |
|
293 |
return '%smanage/pricing/agenda/%s/' % (lingo_url, self.slug) |
|
294 | ||
286 | 295 |
def can_be_managed(self, user): |
287 | 296 |
if user.is_staff: |
288 | 297 |
return True |
chrono/manager/templates/chrono/manager_agenda_settings.html | ||
---|---|---|
20 | 20 |
{% endblock %} |
21 | 21 |
<ul class="extra-actions-menu"> |
22 | 22 |
<li><a rel="popup" href="{% url 'chrono-manager-agenda-edit' pk=object.id %}">{% trans 'Options' %}</a></li> |
23 |
{% block agenda-extra-menu-actions %}{% endblock %} |
|
23 | 24 |
<li><a rel="popup" class="action-duplicate" href="{% url 'chrono-manager-agenda-duplicate' pk=object.pk %}">{% trans 'Duplicate' %}</a></li> |
24 | 25 |
<li><a download href="{% url 'chrono-manager-agenda-export' pk=object.id %}">{% trans 'Export Configuration (JSON)' %}</a></li> |
25 | 26 |
{% if object.kind == 'events' %} |
... | ... | |
28 | 29 |
{% if user.is_staff %} |
29 | 30 |
<li><a rel="popup" href="{% url 'chrono-manager-agenda-delete' pk=object.id %}">{% trans 'Delete' %}</a></li> |
30 | 31 |
{% endif %} |
31 |
{% block agenda-extra-menu-actions %}{% endblock %} |
|
32 | 32 |
</ul> |
33 | 33 |
</span> |
34 | 34 |
{% endblock %} |
chrono/manager/templates/chrono/manager_events_agenda_settings.html | ||
---|---|---|
6 | 6 |
<a rel="popup" href="{% url 'chrono-manager-agenda-add-event' pk=object.id %}">{% trans 'New Event' %}</a> |
7 | 7 |
{% endblock %} |
8 | 8 | |
9 |
{% block agenda-extra-menu-actions %} |
|
10 |
{% with lingo_url=object.get_lingo_url %}{% if lingo_url %} |
|
11 |
<li><a href="{{ lingo_url }}">{% trans 'Pricing' context 'pricing' %}</a></li> |
|
12 |
{% endif %}{% endwith %} |
|
13 |
{% endblock %} |
|
14 | ||
9 | 15 |
{% block agenda-settings %} |
10 | 16 | |
11 | 17 |
<div class="section"> |
tests/manager/test_all.py | ||
---|---|---|
465 | 465 |
assert agenda.minimal_booking_delay_in_working_days is True |
466 | 466 | |
467 | 467 | |
468 |
def test_options_events_agenda_lingo_link(settings, app, admin_user): |
|
469 |
settings.KNOWN_SERVICES = {} |
|
470 |
agenda = Agenda.objects.create(label='Foo bar') |
|
471 | ||
472 |
app = login(app) |
|
473 |
resp = app.get('/manage/agendas/%s/settings' % agenda.pk) |
|
474 |
assert 'Pricing' not in resp |
|
475 |
assert '/manage/pricing/agenda/%s/' % agenda.slug not in resp |
|
476 | ||
477 |
settings.KNOWN_SERVICES['lingo'] = {'default': {'url': 'https://lingo.dev'}} |
|
478 |
resp = app.get('/manage/agendas/%s/settings' % agenda.pk) |
|
479 |
assert 'Pricing' in resp |
|
480 |
assert 'https://lingo.dev/manage/pricing/agenda/%s/' % agenda.slug in resp |
|
481 |
settings.KNOWN_SERVICES['lingo'] = {'default': {'url': 'https://lingo.dev/'}} |
|
482 |
resp = app.get('/manage/agendas/%s/settings' % agenda.pk) |
|
483 |
assert 'https://lingo.dev/manage/pricing/agenda/%s/' % agenda.slug in resp |
|
484 | ||
485 | ||
468 | 486 |
def test_options_virtual_agenda_delays(app, admin_user): |
469 | 487 |
agenda = Agenda.objects.create(label='Foo bar', kind='virtual', maximal_booking_delay=2) |
470 | 488 |
assert agenda.maximal_booking_delay == 2 |
471 |
- |