import pprint
|
|
|
|
|
|
class Member():
|
|
"""Member class for admidio, here all member data will be stored."""
|
|
|
|
def __init__(self, db, user_id, username, password, userfields, admidio):
|
|
self.__c = db.cursor()
|
|
self.user_id = user_id
|
|
self.username = username
|
|
self.password = password
|
|
self.userdata = dict()
|
|
self.admidio = admidio
|
|
sql = f"""SELECT usd_usf_id, usd_value
|
|
FROM {self.admidio.prefix}_user_data
|
|
WHERE usd_usr_id = {self.user_id!s}"""
|
|
self.__c.execute(sql)
|
|
for row in self.__c.fetchall():
|
|
# makes dict with {usf_name_intern:usd_value}
|
|
self.userdata[userfields[row[0]]] = row[1]
|
|
|
|
def __hash__(self):
|
|
"""Not sure if needed"""
|
|
return hash((self.user_id, self.username))
|
|
|
|
def __str__(self):
|
|
return (f"""Userid: {self.user_id}, Username: {self.username}, """
|
|
f"""Userdata: {pprint.pformat(self.userdata)}""")
|
|
|
|
"""@property
|
|
def email(self):
|
|
return self.userdata['EMAIL']
|
|
|
|
@property
|
|
def firstName(self):
|
|
return self.userdata['FIRST_NAME']
|
|
|
|
@property
|
|
def lastName(self):
|
|
return self.userdata['LAST_NAME']
|
|
|
|
@property
|
|
def username(self):
|
|
self.username
|
|
|
|
@property
|
|
def password(self):
|
|
return self.password"""
|