Skip to content

Commit

Permalink
added user implemation for user
Browse files Browse the repository at this point in the history
added the backend implentation for the api to pycroft
and sample user
#498
  • Loading branch information
agmes4 committed Dec 25, 2024
1 parent dc8ec4f commit 3193e69
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
4 changes: 0 additions & 4 deletions sipa/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,6 @@ class DeleteMPSKClientForm(FlaskForm):
password = PasswordField(
label=lazy_gettext("Passwort"),
validators=[DataRequired(lazy_gettext("Passwort nicht angegeben!"))])
mac = StrippedStringField(
label=lazy_gettext("WiFi MAC"),
render_kw={'readonly': True, 'disabled': True},
description="XX:XX:XX:XX:XX:XX")


class ActivateNetworkAccessForm(FlaskForm):
Expand Down
16 changes: 10 additions & 6 deletions sipa/model/pycroft/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,13 +329,17 @@ def mpsks_clients(self) -> ActiveProperty[str | None, str | None]:
return ActiveProperty(name="mpsks_clients", value=self.config["mpsks_clients"], capabilities=Capabilities(edit=True, delete=False),)

def change_mpsks_clients(self, mac, name, mpsk_id, password: str):
for i, el in enumerate(self.config["mpsks_clients"]):
if mpsk_id == el.id:
el.name = name
el.mac = mac
break
else:
status, _ = api.change_mpsk(self.user_data.id, mac, name, mpsk_id, password)

if status == 400:
raise ValueError(f"mac: {mac} not found for user")
elif status == 409:
raise MacAlreadyExists
elif status == 422:
raise ValueError

self.mpsks_clients.value[mpsk_id].name = name
self.mpsks_clients.value[mpsk_id].mac = mac

def add_mpsks_client(self, name, mac, password):
status, response = api.add_mpsk(
Expand Down
1 change: 0 additions & 1 deletion sipa/model/sample/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ def change_mpsks_clients(self, mac, name, mpsk_id, password: str):

def add_mpsks_client(self, name, mac, password):
dev = MPSKClientEntry(mac=mac, name=name, id=len(self.config["mpsks_clients"]))
self.config["mpsks_clients"].append(dev)
return dev

def delete_mpsks_client(self, mpsk_id: int, password):
Expand Down

0 comments on commit 3193e69

Please sign in to comment.