from datetime import date import geruecht.controller.databaseController as dc from geruecht import getDebugLogger db = dc.DatabaseController() debug = getDebugLogger() class Base: def getJobInvites(self, from_user, to_user, date): debug.info("get JobInvites from_user {{ {} }} to_user {{ {} }} on date {{ {} }}".format(from_user, to_user, date)) if from_user is None: retVal = db.getJobInvitesToUser(to_user, date) elif to_user is None: retVal = db.getJobInvitesFromUser(from_user, date) else: raise Exception("from_user {{ {} }} and to_user {{ {} }} are None".format(from_user, to_user)) return retVal def setJobInvites(self, data): debug.info("set new JobInvites data {{ {} }}".format(data)) retVal = [] for jobInvite in data: from_user = jobInvite['from_user'] to_user = jobInvite['to_user'] on_date = date(jobInvite['date']['year'], jobInvite['date']['month'], jobInvite['date']['day']) debug.info("set new JobInvite from_user {{ {} }}, to_user {{ {} }}, on_date {{ {} }}") retVal.append(db.setJobInvite(from_user, to_user, on_date)) debug.debug("seted JobInvites are {{ {} }}".format(retVal)) return retVal def updateJobInvites(self, data): debug.info("update JobInvites data {{ {} }}".format(data)) return db.updateJobInvite(data) def deleteJobInvite(self, jobInvite): debug.info("delete JobInvite {{ {} }}".format(jobInvite)) db.deleteJobInvite(jobInvite)