Add organization display for devices, WiFis and users in manager for superusers

This commit is contained in:
Kumi 2019-01-15 12:08:19 +01:00
parent 363035af1a
commit fa61c7f7b2
3 changed files with 8 additions and 5 deletions

View file

@ -24,10 +24,10 @@
{% for device in devices %}
<tr>
<td><div style="display: inline; color: grey; font-weight: bold;" title="No information available" id="{{ device.id }}-indicator">&#11044;</div>&nbsp;<div style="display: inline;" id="{{ device.id }}-id">{{ device.serial }}</div></td>
<td><div style="display: inline; color: grey; font-weight: bold;" title="No information available" id="{{ device.id }}-indicator">&#11044;</div>&nbsp;<div style="display: inline;" {% if user.is_superuser %}title="{{device.organization.name}}"{% endif %} id="{{ device.id }}-id">{{ device.serial }}</div></td>
<td id="{{ device.id }}-name">{% if device.name %}{{ device.name }}{% endif %}</td>
<td id="{{ device.id }}-network">{{ device.network }}</td>
<td><div style="display:inline" id="{{ device.id }}-ip">{% if device.curip %}{{ device.curip }} (at {{ device.lasttime }}){% endif %}</div></td>
<td><div style="display:inline;" id="{{ device.id }}-ip">{% if device.curip %}{{ device.curip }} (at {{ device.lasttime }}){% endif %}</div></td>
<td><a href="/devices/{{ device.id }}/edit"><i class="fas fa-edit" title="Edit Device"></i></a> <a href="#"><i style="color: green;" onclick="askreboot({{ device.id }});" class="fas fa-sync" title="Reboot Device"></i></a>{% if user.is_staff %} <a onclick="downloadnotice();" href="/devices/{{ device.id }}/download"><i class="fas fa-download" title="Download Configuration"></i></a>{% endif %}{% if user.is_superuser %} <a href="#"><i style="color: darkred;" onclick="askdelete({{ device.id }});" class="fas fa-trash-alt" title="Delete Device"></i></a>{% endif %}</td>
</tr>
{% endfor %}
@ -51,7 +51,7 @@
{% for wifi in wifis %}
<tr>
<td>{{ wifi.serial }}</td>
<td><div style="display:inline;" {% if user.is_superuser %}title="{{ wifi.organization.name }}"{% endif %}>{{ wifi.serial }}</div></td>
<td>{{ wifi.ssid }}</td>
<td><a href="/wifi/{{ wifi.id }}/edit"><i class="fas fa-edit" title="Edit WiFi"></i></a>{% if user.is_staff %} <a href="#"><i style="color: darkred;" onclick="askdeletewifi({{ wifi.id }});" class="fas fa-trash-alt" title="Delete WiFi"></i></a>{% endif %}</td>
</tr>
@ -77,7 +77,7 @@
{% for auser in users %}
<tr>
<td>{% if auser.is_staff %}<b>{% endif %}{{ auser.username }}{% if auser.is_staff %}</b>{% endif %}</td>
<td><div style="display:inline;" {% if user.is_superuser %}title="{% for orga in auser.organizations %}{{ orga }}&#10;{% endfor %}"{% endif %}>{% if auser.is_staff %}<b>{% endif %}{{ auser.username }}{% if auser.is_staff %}</b>{% endif %}</div></td>
<td>{% if auser.is_staff %}<b>{% endif %}{{ auser.first_name }} {{ auser.last_name }}{% if auser.is_staff %}</b>{% endif %}</td>
<td><a href="/user/{{ auser.id }}/edit"><i class="fas fa-edit" title="Edit User"></i></a></td>
</tr>

View file

@ -268,6 +268,9 @@ def devices(request):
wifis.add(wifi)
if user.is_staff:
for orgauser in User.objects.filter(organization=organization):
orgauser.organizations = set()
for orga in Organization.objects.filter(users=orgauser):
orgauser.organizations.add(orga)
users.add(orgauser)
return render(request, "manager/index.html",

View file

@ -7,7 +7,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = '=go8&h#^kh6ksr11e2z-@4qqd6t%63$x#-!s#l_yhw@oyanrys'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
DEBUG = True
ALLOWED_HOSTS = ["admin360.kumi.host"]