Skip to content

Commit

Permalink
added mpsks methods sample backend
Browse files Browse the repository at this point in the history
added the add change and delete methods for the sample backend
#498
  • Loading branch information
agmes4 committed Dec 25, 2024
1 parent 1be02b5 commit 68d4200
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 31 deletions.
19 changes: 17 additions & 2 deletions sipa/model/sample/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,24 @@ def mpsks_clients(self, value):
self.config["mpsks_clients"] = value


def change_mpsks_clients(self, password: str, mpsks: list):
self.config["mpsks_clients"] = mpsks
def change_mpsks_clients(self, mac, name: str, old_mac, password: str):
for i, el in enumerate(self.config["mpsks_clients"]):
if old_mac == el[1]:
self.config["mpsks_clients"][i] = (name, mac)
break
else:
raise ValueError(f"mac: {mac} not found for user")

def add_mpsks_client(self, name, mac, password):
self.config["mpsks_clients"].append((name, mac))

def delete_mpsks_client(self, mac, password):
for i, el in enumerate(self.config["mpsks_clients"]):
if mac == el[1]:
self.config["mpsks_clients"].remove(el)
break
else:
raise ValueError(f"mac: {mac} not found for user")

@property
def mail(self):
Expand Down
13 changes: 13 additions & 0 deletions sipa/templates/usersuite/mpsk_client.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% extends "generic_form.html" %}
{% set page_title = _("MAC-Adresse ändern") %}

{% block form_content %}
<div class="{{ form_input_offset_class }} {{ form_input_width_class }} alert alert-info">
{{ _('Bitte gehe sicher, dass es sich um die Wi-Fi MAC-Adresse deines Gerätes handelt.') }}
{{ _('Hinweis: Bei einer Änderung der MAC-Adresse wird automatisch eine Benachrichtigungsmail an uns gesandt.') }}
</div>
<div class="{{ form_input_offset_class }} {{ form_input_width_class }} alert alert-warning">
{{ _('Bitte beachtet, dass Nach-/Untermieter einen eigenen Account brauchen. Es ist nicht zulässig, den eigenen Account weiterzugeben.') }}
{{ _('Solltet ihr euren Account mit anderen teilen (ihn weitergeben, fremde MAC-Adressen eintragen), haftet weiterhin ihr als der Accountinhaber für alle Aktivitäten des Accounts!') }}
</div>
{% endblock %}
38 changes: 38 additions & 0 deletions sipa/templates/usersuite/mpsks_table.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{% extends "base.html" %}

{% import "macros/forms.html" as forms %}
{% set page_title = _("MPSK Wi-Fi Geräte") %}
{% block content %}
{% include "heading.html" %}
<table class="table table-striped">
<tr>
<th>{{ _("Greät") }}</th>
<th>{{ _("Wi-Fi MAC") }}</th>
<th>{{ _("Aktion") }}</th>
</tr>
{% for client in clients %}
<tr>

<td>{{ client[0] }}</td>
<td>{{ client[1] }}</td>
<td>
<a href="{{ url_for('usersuite.change_mpsks', name=client[0], mac=client[1]) }}">
<span class="bi-pencil-fill ms-auto"></span>
</a>
<a href="{{ url_for('usersuite.delete_mpsk', mac=client[1]) }}">
<span class="bi-trash-fill ms-auto"></span>
</a>
</td>
</tr>
{% endfor %}
<tr>
<td colspan="3" class="text-center">
<a href="{{ url_for('usersuite.add_mpsks') }}" class="align-items-center " >
<span class="bi-plus-square-fill ms-auto"></span>
</a>
</td>
</tr>
</table>

{% endblock %}

29 changes: 0 additions & 29 deletions sipa/templates/usersuite/mpsks_things.html

This file was deleted.

0 comments on commit 68d4200

Please sign in to comment.