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.

62 lines
1.9 KiB

import pprint
import hashlib
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}"""
for row in self.__c.fetchall():
# makes dict with {usf_name_intern:usd_value}
self.userdata[userfields[row[0]]] = row[1]
def __eq__(self, other):
if isinstance(other, Member):
return self.hash() == other.hash()
def hash(self):
if self.password:
return hashlib.md5((str(self.user_id)
+ self.username
+ self.password
+ str(self.userdata)
return hashlib.md5((str(self.user_id)
+ self.username
+ str(self.userdata)
def __str__(self):
return (f"""Userid: {self.user_id}, Username: {self.username}, """
f"""Userdata: {pprint.pformat(self.userdata)}""")
def email(self):
return self.userdata['EMAIL']
def firstName(self):
return self.userdata['FIRST_NAME']
def lastName(self):
return self.userdata['LAST_NAME']
def username(self):
def password(self):
return self.password"""