misc: ask for most important parameters on home page (#44413)

This commit is contained in:
Nicolas Roche 2020-06-29 16:17:03 +02:00
parent 90a954b45e
commit be3ffd83a6
3 changed files with 41 additions and 2 deletions

View File

@ -25,6 +25,27 @@
{% block content %}
{% if not has_global_title %}
<div class="warningnotice">
<p class="action">
<span class="action-label">
{% trans 'You have not yet defined a name for the platform; the generic title "Compte Citoyen" is used.' %}
</span>
<a class="action-button" rel="popup" href="{% url 'theme-options' %}">{% trans 'Set up a title' %}</a>
</p>
</div>
{% endif %}
{% if not has_default_from_email %}
<div class="warningnotice">
<p class="action">
<span class="action-label">
{% trans "You have not yet defined an address for emails sent by Publik." %}
</span>
<a class="action-button" href="{% url 'emails-home' %}">{% trans 'Set up email options' %}</a>
</p>
</div>
{% endif %}
{% if services %}
<div class="services">
{% for service in services %}

View File

@ -14,7 +14,7 @@ from django.contrib.auth import views as auth_views
from django.shortcuts import resolve_url
from django.utils.encoding import force_text
from .environment.models import Authentic
from .environment.models import Authentic, Variable
from .environment.utils import Zone, get_installed_services
from .forms import HoboForm, HoboUpdateForm, get_tenant_model
@ -34,6 +34,9 @@ class Home(TemplateView):
context = super(Home, self).get_context_data(**kwargs)
context['services'] = [x for x in get_installed_services() if not x.secondary]
context['has_authentic'] = bool(Authentic.objects.filter(secondary=False))
context['has_global_title'] = Variable.objects.filter(name='global_title').exists()
context['has_default_from_email'] = Variable.objects.filter(
name='default_from_email').exists()
return context
home = admin_required(Home.as_view())

View File

@ -6,7 +6,7 @@ import re
from django.contrib.auth.models import User
from hobo.environment.models import Authentic
from hobo.environment.models import Authentic, Variable
from test_manager import login
@ -97,3 +97,18 @@ def test_menu_view(app, admin_user):
assert resp.content_type == 'application/javascript'
json_str = re.match(r'foo\((.*)\)', resp.text).group(1)
assert json.loads(json_str) == expected
def test_warning_notifications(app, admin_user):
app = login(app)
resp = app.get('/')
assert len(resp.html.find_all('div', {'class': 'warningnotice'})) == 2
assert resp.html.find('div', {'class': 'warningnotice'}).a['href'] == '/theme/options'
Variable.objects.create(name='global_title', value='Publik')
resp = app.get('/')
assert len(resp.html.find_all('div', {'class': 'warningnotice'})) == 1
assert resp.html.find('div', {'class': 'warningnotice'}).a['href'] == '/emails/'
Variable.objects.create(name='default_from_email', value='publik@example.com')
resp = app.get('/')
assert not resp.html.find_all('div', {'class': 'warningnotice'})