|
|
@ -10,23 +10,25 @@ from dateutil.relativedelta import relativedelta |
|
|
|
class Admidio: |
|
|
|
"""Creates the Admidio Class""" |
|
|
|
|
|
|
|
def __init__(self, mysql_host, mysql_user, mysql_pass, mysql_db): |
|
|
|
def __init__(self, mysql_host, mysql_user, mysql_pass, mysql_db, |
|
|
|
db_prefix): |
|
|
|
self.db = MySQLdb.connect( |
|
|
|
host=mysql_host, user=mysql_user, passwd=mysql_pass, db=mysql_db) |
|
|
|
self.cursor = self.db.cursor() |
|
|
|
self.prefix = db_prefix |
|
|
|
self.members = dict() |
|
|
|
self.groups = dict() |
|
|
|
self.events = dict() |
|
|
|
self.event_confirmation_id = None |
|
|
|
sql = "SELECT usf_id,usf_name_intern FROM `adm_user_fields`" |
|
|
|
sql = f"SELECT usf_id,usf_name_intern FROM {self.prefix}_user_fields" |
|
|
|
self.cursor.execute(sql) |
|
|
|
self.userfields = dict(self.cursor.fetchall()) |
|
|
|
|
|
|
|
# Get the id for event confirmation role. |
|
|
|
# So it can exclude them from Groups |
|
|
|
|
|
|
|
sql = """SELECT cat_id |
|
|
|
FROM adm_categories |
|
|
|
sql = f"""SELECT cat_id |
|
|
|
FROM {self.prefix}_categories |
|
|
|
WHERE cat_name_intern = 'CONFIRMATION_OF_PARTICIPATION'""" |
|
|
|
self.cursor.execute(sql) |
|
|
|
self.event_confirmation_id = self.cursor.fetchone()[0] |
|
|
@ -41,8 +43,8 @@ class Admidio: |
|
|
|
def initMembers(self): |
|
|
|
"""Initialises all members in the Admidio installation""" |
|
|
|
|
|
|
|
sql = """SELECT usr_id, usr_login_name, usr_password |
|
|
|
FROM adm_users WHERE usr_valid = 1""" |
|
|
|
sql = f"""SELECT usr_id, usr_login_name, usr_password |
|
|
|
FROM {self.prefix}_users WHERE usr_valid = 1""" |
|
|
|
self.cursor.execute(sql) |
|
|
|
|
|
|
|
for row in self.cursor.fetchall(): |
|
|
@ -54,7 +56,7 @@ class Admidio: |
|
|
|
"""Initialises all groups in the Admidio installation""" |
|
|
|
|
|
|
|
sql = f"""SELECT rol_id, rol_name, rol_description |
|
|
|
FROM adm_roles |
|
|
|
FROM {self.prefix}_roles |
|
|
|
WHERE rol_valid = 1 |
|
|
|
AND rol_cat_id != {self.event_confirmation_id}""" |
|
|
|
self.cursor.execute(sql) |
|
|
@ -71,7 +73,7 @@ class Admidio: |
|
|
|
sql = f"""SELECT dat_id, dat_cat_id, dat_begin, dat_end, |
|
|
|
dat_headline, dat_description, |
|
|
|
dat_location, dat_country, dat_rol_id |
|
|
|
FROM adm_dates |
|
|
|
FROM {self.prefix}_dates |
|
|
|
WHERE dat_begin >'{datestring}'""" |
|
|
|
self.cursor.execute(sql) |
|
|
|
|
|
|
|