Skip to content
Permalink
Browse files

Make userdb unsupported if the user does not have the userdb property

  • Loading branch information...
ibot3 committed Aug 28, 2019
1 parent c4d8c21 commit a3b42337cd99bd901e96ee186a10540db5213de1
Showing with 22 additions and 9 deletions.
  1. +3 −0 sipa/blueprints/usersuite.py
  2. +19 −9 sipa/model/pycroft/user.py
@@ -376,6 +376,9 @@ def change_use_cache():
def hosting(action=None):
"""Change various settings for Helios.
"""
if not current_user.has_property("userdb"):
abort(403)

if action == "confirm":
current_user.userdb.drop()
flash(gettext("Deine Datenbank wurde gelöscht."), 'success')
@@ -4,7 +4,7 @@
from sipa.model.user import BaseUser
from sipa.model.finance import BaseFinanceInformation
from sipa.model.fancy_property import active_prop, connection_dependent, \
unsupported_prop
unsupported_prop, ActiveProperty, UnsupportedProperty
from sipa.model.misc import PaymentDetails
from sipa.model.exceptions import UserNotFound, PasswordInvalid, \
MacAlreadyExists, NetworkAccessAlreadyActive
@@ -200,20 +200,30 @@ def hostname(self):
def hostalias(self):
raise NotImplementedError

@active_prop
@property
def userdb_status(self):
status = self.userdb.has_db

if not self.has_property("userdb"):
return UnsupportedProperty("userdb_status")

if status is None:
return {'value': gettext("Datenbank nicht erreichbar"),
'style': 'danger', 'empty': True}
return ActiveProperty(name="userdb_status",
value=gettext("Datenbank nicht erreichbar"),
style='danger',
empty=True)

if status:
return {'value': gettext("Aktiviert"),
'style': 'success'}
return {'value': gettext("Nicht aktiviert"),
'empty': True}
return ActiveProperty(name="userdb_status",
value=gettext("Aktiviert"),
style='success')

return ActiveProperty(name="userdb_status",
value=gettext("Nicht aktiviert"),
empty=True)


userdb_status = userdb_status.fake_setter()
# userdb_status = userdb_status.fake_setter()

@property
def userdb(self):

0 comments on commit a3b4233

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