Browse Source

change imports to relative imports. Adding refresh option

master
Rick 6 years ago
parent
commit
126e5b7a9a
1 changed files with 19 additions and 7 deletions
  1. +19
    -7
      admidio.py

+ 19
- 7
admidio.py View File

@ -1,8 +1,9 @@
import MySQLdb
import admidio_python_api.member as member
import admidio_python_api.group as group
import admidio_python_api.event as event
from admidio_python_api.exceptions import MemberNotFoundException
from .member import Member as member
from .group import Group as group
from .event import Event as event
from .exceptions import MemberNotFoundException
from datetime import datetime
from dateutil.relativedelta import relativedelta
@ -40,6 +41,17 @@ class Admidio:
def __del__(self):
self.db.close()
def refresh(self):
"""Refresh all users, groups and events that are stored"""
self.ready = False
self.members = dict()
self.groups = dict()
self.events = dict()
self.initMembers()
self.initGroups()
self.initEvents()
self.ready = True
def initMembers(self):
"""Initialises all members in the Admidio installation"""
@ -48,7 +60,7 @@ class Admidio:
self.cursor.execute(sql)
for row in self.cursor.fetchall():
self.members[row[0]] = member.Member(
self.members[row[0]] = member(
self.db, row[0], row[1],
row[2], self.userfields, self)
@ -62,7 +74,7 @@ class Admidio:
self.cursor.execute(sql)
for row in self.cursor.fetchall():
self.groups[row[0]] = group.Group(row[0], row[1], self)
self.groups[row[0]] = group(row[0], row[1], self)
def initEvents(self):
"""Initialises all comming events and passed events <3 months"""
@ -79,7 +91,7 @@ class Admidio:
self.cursor.execute(sql)
for row in self.cursor.fetchall():
self.events[row[0]] = event.Event(
self.events[row[0]] = event(
row[0], row[8], row[4], row[2], row[3], row[5],
row[6], row[7], self)


Loading…
Cancel
Save