Skip to content
Permalink
Browse files

Allow for membership termination in sample datasource

  • Loading branch information...
lukasjuhrich committed Sep 15, 2019
1 parent b0fe705 commit 097ede23bde10679a2db24f45585a0fa9432360f
Showing with 29 additions and 2 deletions.
  1. +29 −2 sipa/model/sample/user.py
@@ -30,6 +30,8 @@ def init_context(app):
'hostname': 'My_Server',
'hostalias': 'leethax0r',
'use_cache': False,
'membership_end_date': None,
'is_member': True,
}
}

@@ -159,7 +161,10 @@ def ips(self):

@active_prop
def status(self):
return self.config[self.uid]['status']
status_str = self.config[self.uid]['status']
return (status_str
if not self.membership_end_date
else f"{status_str} (ends at {self.membership_end_date.value})")

has_connection = True

@@ -204,9 +209,31 @@ def payment_details(self):
purpose=self.id.value,
)

@active_prop
def membership_end_date(self):
print(self.config[self.uid])
return {'value': self.config[self.uid]['membership_end_date'],
# we cannot edit it if we are not a member
'tmp_readonly': not self.is_member}

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

@property
def is_member(self):
return True
return self.config[self.uid]['is_member']

def estimate_balance(self, end_date):
return random() * 10 - 5

def terminate_membership(self, end_date):
self.config[self.uid]['membership_end_date'] = end_date
print(self.config[self.uid])

def continue_membership(self):
self.config[self.uid]['membership_end_date'] = None

userdb = None

0 comments on commit 097ede2

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