flaschengeist/geruecht/controller/mainController/mainJobTransactController.py

71 lines
3.2 KiB
Python
Raw Normal View History

import geruecht.controller.databaseController as dc
import geruecht.controller.emailController as ec
from geruecht.exceptions import TansactJobIsAnswerdException
from geruecht.logger import getDebugLogger
db = dc.DatabaseController()
emailController = ec.EmailController()
debug = getDebugLogger()
class Base:
def setTransactJob(self, from_user, to_user, date):
debug.info("set transact job from {{ {} }} to {{ {} }} on {{ {} }}".format(
from_user, to_user, date))
jobtransact = db.setTransactJob(from_user, to_user, date.date())
debug.debug("transact job is {{ {} }}".format(jobtransact))
debug.info("send mail with transact job to user")
emailController.sendMail(
jobtransact['to_user'], 'jobtransact', jobtransact)
return jobtransact
def getTransactJobFromUser(self, user, date):
debug.info(
"get transact job from user {{ {} }} on {{ {} }}".format(user, date))
retVal = db.getTransactJobFromUser(user, date.date())
debug.debug(
"transact job from user {{ {} }} is {{ {} }}".format(user, retVal))
return retVal
def getAllTransactJobFromUser(self, user, date):
debug.info(
"get all transact job from user {{ {} }} start on {{ {} }}".format(user, date))
retVal = db.getAllTransactJobFromUser(user, date.date())
debug.debug("all transact job are {{ {} }}".format(retVal))
return retVal
def getAllTransactJobToUser(self, user, date):
debug.info(
"get all transact job from to_user {{ {} }} start on {{ {} }}".format(user, date))
retVal = db.getAllTransactJobToUser(user, date.date())
debug.debug("all transact job are {{ {} }}".format(retVal))
return retVal
def getTransactJob(self, from_user, to_user, date):
debug.info("get transact job from user {{ {} }} to user {{ {} }} on {{ {} }}".format(
from_user, to_user, date))
retVal = db.getTransactJob(from_user, to_user, date.date())
debug.debug("transact job is {{ {} }}".format(retVal))
return retVal
def deleteTransactJob(self, from_user, to_user, date):
debug.info("delete transact job from user {{ {} }} to user {{ {} }} on {{ {} }}".format(
from_user, to_user, date))
transactJob = self.getTransactJob(from_user, to_user, date)
debug.debug("transact job is {{ {} }}".format(transactJob))
if transactJob['answerd']:
debug.warning(
"transactjob {{ {} }} can not delete because is answerd")
raise TansactJobIsAnswerdException(
"TransactJob is already answerd")
db.deleteTransactJob(from_user, to_user, date.date())
def answerdTransactJob(self, from_user, to_user, date, answer):
debug.info("answer transact job from user {{ {} }} to user {{ {} }} on {{ {} }} with answer {{ {} }}".format(
from_user, to_user, date, answer))
transactJob = db.updateTransactJob(
from_user, to_user, date.date(), answer)
debug.debug("transactjob is {{ {} }}".format(transactJob))
if answer:
debug.info("add worker on date {{ {} }}".format(date))
self.addWorker(to_user.uid, date)
return transactJob