Default configuration and test client use user avatars

This commit is contained in:
Éloi Rivard 2021-12-13 22:50:53 +01:00
parent 951fce2725
commit f4c04d9666
6 changed files with 79 additions and 57 deletions

View file

@ -519,7 +519,7 @@ def reset(uid, hash):
@bp.route("/profile/<uid>/<field>")
def photo(uid, field):
if field != "jpegPhoto":
if field.lower() != "jpegphoto":
abort(404)
user = User.get(uid)

View file

@ -156,6 +156,7 @@ FAMILY_NAME = "{{ user.sn[0] }}"
PREFERRED_USERNAME = "{{ user.displayName[0] }}"
LOCALE = "{{ user.preferredLanguage[0] }}"
ADDRESS = "{{ user.postalAddress[0] }}"
PICTURE = "{% if user.jpegPhoto %}{{ url_for('account.photo', uid=user.uid[0], field='jpegPhoto', _external=True) }}{% endif %}"
# The SMTP server options. If not set, mail related features such as
# user invitations, and password reset emails, will be disabled.

View file

@ -1,71 +1,86 @@
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Canaille test client</title>
<title>Canaille test client</title>
<link href="/static/fomanticui/semantic.min.css" rel="stylesheet">
<link href="/static/css/base.css" rel="stylesheet">
{% if logo_url %}<link rel="icon" href="{{ favicon_url }}">{% endif %}
{% block style %}{% endblock %}
<link href="/static/fomanticui/semantic.min.css" rel="stylesheet">
<link href="/static/css/base.css" rel="stylesheet">
{% if logo_url %}<link rel="icon" href="{{ favicon_url }}">{% endif %}
{% block style %}{% endblock %}
<!--[if lt IE 9]>
<script>window.html5 || document.write('<script src="/static/html5shiv/html5shiv.min.js"><\/script>')</script>
<script src="/static/js/respond.min.js"></script>
<![endif]-->
<!--[if lt IE 9]>
<script>window.html5 || document.write('<script src="/static/html5shiv/html5shiv.min.js"><\/script>')</script>
<script src="/static/js/respond.min.js"></script>
<![endif]-->
</head>
</head>
<body>
<nav class="ui stackable labeled icon menu container">
<div class="header item">
<a href="/" class="logo">
<img class="ui image" src="/static/img/canaille-head.png" alt="Canaille client" />
</a>
</div>
{% if user %}
<a class="item" href="{{ url_for('logout') }}">
<i class="sign out alternate icon"></i>
Log out
</a>
{% else %}
<a class="item" href="{{ url_for('login') }}">
<i class="sign in alternate icon"></i>
Log in
</a>
{% endif %}
</nav>
<div class="ui container">
{% with messages = get_flashed_messages(with_categories=true) %}
{% for category, message in messages %}
<div class="ui attached message {{ category }}">
{{ message }}
<body>
<nav class="ui stackable labeled icon menu container">
<div class="header item">
<a href="/" class="logo">
<img class="ui image" src="/static/img/canaille-head.png" alt="Canaille client" />
</a>
</div>
{% endfor %}
{% endwith %}
<div class="ui segment">
<h2 class="ui header">{{ name }}</h2>
<div>
{% if user %}
<p>Welcome {{ user.name }}</p>
{% if user.groups %}
<p>You're a member of the following groups: {{ user.groups }}</p>
{% endif %}
<a class="item" href="{{ url_for('logout') }}">
<i class="sign out alternate icon"></i>
Sign out
</a>
{% else %}
Welcome, please <a href="{{ url_for('login') }}">log-in</a>.
<a class="item" href="{{ url_for('login') }}">
<i class="sign in alternate icon"></i>
Sign in
</a>
{% endif %}
</nav>
<div class="ui container">
{% with messages = get_flashed_messages(with_categories=true) %}
{% for category, message in messages %}
<div class="ui attached message {{ category }}">
{{ message }}
</div>
{% endfor %}
{% endwith %}
<div class="ui segment">
<h2 class="ui header">{{ name }}</h2>
{% if user %}
<div class="ui centered card">
{% if user.picture %}
<div class="image">
<img src="{{ user.picture }}" alt="Avatar">
</div>
{% endif %}
<div class="content">
<span class="header">{{ user.name }}</span>
<div class="meta">
{{ user.sub }}
</div>
{% if user.groups %}
<div class="extra content">
<i class="user users icon"></i>
{% for group in user.groups %}
<span class="label">{{ group }}</span>
{% endfor %}
</div>
{% endif %}
</div>
</div>
{% else %}
<a class="ui primary button" href="{{ url_for('login') }}">Sign in</a>.
{% endif %}
</div>
</div>
</div>
<script src="/static/jquery/jquery.min.js"></script>
<script src="/static/fomanticui/semantic.min.js"></script>
<script src="/static/js/base.js"></script>
{% block script %}{% endblock %}
</body>
<script src="/static/jquery/jquery.min.js"></script>
<script src="/static/fomanticui/semantic.min.js"></script>
<script src="/static/js/base.js"></script>
{% block script %}{% endblock %}
</body>
</html>

View file

@ -162,6 +162,7 @@ FAMILY_NAME = "{{ user.sn[0] }}"
PREFERRED_USERNAME = "{{ user.displayName[0] }}"
LOCALE = "{{ user.preferredLanguage[0] }}"
ADDRESS = "{{ user.postalAddress[0] }}"
PICTURE = "{% if user.jpegPhoto %}{{ url_for('account.photo', uid=user.uid[0], field='jpegPhoto', _external=True) }}{% endif %}"
# The SMTP server options. If not set, mail related features such as
# user invitations, and password reset emails, will be disabled.

View file

@ -212,6 +212,10 @@ Attributes are rendered using jinja2, and can use a ``user`` variable.
:ADDRESS:
*Optional.* Defaults to ``{{ user.postalAddress[0] }}``
:PICTURE:
*Optional.* Defaults to ``{% if user.jpegPhoto %}{{ url_for('account.photo', uid=user.uid[0], field='jpegPhoto', _external=True) }}{% endif %}``
SMTP
----
Canaille needs you to configure a SMTP server to send some mails, including the *I forgot my password* and the *invitation* mails.

View file

@ -187,6 +187,7 @@ def configuration(slapd_server, smtpd, keypair_path):
"FAMILY_NAME": "{{ user.sn[0] }}",
"PREFERRED_USERNAME": "{{ user.displayName[0] }}",
"LOCALE": "{{ user.preferredLanguage[0] }}",
"PICTURE": "{% if user.jpegPhoto %}{{ url_for('account.photo', uid=user.uid[0], field='jpegPhoto', _external=True) }}{% endif %}",
},
},
"SMTP": {