Skip to content
Permalink
Browse files

Restructuring

  • Loading branch information...
ibot3 committed Sep 9, 2019
1 parent 8ad4128 commit d70cc088aa3c2125b373c4ac5df1b41aab2e38d2
Showing with 24 additions and 29 deletions.
  1. +0 −4 sipa/model/hss/user.py
  2. +18 −19 sipa/model/pycroft/user.py
  3. +6 −6 sipa/model/user.py
@@ -166,10 +166,6 @@ def realname(self):
def login(self):
return self._pg_account.account.strip()

@unsupported_prop
def network_access_active(self):
raise NotImplementedError

@active_prop
def mac(self):
return {'value': ", ".join(mac.mac.lower() for mac in self._pg_account.macs),
@@ -104,6 +104,24 @@ def mac(self):
return {'value': ", ".join(i.mac for i in self.user_data.interfaces),
'tmp_readonly': len(self.user_data.interfaces) != 1}

# Empty setter for "edit" capability
@mac.setter
def mac(self, new_mac):
pass

def change_mac_address(self, new_mac, host_name):
# if this has been reached despite `tmp_readonly`, this is a bug.
assert len(self.user_data.interfaces) == 1

status, result = api.change_mac(self.user_data.id, self._tmp_password,
self.user_data.interfaces[0].id,
new_mac, host_name)

if status == 401:
raise PasswordInvalid
elif status == 400:
raise MacAlreadyExists

@active_prop
@connection_dependent
def network_access_active(self):
@@ -150,24 +168,6 @@ def continue_membership(self):
elif status != 200:
raise UnkownError


@mac.setter
def mac(self, new_mac):
pass

def change_mac_address(self, new_mac, host_name):
# if this has been reached despite `tmp_readonly`, this is a bug.
assert len(self.user_data.interfaces) == 1

status, result = api.change_mac(self.user_data.id, self._tmp_password,
self.user_data.interfaces[0].id,
new_mac, host_name)

if status == 401:
raise PasswordInvalid
elif status == 400:
raise MacAlreadyExists

@active_prop
def mail(self):
return self.user_data.mail
@@ -252,7 +252,6 @@ def userdb_status(self):
empty=True,
capabilities=capabilities)


@property
def userdb(self):
return self._userdb
@@ -7,7 +7,8 @@
from contextlib import contextmanager
from typing import TypeVar, Type, List, Dict, Optional

from sipa.model.fancy_property import active_prop, UnsupportedProperty, PropertyBase
from sipa.model.fancy_property import active_prop, UnsupportedProperty, PropertyBase, \
unsupported_prop
from sipa.model.finance import BaseFinanceInformation
from sipa.model.misc import PaymentDetails

@@ -284,16 +285,15 @@ def has_property(self, property):
"""Method to check if a user has a property"""
return False

@property
@unsupported_prop
def membership_end_date(self):
"""Date when the membership ends"""
return None
raise NotImplementedError

@active_prop
@abstractmethod
@unsupported_prop
def network_access_active(self):
"""Whether or not the network access is active"""
pass
raise NotImplementedError

def activate_network_access(self, password, mac, birthdate, host_name):
"""Method to activate network access"""

0 comments on commit d70cc08

Please sign in to comment.
You can’t perform that action at this time.