The objective of this interface is the ability to get data from an Admidio installation and use them in python. Currently Users, groups and events are integrated
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

48 lines
1.3 KiB

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"""