From fd21d8bb288374d028f467ffa73987462a46fc18 Mon Sep 17 00:00:00 2001
From: Carlos Vega <carlos.vega@uni.lu>
Date: Thu, 22 Nov 2018 16:32:11 +0100
Subject: [PATCH] show if worker is super user

---
 smash/web/forms/worker_form.py        | 4 ++++
 smash/web/templates/doctors/edit.html | 3 +++
 2 files changed, 7 insertions(+)

diff --git a/smash/web/forms/worker_form.py b/smash/web/forms/worker_form.py
index 29625680..8ceeacd7 100644
--- a/smash/web/forms/worker_form.py
+++ b/smash/web/forms/worker_form.py
@@ -57,6 +57,10 @@ class WorkerForm(ModelForm):
         del self.fields['user']
 
         if worker_type == WORKER_STAFF:
+            if instance.user is not None:
+                self.fields['Superuser'] = forms.BooleanField(label='Is Superuser?', disabled=True, required=False,
+            help_text='Super users have all permissions. This is a read only field.')
+                self.fields['Superuser'].initial = instance.user.is_superuser
             del self.fields['voucher_types']
             del self.fields['name']
         else:
diff --git a/smash/web/templates/doctors/edit.html b/smash/web/templates/doctors/edit.html
index fb689494..40217781 100644
--- a/smash/web/templates/doctors/edit.html
+++ b/smash/web/templates/doctors/edit.html
@@ -37,6 +37,9 @@
                         <div class="col-md-6 form-group  {% if field.errors %}has-error{% endif %} {{ field.field.widget.attrs.class }}">
                             <label for="{# TODO #}" class="col-sm-4 control-label">
                                 {{ field.label }}
+                                {% if field.help_text %}
+                                   <i class="fa fa-info-circle" aria-hidden="true" data-toggle="tooltip" data-placement="top" title="{{field.help_text}}"></i>
+                                {% endif %}
                             </label>
 
                             <div class="col-sm-8">
-- 
GitLab