Allow modifying personal data, fix ssh key css

pull/1/head
q3k 2019-10-18 13:16:04 +02:00 committed by The Git Man
parent d468b6ad71
commit 46ee9f5334
2 changed files with 20 additions and 5 deletions

View File

@ -10,7 +10,9 @@ admin_pw = 'changeme'
hackerspace_name = 'Warsaw Hackerspace'
readable_names = {
'commonname': u'Common Name',
'givenname': u'Given Name',
'gecos': u'GECOS (public name)',
'surname': u'Surname',
'loginshell': u'Shell',
'telephonenumber': 'Phone Number',
@ -19,6 +21,7 @@ readable_names = {
full_name = {
'cn': 'commonname',
'gecos': 'gecos',
'sn': 'surname',
'mobile': 'mobiletelephonenumber',
'l': 'locality',
@ -29,7 +32,9 @@ can_add = set([
'mobiletelephonenumber',
])
can_delete = can_add
can_modify = can_add
can_modify = can_add | set([
'givenname', 'surname', 'commonname', 'gecos',
])
can = { 'add':can_add, 'mod':can_modify, 'del':can_delete }
admin_required = set()

View File

@ -1,11 +1,14 @@
{% macro field(name) -%}
{% macro field(name, width=4) -%}
{% if profile[name] %}
{% with field = profile[name]|first %}
<div class="col-md-4" style="margin-bottom: 20px;">
<div class="col-md-{{width}}" style="margin-bottom: 20px;">
<div style="background-color: #eee; padding: 10px 30px; border-radius: 12px;">
<h4>{{ name|readable }}</h4>
<h2 style="margin-top: 0">{{ field }}</h2>
{% if field.name in can_delete %}delete{% endif %}
{% if name in can_modify %}
<a class="modalLink" href="/vcard/modify/{{ field.uid }}"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Edit</a>
{% endif %}
</div>
</div>
{% endwith %}
@ -16,15 +19,19 @@
{% endif %}
{%- endmacro %}
{% macro multifield(name) -%}
<div class="col-md-4" style="margin-bottom: 20px;">
{% macro multifield(name, code=False, width=4) -%}
<div class="col-md-{{width}}" style="margin-bottom: 20px;">
<div style="background-color: #eee; padding: 10px 30px; border-radius: 12px;">
<h4>{{ name|readable }}</h4>
{% if name in can_add %}
<a class="modalLink" href="/vcard/add/{{ name }}"><span class="glyphicon glyphicon-plus-sign" aria-hidden="true"></span> Add</a>
{% endif %}
{% for value in profile[name] %}
{% if code %}
<code style="display: block; word-wrap: break-word; margin-top: 1em; margin-bottom: 0.5em; padding: 0.8em; background-color: #111; color: #fff;">{{ value }}</code>
{% else %}
<h2>{{ value }}</h2>
{% endif %}
{% if name in can_delete %}
<a class="modalLink" href="/vcard/delete/{{ value.uid }}"><span class="glyphicon glyphicon-minus-sign" aria-hidden="true"></span> Remove</a>
{% endif %}
@ -41,10 +48,13 @@
{% block content %}
<div class="row">
{{ field('givenname') }}
{{ field('gecos', width=8) }}
{{ field('surname') }}
{{ field('commonname', width=8) }}
{{ field('loginshell') }}
{{ multifield('telephonenumber') }}
{{ multifield('mobiletelephonenumber') }}
{{ multifield('sshpublickey', code=True, width=12) }}
</div>
{% endblock %}