Skip to content

Commit

Permalink
feat(user-info): display additional data
Browse files Browse the repository at this point in the history
  • Loading branch information
ch-cbna committed Mar 6, 2024
1 parent f4f270f commit 34f0941
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 10 deletions.
4 changes: 4 additions & 0 deletions app/t_roles/route.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
flash,
current_app,
)
import re

from pypnusershub import routes as fnauth
from pypnusershub.db.models import check_and_encrypt_password
Expand Down Expand Up @@ -291,6 +292,9 @@ def buildUserFullName(user):
fullname.append(user["prenom_role"].title())
return " ".join(fullname)

@route.app_template_filter()
def pretty_json_key(key):
return re.sub("([a-z])([A-Z])","\g<1> \g<2>",key)

def pops(form, with_group=True):
"""
Expand Down
26 changes: 26 additions & 0 deletions app/templates/info_user.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
{%set is_organisme = organisme is not none and organisme['nom_organisme'] != '' %}
{%set is_desc = user['desc_role'] is not none and user['desc_role'] != '' %}
{%set is_remarques = user['remarques'] is not none and user['remarques'] != '' %}
{%set is_champs_addi = user['champs_addi'] is not none and user['champs_addi'] != '' %}
{%set is_mail = user['email'] is not none and user['email'] != '' %}
{%set is_group = groups|length > 0 %}
{%set is_list = lists|length > 0 %}
Expand All @@ -32,6 +33,31 @@ <h3>Utilisateur "{{user['fullname']}}"</h3>
{% if is_remarques %}
<br /><strong>Remarques :</strong> {{user['remarques']}}
{% endif %}
{% if is_champs_addi %}
<dl class="list-def-inline">
{% for key, value in user.champs_addi.items() %}
<dt>{{ key|pretty_json_key|capitalize }} : </dt>
<dd>
{% if value is iterable and (value is not string and value is not mapping) %}
<ul>
{% for item in value %}
<li>{{ item }}</li>
{% endfor %}
</ul>
{% elif value is mapping %}
<dl class="list-def-inline">
{% for key, value in value.items() %}
<dt>{{ key|e|capitalize }} : </dt>
<dd>{{ value }} </dd>
{% endfor %}
</dl>
{% else %}
{{ value }}
{% endif %}
</dd>
{% endfor %}
</dl>
{% endif %}
</small>
</div>

Expand Down
32 changes: 22 additions & 10 deletions app/templates/librairies.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,20 @@
{% block title %}UsersHub V2{% endblock %}

{% block styles %}

<style type="text/css">
dl.list-def-inline {
display: grid;
grid-template-columns: max-content auto;
}

dl.list-def-inline dt {
grid-column-start: 1;
}

dl.list-def-inline dd {
grid-column-start: 2;
}

#add {
-ms-transform: rotate(180deg); /* IE 9 */
Expand All @@ -19,7 +31,7 @@
.font-medium {
font-size: 25px !important;
}

.forms {
padding: 40px !important;
}
Expand Down Expand Up @@ -65,20 +77,20 @@


{% block scripts %}
<script
<script
src="{{ url_for('static', filename='node_modules/jquery/dist/jquery.min.js') }}"
type="text/javascript"
></script>
<script
></script>
<script
src="{{ url_for('static', filename='node_modules/bootstrap/dist/js/bootstrap.js') }}"
type="text/javascript"
></script>
<script
></script>
<script
src=" {{url_for('static', filename='node_modules/datatables.net/js/jquery.dataTables.min.js')}} "
type="text/javascript"
></script>
<script src="{{ url_for('constants_js') }} " type="text/javascript"></script>
<script
></script>
<script src="{{ url_for('constants_js') }} " type="text/javascript"></script>
<script
src="{{ url_for('static', filename='transfer.js') }}"
type="text/javascript"
></script>
Expand Down

0 comments on commit 34f0941

Please sign in to comment.