def post(self): Guser = users.get_current_user() from church import ChurchMember if Guser: vstrChoice = self.request.get('vstrChoice') if vstrChoice == "0": vstrListName = self.request.get('vstrListName') vstrListDescription = self.request.get('vstrListDescription') vstrStartSendingDate = self.request.get('vstrStartSendingDate') DateList = vstrStartSendingDate.split("-") strYear = int(DateList[0]) strMonth = int(DateList[1]) strDay = int(DateList[2]) vstrDate = datetime.date(year=strYear,month=strMonth,day=strDay) vstrStartSendingTime = self.request.get('vstrStartSendingTime') TimeList = vstrStartSendingTime.split(":") strHour = int(TimeList[0]) strMinute = int(TimeList[1]) vstrTime = datetime.time(hour=strHour,minute=strMinute,second=0) findRequest = ChurchMember.query(ChurchMember.strMemberID == Guser.user_id()) thisChurchMemberList = findRequest.fetch() if len(thisChurchMemberList) > 0: thisChurchMember = thisChurchMemberList[0] else: thisChurchMember = ChurchMember() findRequest = MailingList.query(MailingList.strChurchID == thisChurchMember.strChurchID,MailingList.strListName == vstrListName,MailingList.strListDescription == vstrListDescription) thisMailingList = findRequest.fetch() if len(thisMailingList) > 0: thisMailing = thisMailingList[0] else: thisMailing = MailingList() thisMailing.writeListID(strinput=thisMailing.CreateListID()) thisMailing.writeChurchID(strinput=thisChurchMember.strChurchID) thisMailing.writeListName(strinput=vstrListName) thisMailing.writeListDescription(strinput=vstrListDescription) thisMailing.writeStartSendingDate(strinput=vstrDate) thisMailing.writeStartSendingTime(strinput=vstrTime) thisMailing.put() self.response.write("Mailing List successfully update")
def get(self): Guser = users.get_current_user() if Guser: findRequest = ChurchMember.query(ChurchMember.strMemberID == Guser.user_id()) thisProfileList = findRequest.fetch() if len(thisProfileList) > 0: thisProfile = thisProfileList[0] else: thisProfile = ChurchMember() template = template_env.get_template('templates/profile/profiles.html') context = {'thisProfile':thisProfile} self.response.write(template.render(context))
def get(self): Guser = users.get_current_user() from church import ChurchMember if Guser: findRequest = ChurchMember.query( ChurchMember.strMemberID == Guser.user_id()) thisChurchMemberList = findRequest.fetch() if len(thisChurchMemberList) > 0: thisChurchMember = thisChurchMemberList[0] else: findRequest = ChurchMember.query( ChurchMember.strEmail == Guser.email()) thisChurchMemberList = findRequest.fetch() if len(thisChurchMemberList) > 0: thisChurchMember = thisChurchMemberList[0] else: thisChurchMember = ChurchMember() findRequest = ForumKeys.query( ForumKeys.strChurchID == thisChurchMember.strChurchID) thisMyChurchForumsList = findRequest.fetch() thisDate = datetime.datetime.now() thisRecentDate = thisDate - timedelta(days=5) findRequest = ForumKeys.query(ForumKeys.strDate >= thisRecentDate) thisLatestForumsList = findRequest.fetch(limit=5) findRequest = ForumKeys.query().order(ForumKeys.strLikes, ForumKeys.strShares) thisTrendingForumsList = findRequest.fetch() template = template_env.get_template( 'templates/forums/forums.html') context = { 'thisMyChurchForumsList': thisMyChurchForumsList, 'thisLatestForumsList': thisLatestForumsList, 'thisTrendingForumsList': thisTrendingForumsList } self.response.write(template.render(context)) else: template = template_env.get_template( 'templates/forums/forums.html') context = {} self.response.write(template.render(context))
def post(self): Guser = users.get_current_user() from church import ChurchMember, UserRights if Guser: findRequest = UserRights.query( UserRights.strMemberID == Guser.user_id()) thisUserRightsList = findRequest.fetch() if len(thisUserRightsList) > 0: thisUserRight = thisUserRightsList[0] else: thisUserRight = UserRights() findRequest = ChurchMember.query( ChurchMember.strMemberID == Guser.user_id()) thisChurchMemberList = findRequest.fetch() if len(thisChurchMemberList) > 0: thisChurchMember = thisChurchMemberList[0] else: thisChurchMember = ChurchMember() if thisUserRight.strAdminUser or thisUserRight.strSuperUser: vstrChoice = self.request.get('vstrChoice') if vstrChoice == "0": vstrNames = self.request.get('vstrNames') vstrSurname = self.request.get('vstrSurname') vstrOccasion = self.request.get('vstrOccasion') vstrTextTestament = self.request.get('vstrTextTestament') thisTestament = Testimony() thisTestament.writeChurchBranchID( strinput=thisChurchMember.strChurchBranchID) thisTestament.writeChurchID( strinput=thisChurchMember.strChurchID) thisTestament.writeNames(strinput=vstrNames) thisTestament.writeSurname(strinput=vstrSurname) thisTestament.writeOccasion(strinput=vstrOccasion) thisTestament.writeTestament(strinput=vstrTextTestament) thisTestament.put() self.response.write("Testament successfully uploaded")
def get(self): Guser = users.get_current_user() from church import ChurchMember, UserRights if Guser: findRequests = ChurchMember.query( ChurchMember.strMemberID == Guser.user_id()) thisChurchMemberList = findRequests.fetch() if len(thisChurchMemberList) > 0: thisChurchMember = thisChurchMemberList[0] else: thisChurchMember = ChurchMember() findRequests = UserRights.query( UserRights.strMemberID == Guser.user_id()) thisUserRightsList = findRequests.fetch() if len(thisUserRightsList) > 0: thisUserRight = thisUserRightsList[0] else: thisUserRight = UserRights() if thisUserRight.strAdminUser or thisUserRight.strSuperUser: URL = self.request.url URLlist = URL.split("/") vstrCell = URLlist[len(URLlist) - 1] findRequest = Contacts.query( Contacts.strCell == vstrCell, Contacts.strChurchID == thisChurchMember.strChurchID) thisContactList = findRequest.fetch() if len(thisContactList) > 0: thisContact = thisContactList[0] else: thisContact = Contacts() template = template_env.get_template( 'templates/contacts/thisContact.html') context = {'thisContact': thisContact} self.response.write(template.render(context))
def get(self): Guser = users.get_current_user() if Guser: URL = self.request.url URLlist = URL.split("/") vstrAdminReference = URLlist[len(URLlist) - 1] findRequest = Administrators.query( Administrators.strAdminID == vstrAdminReference) thisAdminList = findRequest.fetch() if len(thisAdminList) > 0: thisAdmin = thisAdminList[0] else: thisAdmin = Administrators() findRequest = ChurchMember.query( ChurchMember.strMemberID == vstrAdminReference) thisChurchMemberList = findRequest.fetch() if len(thisChurchMemberList) > 0: thisChurchMember = thisChurchMemberList[0] else: thisChurchMember = ChurchMember() findRequest = Churches.query( Churches.strChurchID == thisChurchMember.strChurchID) thisChurchesList = findRequest.fetch() if len(thisChurchesList) > 0: thisChurch = thisChurchesList[0] else: thisChurch = Churches() template = template_env.get_template( 'templates/dashboard/dashfiles/thisAdmin.html') context = { 'thisAdmin': thisAdmin, 'thisChurchMember': thisChurchMember, 'thisChurch': thisChurch } self.response.write(template.render(context))
def AdvanceIndex(self,strinput): from church import ChurchMember try: Guser = users.get_current_user() findRequest = ChurchMember.query(ChurchMember.strMemberID == Guser.user_id()) thisChurchMemberList = findRequest.fetch() if len(thisChurchMemberList) > 0: thisChurchMember = thisChurchMemberList[0] else: thisChurchMember = ChurchMember() findRequest = Letters.query(Letters.strChurchID == thisChurchMember.strChurchID,Letters.strListID == strinput) thisLetterList = findRequest.fetch() return len(thisLetterList) except: return None
def get(self): Guser = users.get_current_user() from church import Churches, ChurchMember, Branches if Guser: findRequest = ChurchMember.query( ChurchMember.strMemberID == Guser.user_id()) thisChurchMemberList = findRequest.fetch() if len(thisChurchMemberList) > 0: thisChurchMember = thisChurchMemberList[0] else: thisChurchMember = ChurchMember() findRequest = Churches.query( Churches.strChurchID == thisChurchMember.strChurchID) thisChurchList = findRequest.fetch() if len(thisChurchList) > 0: thisChurch = thisChurchList[0] else: thisChurch = Churches() findRequest = Branches.query( Branches.strChurchID == thisChurch.strChurchID) thisBranchesList = findRequest.fetch() vstrTotalBranches = str(len(thisBranchesList)) findRequest = ChurchMember.query( ChurchMember.strChurchID == thisChurch.strChurchID) thisChurchMebersList = findRequest.fetch() vstrTotalChurchMembers = str(len(thisChurchMebersList)) template = template_env.get_template('templates/admin.html') context = { 'thisChurch': thisChurch, 'thisChurchMember': thisChurchMember, 'vstrTotalBranches': vstrTotalBranches, 'vstrTotalChurchMembers': vstrTotalChurchMembers } self.response.write(template.render(context))
def get(self): Guser = users.get_current_user() from church import ChurchMember if Guser: findRequest = ChurchMember.query(ChurchMember.strMemberID == Guser.user_id()) thisChurchMemberList = findRequest.fetch() if len(thisChurchMemberList) > 0: thisChurchMember = thisChurchMemberList[0] else: thisChurchMember = ChurchMember() findRequest = MailingList.query(MailingList.strChurchID == thisChurchMember.strChurchID) thisMailingList = findRequest.fetch() template = template_env.get_template('templates/newsletter/newsletter.html') context = {'thisMailingList':thisMailingList} self.response.write(template.render(context))
def get(self): Guser = users.get_current_user() from church import ChurchMember, UserRights if Guser: findRequest = UserRights.query( UserRights.strMemberID == Guser.user_id()) thisUserRightsList = findRequest.fetch() if len(thisUserRightsList) > 0: thisUserRight = thisUserRightsList[0] else: thisUserRight = UserRights() findRequest = ChurchMember.query( ChurchMember.strMemberID == Guser.user_id()) thisChurchMemberList = findRequest.fetch() if len(thisChurchMemberList) > 0: thisChurchMember = thisChurchMemberList[0] else: thisChurchMember = ChurchMember() if thisUserRight.strAdminUser or thisUserRight.strSuperUser: findRequest = Testimony.query( Testimony.strChurchID == thisChurchMember.strChurchID, Testimony.strChurchBranchID == thisChurchMember.strChurchBranchID) thisTestimonyList = findRequest.fetch() template = template_env.get_template( 'templates/testimony/testimony.html') context = {'thisTestimonyList': thisTestimonyList} self.response.write(template.render(context)) else: template = template_env.get_template( 'templates/subRestricted.html') context = {'thisChurchMember': thisChurchMember} self.response.write(template.render(context))
def get(self): Guser = users.get_current_user() from church import ChurchMember,UserRights if Guser: URL = self.request.url vstrURLlist = URL.split("/") vstrListID = vstrURLlist[len(vstrURLlist) - 1] findRequest = UserRights.query(UserRights.strMemberID == Guser.user_id()) thisUserRightList = findRequest.fetch() if len(thisUserRightList) > 0: thisUserRight = thisUserRightList[0] else: thisUserRight = UserRights() findRequest = ChurchMember.query(ChurchMember.strMemberID == Guser.user_id()) thisChurchMemberList = findRequest.fetch() if len(thisChurchMemberList) > 0: thisChurchMember = thisChurchMemberList[0] else: thisChurchMember = ChurchMember() if thisUserRight.strSuperUser or thisUserRight.strAdminUser: findRequest = MailingList.query(MailingList.strListID == vstrListID,MailingList.strChurchID == thisChurchMember.strChurchID) thisMailingList = findRequest.fetch() if len(thisMailingList) > 0: thisNewsLetter = thisMailingList[0] else: thisNewsLetter = MailingList() template = template_env.get_template('templates/newsletter/thisNewsletter.html') context = {'thisNewsLetter':thisNewsLetter} self.response.write(template.render(context))
def get(self): from events import Birthdays from church import ChurchMember from mysms import SMSAccount findRequest = Birthdays.query() thisBirthDaysList = findRequest.fetch() thisDate = datetime.datetime.now() thisDate = thisDate.now() for thisBirthDay in thisBirthDaysList: if thisBirthDay.strAutoSend: findRequest = ChurchMember.query(ChurchMember.strChurchID == thisBirthDay.strChurchID) thisChurchMemberList = findRequest.fetch() for thisChurchMember in thisChurchMemberList: if (thisChurchMember.strMonth == thisDate.month) and (thisChurchMember.strDay == thisDate.day) and (thisChurchMember.strCell <> None): findRequest = SMSAccount.query(SMSAccount.strChurchID == thisChurchMember.strChurchID) thisSMSAccountList = findRequest.fetch() if len(thisSMSAccountList) > 0: thisSMSAccount = thisSMSAccountList[0] if (thisSMSAccount.strTotalSMS > 1): if thisBirthDay.SendBirthdayWishes(strMessage=thisBirthDay.strBirthdayMessage,strCell=thisChurchMember.strCell,strPortal=thisSMSAccount.strUsePortal): if thisSMSAccount.strUsePortal == "Budget": thisSMSAccount.strTotalSMS = thisSMSAccount.strTotalSMS - 1 thisSMSAccount.put() else: logging.info("Error sending birthday messages") else: pass #TODO- Send a notification to the user indicating that their SMS Credits are insufficient and notifications can no loner be sent else: pass else: pass else: pass
def post(self): Guser = users.get_current_user() from dashboard import AppRequests, Administrators if Guser: vstrReference = self.request.get('vstrReference') vstrIDNumber = self.request.get('vstrIDNumber') findRequest = AppRequests.query( AppRequests.strIDNumber == vstrIDNumber) thisAppRequestsList = findRequest.fetch() if len(thisAppRequestsList) > 0: thisAppRequest = thisAppRequestsList[0] else: thisAppRequest = AppRequests() if thisAppRequest.strIDNumber == vstrIDNumber: thisAppRequest.writeRequestAccepted(strinput=True) findRequest = ChurchMember.query( ChurchMember.strMemberID == vstrReference) thisChurchMemberList = findRequest.fetch() if len(thisChurchMemberList) > 0: thisChurchMember = thisChurchMemberList[0] else: thisChurchMember = ChurchMember() thisChurchMember.writeMemberID(strinput=vstrReference) thisChurchMember.writeCell(strinput=thisAppRequest.strCell) thisChurchMember.writeMemberNames( strinput=thisAppRequest.strNames) thisChurchMember.writeMemberSurname( strinput=thisAppRequest.strSurname) thisChurchMember.writeMemberIDNumber( strinput=thisAppRequest.strIDNumber) thisChurchMember.writeEmail(strinput=thisAppRequest.strEmail) thisChurchMember.writeProfileClaimed(strinput=True) findRequest = Churches.query( Churches.strFounderMemberID == vstrReference) thisChurchesList = findRequest.fetch() if len(thisChurchesList) > 0: thisNewChurch = thisChurchesList[0] else: thisNewChurch = Churches() thisNewChurch.createChurchID(strinput=vstrReference) thisNewChurch.writeFounderMemberID(strinput=vstrReference) thisChurchMember.writeChurchID( strinput=thisNewChurch.strChurchID) findRequest = UserRights.query( UserRights.strMemberID == vstrReference) thisUsersRightsList = findRequest.fetch() if len(thisUsersRightsList) > 0: thisUsersRight = thisUsersRightsList[0] else: thisUsersRight = UserRights() thisUsersRight.setAdminUser(strinput=True) thisUsersRight.setSuperUser(strinput=False) thisUsersRight.setChurchMember(strinput=False) thisUsersRight.writeMemberID(strinput=vstrReference) findRequest = Administrators.query( Administrators.strAdminID == thisUsersRight.strMemberID) thisAdminList = findRequest.fetch() if len(thisAdminList) > 0: thisAdmin = thisAdminList[0] else: thisAdmin = Administrators() thisAdmin.writeAdminID(strinput=thisUsersRight.strMemberID) thisAdmin.writeChurchID(strinput=thisNewChurch.strChurchID) thisAdmin.put() thisUsersRight.put() thisNewChurch.put() thisChurchMember.put() thisAppRequest.put() self.response.write("App Request Accepted") else: self.request.write("Error Data Mismatch")
def post(self): Guser = users.get_current_user() from church import ChurchMember, UserRights if Guser: findRequests = ChurchMember.query( ChurchMember.strMemberID == Guser.user_id()) thisChurchMemberList = findRequests.fetch() if len(thisChurchMemberList) > 0: thisChurchMember = thisChurchMemberList[0] else: thisChurchMember = ChurchMember() findRequests = UserRights.query( UserRights.strMemberID == Guser.user_id()) thisUserRightsList = findRequests.fetch() if len(thisUserRightsList) > 0: thisUserRight = thisUserRightsList[0] else: thisUserRight = UserRights() if thisUserRight.strAdminUser or thisUserRight.strSuperUser: vstrChoice = self.request.get('vstrChoice') if vstrChoice == "0": vstrNames = self.request.get('vstrNames') vstrSurname = self.request.get('vstrSurname') vstrCell = self.request.get('vstrCell') vstrTel = self.request.get('vstrTel') vstrFax = self.request.get('vstrFax') vstrEmail = self.request.get('vstrEmail') vstrWebsite = self.request.get('vstrWebsite') vstrDateCreated = self.request.get('vstrDateCreated') vstrTitle = self.request.get('vstrTitle') findRequests = Contacts.query( Contacts.strCell == vstrCell, Contacts.strChurchID == thisChurchMember.strChurchID, Contacts.strChurchBranchID == thisChurchMember.strChurchBranchID) thisContactList = findRequests.fetch() if len(thisContactList) > 0: thisContact = thisContactList[0] else: thisContact = Contacts() thisContact.writeContactID( strinput=thisContact.CreateContactID()) thisContact.writeChurchID( strinput=thisChurchMember.strChurchID) thisContact.writeChurchBranchID( strinput=thisChurchMember.strChurchBranchID) thisContact.writeNames(strinput=vstrNames) thisContact.writeSurname(strinput=vstrSurname) thisContact.writeCell(strinput=vstrCell) thisContact.writeTel(strinput=vstrTel) thisContact.writeFax(strinput=vstrFax) thisContact.writeEmail(strinput=vstrEmail) thisContact.writeWebsite(strinput=vstrWebsite) thisContact.writeDateCreated(strinput=vstrDateCreated) thisContact.writeTitle(strinput=vstrTitle) thisContact.put() self.response.write("Contact successfully uploaded") else: template = template_env.get_template( 'templates/subRestricted.html') context = {'thisChurchMember': thisChurchMember} self.response.write(template.render(context))
def get(self): from mysms import MessageSchedule, Messages, SMSContacts, Groups, SMSAccount, SMSPortalVodacom, DeliveryReport,SMSPortalBudget from church import ChurchMember Today = datetime.datetime.now() thisDate = Today.date() thisTime = Today.time() findRequest = MessageSchedule.query(MessageSchedule.strStatus == "Scheduled", MessageSchedule.strStartDate == thisDate, MessageSchedule.strStartTime >= thisTime) thisMessageScheduleList = findRequest.fetch() for thisSchedule in thisMessageScheduleList: findRequest = Messages.query(Messages.strMessageID == thisSchedule.strMessageID, Messages.strSubmitted == False) thisMessageList = findRequest.fetch() if len(thisMessageList) > 0: thisMessage = thisMessageList[0] else: thisMessage = Messages() findRequest = Groups.query(Groups.strGroupID == thisMessage.strGroupID) thisGroupList = findRequest.fetch() if len(thisGroupList) > 0: thisGroup = thisGroupList[0] else: thisGroup = Groups() findRequest = SMSAccount.query(SMSAccount.strChurchID == thisGroup.strChurchID) thisSMSAccountList = findRequest.fetch() if len(thisSMSAccountList) > 0: thisSMSAccount = thisSMSAccountList[0] else: thisSMSAccount = SMSAccount() thisSMSAccount.writeChurchID(strinput=thisGroup.strChurchID) thisSMSAccount.put() findRequest = SMSContacts.query(SMSContacts.strGroupID == thisMessage.strGroupID) thisContactsList = findRequest.fetch() ReceipientList = [] for thisContact in thisContactsList: if thisContact.strCellNumber != None: ReceipientList.append(thisContact.strCellNumber) if thisSchedule.strNotifyOnStart == True: findRequest = ChurchMember.query(ChurchMember.strMemberID == thisSchedule.strMemberID) thisChurchMemberList = findRequest.fetch() if len(thisChurchMemberList) > 0: thisChurchMember = thisChurchMemberList[0] if thisChurchMember.strCell in ReceipientList: pass else: ReceipientList.append(thisChurchMember.strCell) if thisSMSAccount.strTotalSMS >= len(ReceipientList): if thisSMSAccount.strUsePortal == "Vodacom": findRequest = SMSPortalVodacom.query() thisVodaList = findRequest.fetch() if len(thisVodaList) > 0: thisVoda = thisVodaList[0] else: thisVoda = SMSPortalVodacom() thisVoda.put() if thisVoda.CronSendMessages(strCellNumberList=ReceipientList, strMessage=thisMessage.strMessage, strAccountID=thisSMSAccount.strChurchID): thisSchedule.writeStatus(strinput="Completed") thisSchedule.put() thisMessage.writeDateSubmitted(strinput=thisDate) thisMessage.writeTimeSubmitted(strinput=thisTime) thisMessage.writeSubmitted(strinput=True) thisMessage.put() for StrCell in ReceipientList: #TODO- Investigate if Vodacom uses cell number for reference to obtain response thisDeliveryReport = DeliveryReport() thisDeliveryReport.writeMessageID(strinput=thisMessage.strMessageID) thisDeliveryReport.writeGroupID(strinput=thisMessage.strGroupID) thisDeliveryReport.writeCell(strinput=StrCell) thisDeliveryReport.writeDate(strinput=thisDate) thisDeliveryReport.writeTime(strinput=thisTime) thisDeliveryReport.writeDelivered(strinput=True) thisDeliveryReport.put() logging.info("Bulk SMS Schedule executed") # thisSMSAccount.strTotalSMS = thisSMSAccount.strTotalSMS - len(ReceipientList) # Vodacom Portal Subtracts its own Credits elif thisSMSAccount.strUsePortal == "Budget": findRequest = SMSPortalBudget.query() thisPortalList = findRequest.fetch() if len(thisPortalList) > 0: thisPortal = thisPortalList[0] else: thisPortal = SMSPortalBudget() for thisCell in ReceipientList: strRef = thisPortal.SendCronMessage(strMessage=thisMessage.strMessage,strCell=thisCell) if not(strRef == None): thisDeliveryReport = DeliveryReport() thisDeliveryReport.writeMessageID(strinput=thisMessage.strMessageID) thisDeliveryReport.writeGroupID(strinput=thisMessage.strGroupID) thisDeliveryReport.writeCell(strinput=thisCell) thisDeliveryReport.writeRef(strinput=strRef) thisDeliveryReport.writeDate(strinput=thisDate) thisDeliveryReport.writeTime(strinput=thisTime) thisDeliveryReport.writeDelivered(strinput=True) thisDeliveryReport.put() thisSMSAccount.strTotalSMS = thisSMSAccount.strTotalSMS - 1 else: thisDeliveryReport = DeliveryReport() thisDeliveryReport.writeMessageID(strinput=thisMessage.strMessageID) thisDeliveryReport.writeGroupID(strinput=thisMessage.strGroupID) thisDeliveryReport.writeCell(strinput=thisCell) thisDeliveryReport.writeRef(strinput="") thisDeliveryReport.writeDate(strinput=thisDate) thisDeliveryReport.writeTime(strinput=thisTime) thisDeliveryReport.writeDelivered(strinput=False) thisDeliveryReport.put() thisMessage.writeDateSubmitted(strinput=thisDate) thisMessage.writeTimeSubmitted(strinput=thisTime) thisMessage.writeSubmitted(strinput=True) thisMessage.put() #TODO- Include Budget Sending Capability to enable the Messages to be sent on schedule thisSMSAccount.put()
def post(self): Guser = users.get_current_user() from church import UserRights,ChurchMember,Branches if Guser: findRequest = UserRights.query(UserRights.strMemberID == Guser.user_id()) thisUserRightsList = findRequest.fetch() if len(thisUserRightsList) > 0: thisUserRight = thisUserRightsList[0] else: thisUserRight = UserRights() if thisUserRight.strAdminUser: vstrChoice = self.request.get('vstrChoice') if vstrChoice == "0": URL = self.request.url URLlist = URL.split("/") vstrIDNumber = URLlist[len(URLlist) - 1] findRequest = Employees.query(Employees.strIDNumber == vstrIDNumber) thisEmployeeList = findRequest.fetch() if len(thisEmployeeList) > 0: thisEmployee = thisEmployeeList[0] else: thisEmployee = Employees() findRequest = Branches.query(Branches.strChurchID == thisEmployee.strChurchID) thisBranchList = findRequest.fetch() template = template_env.get_template('templates/admin/churches/employees/personal.html') context = {'thisEmployee':thisEmployee,'thisBranchList':thisBranchList} self.response.write(template.render(context)) elif vstrChoice == "1": URL = self.request.url URLlist = URL.split("/") vstrIDNumber = URLlist[len(URLlist) - 1] findRequest = Salaries.query(Salaries.strIDNumber == vstrIDNumber) thisSalariesList = findRequest.fetch() try: thisSalary = thisSalariesList[0] except: thisSalary = Salaries() template = template_env.get_template('templates/admin/churches/employees/SalariesPayslips.html') context = {'thisSalariesList':thisSalariesList,'vstrIDNumber':vstrIDNumber,'vstrEmployeeID':thisSalary.strEmployeeID} self.response.write(template.render(context)) elif vstrChoice == "2": findRequest = ChurchMember.query(ChurchMember.strMemberID == Guser.user_id()) thisChurchMemberList = findRequest.fetch() if len(thisChurchMemberList) > 0: thisChurchMember = thisChurchMemberList[0] else: thisChurchMember = ChurchMember() vstrIDNumber = self.request.get('vstrIDNumber') vstrOverTimeRate = self.request.get('vstrOverTimeRate') vstrNormalRate = self.request.get('vstrNormalRate') vstrUIF = self.request.get('vstrUIF') vstrPaye = self.request.get('vstrPaye') vstrOtherDeductions = self.request.get('vstrOtherDeductions') vstrThisDate = self.request.get('vstrThisDate') vstrEmployeeID = self.request.get('vstrEmployeeID') try: vstrThisDateList = vstrThisDate.split("-") strYear = int(vstrThisDateList[0]) strMonth = int(vstrThisDateList[1]) strDay = int(vstrThisDateList[2]) vstrThisDate = datetime.date(year=strYear,month=strMonth,day=strDay) except: vstrThisDate = datetime.datetime.now() vstrThisDate = vstrThisDate.date() strYear = vstrThisDate.year strMonth = vstrThisDate.month findRequest = Salaries.query(Salaries.strIDNumber == vstrIDNumber,Salaries.strYear == str(strYear),Salaries.strMonth == str(strMonth)) thisSalaryList = findRequest.fetch(1) if len(thisSalaryList) > 0: thisSalary = thisSalaryList[0] else: thisSalary = Salaries() thisSalary.writeChurchID(strinput=thisChurchMember.strChurchID) thisSalary.writeChurchBranchID(strinput=thisChurchMember.strChurchBranchID) thisSalary.writeEmployeeID(strinput=vstrEmployeeID) thisSalary.writeIDNumber(strinput=vstrIDNumber) thisSalary.writeOvertimeRate(strinput=vstrOverTimeRate) thisSalary.writeNormalRate(strinput=vstrNormalRate) thisSalary.writeUIF(strinput=vstrUIF) thisSalary.writePaye(strinput=vstrPaye) thisSalary.writeOtherDeductions(strinput=vstrOtherDeductions) thisSalary.put() self.response.write("Salary Successfully updated") elif vstrChoice == "3": vstrIDNumber = self.request.get('vstrIDNumber') findRequest = BankingDetails.query(BankingDetails.strIDNumber == vstrIDNumber) thisBankingDetailsList = findRequest.fetch() if len(thisBankingDetailsList) > 0: thisBankingDetails = thisBankingDetailsList[0] else: thisBankingDetails = BankingDetails() template = template_env.get_template('templates/admin/churches/employees/BankDetails.html') context = {'thisBankDetails':thisBankingDetails} self.response.write(template.render(context)) elif vstrChoice == "4": vstrIDNumber = self.request.get('vstrIDNumber') vstrAccountOwner = self.request.get('vstrAccountOwner') vstrAccountNumber = self.request.get('vstrAccountNumber') vstrBankName = self.request.get('vstrBankName') vstrBranchName = self.request.get('vstrBranchName') vstrBranchCode = self.request.get('vstrBranchCode') vstrAccountType = self.request.get('vstrAccountType') findRequest = BankingDetails.query(BankingDetails.strIDNumber == vstrIDNumber) thisBankingDetailsList = findRequest.fetch() if len(thisBankingDetailsList) > 0: thisBankingDetails = thisBankingDetailsList[0] else: thisBankingDetails = BankingDetails() thisBankingDetails.writeIDNumber(strinput=vstrIDNumber) thisBankingDetails.writeAccountOwner(strinput=vstrAccountOwner) thisBankingDetails.writeAccountNumber(strinput=vstrAccountNumber) thisBankingDetails.writeBankName(strinput=vstrBankName) thisBankingDetails.writeBranchName(strinput=vstrBranchName) thisBankingDetails.writeBranchCode(strinput=vstrBranchCode) thisBankingDetails.writeAccountType(strinput=vstrAccountType) thisBankingDetails.put() self.response.write("Banking Details Successfully updated") elif vstrChoice == "5": vstrIDNumber = self.request.get('vstrIDNumber') findRequest = AttendanceRegister.query(AttendanceRegister.strIDNumber == vstrIDNumber) thisAttendanceRegisterList = findRequest.fetch() if len(thisAttendanceRegisterList) > 0: thisAttendance = thisAttendanceRegisterList[0] else: thisAttendance = AttendanceRegister() template = template_env.get_template('templates/admin/churches/employees/AttendanceRegister.html') context = {'thisAttendanceRegisterList':thisAttendanceRegisterList,'thisAttendance':thisAttendance,'vstrIDNumber':vstrIDNumber} self.response.write(template.render(context)) elif vstrChoice == "6": vstrNames = self.request.get('vstrNames') vstrSurname = self.request.get('vstrSurname') vstrIDNumber = self.request.get('vstrIDNumber') vstrPosition = self.request.get('vstrPosition') vstrContract = self.request.get('vstrContract') vstrPhyStandNumber = self.request.get('vstrPhyStandNumber') vstrPhyStreetName = self.request.get('vstrPhyStreetName') vstrPhyCityTown = self.request.get('vstrPhyCityTown') vstrPhyProvince = self.request.get('vstrPhyProvince') vstrPhyCountry = self.request.get('vstrPhyCountry') vstrPhyPostalCode = self.request.get('vstrPhyPostalCode') vstrBoxNumber = self.request.get('vstrBoxNumber') vstrCityTown = self.request.get('vstrCityTown') vstrProvince = self.request.get('vstrProvince') vstrCountry = self.request.get('vstrCountry') vstrPostalCode = self.request.get('vstrPostalCode') vstrSelectBranch = self.request.get('vstrSelectBranch') findRequest = ChurchMember.query(ChurchMember.strMemberID == Guser.user_id()) thisAdminList = findRequest.fetch() if len(thisAdminList) > 0: thisAdmin = thisAdminList[0] else: thisAdmin = ChurchMember() findRequest = Employees.query(Employees.strChurchID == thisAdmin.strChurchID,Employees.strIDNumber == vstrIDNumber) thisEmployeeList = findRequest.fetch() if len(thisEmployeeList) > 0: thisEmployee = thisEmployeeList[0] else: thisEmployee = Employees() thisEmployee.writeNames(strinput=vstrNames) thisEmployee.writeSurname(strinput=vstrSurname) thisEmployee.writeIDNumber(strinput=vstrIDNumber) thisEmployee.writePosition(strinput=vstrPosition) thisEmployee.writeContract(strinput=vstrContract) thisEmployee.writePhyStandNumber(strinput=vstrPhyStandNumber) thisEmployee.writePhyStreetName(strinput=vstrPhyStreetName) thisEmployee.writePhyCityTown(strinput=vstrPhyCityTown) thisEmployee.writePhyProvince(strinput=vstrPhyProvince) thisEmployee.writePhyCountry(strinput=vstrPhyCountry) thisEmployee.writePhyCountry(strinput=vstrPhyCountry) thisEmployee.writePhyPostalCode(strinput=vstrPhyPostalCode) thisEmployee.writeBoxNumber(strinput=vstrBoxNumber) thisEmployee.writeCityTown(strinput=vstrCityTown) thisEmployee.writeProvince(strinput=vstrProvince) thisEmployee.writeCountry(strinput=vstrCountry) thisEmployee.writePostalCode(strinput=vstrPostalCode) thisEmployee.writeChurchBranchID(strinput=vstrSelectBranch) thisEmployee.writeChurchID(strinput=thisAdmin.strChurchID) thisEmployee.put()
def post(self): from church import ChurchMember vstrChoice = self.request.get('vstrChoice') if vstrChoice == "0": vstrForumName = self.request.get('vstrForumName') vstrForumDescription = self.request.get('vstrForumDescription') vstrForumLandingPage = self.request.get('vstrForumLandingPage') Guser = users.get_current_user() findRequest = ChurchMember.query( ChurchMember.strMemberID == Guser.user_id()) thisChurchMemberList = findRequest.fetch() if len(thisChurchMemberList) > 0: thisChurchMember = thisChurchMemberList[0] else: findRequest = ChurchMember.query( ChurchMember.strEmail == Guser.email()) thisChurchMemberList = findRequest.fetch() if len(thisChurchMemberList) > 0: thisChurchMember = thisChurchMemberList[0] else: thisChurchMember = ChurchMember() findRequest = ForumKeys.query( ForumKeys.strForumName == vstrForumName, ForumKeys.strChurchID == thisChurchMember.strChurchID) thisForumList = findRequest.fetch() if len(thisForumList) > 0: thisForum = thisForumList[0] else: thisForum = ForumKeys() thisForum.writeForumID(strinput=thisForum.createForumID()) strThisDate = datetime.datetime.now() thisDate = strThisDate.date() thisTime = strThisDate.time() thisForum.writeTime(strinput=thisTime) thisForum.writeDate(strinput=thisDate) thisForum.writeChurchBranchID( strinput=thisChurchMember.strChurchBranchID) thisForum.writeChurchID(strinput=thisChurchMember.strChurchID) thisForum.writeForumName(strinput=vstrForumName) thisForum.writeForumDescription(strinput=vstrForumDescription) thisForum.writeForumPage(strinput=vstrForumLandingPage) thisForum.writeForumStatus(strinput="Active") thisForum.writeForumType(strinput="Public") thisForum.writeOwnerID(strinput=thisChurchMember.strMemberID) thisForum.writeForumSubscriptionStatus(strinput="Open") thisForum.put() self.response.write("Forum Successfully created") elif vstrChoice == "1": vstrForumID = self.request.get('vstrForumID') findRequest = ForumKeys.query(ForumKeys.strForumID == vstrForumID) thisForumList = findRequest.fetch() findRequest = Topic.query(Topic.strForumID == vstrForumID) thisTopicsList = findRequest.fetch() template = template_env.get_template( 'templates/forums/sub/topics.html') context = {'thisTopicsList': thisTopicsList} self.response.write(template.render(context)) elif vstrChoice == "2": vstrForumID = self.request.get('vstrForumID') vstrTopicName = self.request.get('vstrTopicName') vstrTopicDescription = self.request.get('vstrTopicDescription') findRequest = Topic.query(Topic.strForumID == vstrForumID, Topic.strTopicName == vstrTopicName) thisTopicsList = findRequest.fetch() if len(thisTopicsList) > 0: thisTopic = thisTopicsList[0] else: thisTopic = Topic() thisTopic.writeTopicID(strinput=thisTopic.createTopicID()) thisTopic.writeTopicName(strinput=vstrTopicName) thisTopic.writeForumID(strinput=vstrForumID) thisTopic.writeTopicDescription(strinput=vstrTopicDescription) strthisDate = datetime.datetime.now() thisDate = strthisDate.date() thisTime = strthisDate.time() thisTopic.writeDate(strinput=thisDate) thisTopic.writeTime(strinput=thisTime) thisTopic.put() self.response.write("Topic successfully uploaded") elif vstrChoice == "3": vstrForumID = self.request.get('vstrForumID') findRequest = ForumKeys.query(ForumKeys.strForumID == vstrForumID) thisForumList = findRequest.fetch() Guser = users.get_current_user() findRequest = ChurchMember.query( ChurchMember.strMemberID == Guser.user_id()) thisChurchMemberList = findRequest.fetch() if len(thisChurchMemberList) > 0: thisChurchMember = thisChurchMemberList[0] else: findRequest = ChurchMember.query( ChurchMember.strEmail == Guser.email()) thisChurchMemberList = findRequest.fetch() if len(thisChurchMemberList) > 0: thisChurchMember = thisChurchMemberList[0] else: thisChurchMember = ChurchMember() findRequest = ForumSubscriptions.query( ForumSubscriptions.strForumID == vstrForumID, ForumSubscriptions.strUserID == thisChurchMember.strMemberID) thisSubscriptionList = findRequest.fetch() if len(thisSubscriptionList) > 0: thisSubscription = thisSubscriptionList[0] else: thisSubscription = ForumSubscriptions() template = template_env.get_template( 'templates/forums/sub/subscribe.html') context = {'thisSubscription': thisSubscription} self.response.write(template.render(context)) elif vstrChoice == "4": vstrForumID = self.request.get('vstrForumID') vstrNames = self.request.get('vstrNames') vstrSurname = self.request.get('vstrSurname') vstrCell = self.request.get('vstrCell') vstrEmail = self.request.get('vstrEmail') findRequest = ForumSubscriptions.query( ForumSubscriptions.strForumID == vstrForumID) thisSubscriptionList = findRequest.fetch() if len(thisSubscriptionList) > 0: thisSubscription = thisSubscriptionList[0] else: thisSubscription = ForumSubscriptions() Guser = users.get_current_user() thisSubscription.writeForumID(strinput=vstrForumID) thisSubscription.writeUserID(strinput=Guser.user_id) thisSubscription.writeNames(strinput=vstrNames) thisSubscription.writeSurname(strinput=vstrSurname) thisSubscription.writeCell(strinput=vstrCell) thisSubscription.writeEmail(strinput=vstrEmail) thisSubscription.put() self.response.write("Subscriptions are done...") elif vstrChoice == "5": pass elif vstrChoice == "6": vstrForumID = self.request.get('vstrForumID') vstrTopicID = self.request.get('vstrTopicID') findRequest = Topic.query(Topic.strTopicID == vstrTopicID) thisTopicList = findRequest.fetch() if len(thisTopicList) > 0: thisTopic = thisTopicList[0] else: thisTopic = Topic() findRequest = ForumKeys.query(ForumKeys.strForumID == vstrForumID) thisForumList = findRequest.fetch() if len(thisForumList) > 0: thisForum = thisForumList[0] else: thisForum = ForumKeys() template = template_env.get_template( 'templates/forums/sub/newarticle.html') context = {'thisTopic': thisTopic, 'thisForum': thisForum} self.response.write(template.render(context))
def post(self): Guser = users.get_current_user() from church import ChurchMember, UserRights if Guser: findRequests = ChurchMember.query( ChurchMember.strMemberID == Guser.user_id()) thisChurchMemberList = findRequests.fetch() if len(thisChurchMemberList) > 0: thisChurchMember = thisChurchMemberList[0] else: thisChurchMember = ChurchMember() findRequests = UserRights.query( UserRights.strMemberID == Guser.user_id()) thisUserRightsList = findRequests.fetch() if len(thisUserRightsList) > 0: thisUserRight = thisUserRightsList[0] else: thisUserRight = UserRights() if thisUserRight.strAdminUser or thisUserRight.strSuperUser: vstrChoice = self.request.get('vstrChoice') if vstrChoice == "0": vstrCell = self.request.get('vstrCell') findRequests = Contacts.query( Contacts.strCell == vstrCell, Contacts.strChurchID == thisChurchMember.strChurchID) thisContactList = findRequests.fetch() if len(thisContactList) > 0: thisContact = thisContactList[0] else: thisContact = Contacts() findRequests = Notes.query( Notes.strContactID == thisContact.strContactID) thisNotesList = findRequests.fetch() findRequests = PostalAddress.query( PostalAddress.strContactID == thisContact.strContactID) thisPostalAddressList = findRequests.fetch() if len(thisPostalAddressList) > 0: thisPostalAddress = thisPostalAddressList[0] else: thisPostalAddress = PostalAddress() thisPostalAddress.writeContactID( strinput=thisContact.strContactID) thisPostalAddress.writeChurchID( strinput=thisContact.strChurchID) thisPostalAddress.put() findRequests = PhysicalAddress.query( PhysicalAddress.strContactID == thisContact.strContactID) thisPhysicalAddressList = findRequests.fetch() if len(thisPhysicalAddressList) > 0: thisPhysicalAddress = thisPhysicalAddressList[0] else: thisPhysicalAddress = PhysicalAddress() thisPhysicalAddress.writeContactID( strinput=thisContact.strContactID) thisPhysicalAddress.writeChurchID( strinput=thisContact.strChurchID) thisPhysicalAddress.put() template = template_env.get_template( 'templates/contacts/sub/manage.html') context = { 'thisContact': thisContact, 'thisNotesList': thisNotesList, 'thisPostalAddress': thisPostalAddress, 'thisPhysicalAddress': thisPhysicalAddress } self.response.write(template.render(context)) elif vstrChoice == "1": vstrContactID = self.request.get('vstrContactID') vstrPostalCode = self.request.get('vstrPostalCode') vstrCountry = self.request.get('vstrCountry') vstrProvince = self.request.get('vstrProvince') vstrCityTown = self.request.get('vstrCityTown') vstrBox = self.request.get('vstrBox') findRequests = PostalAddress.query( PostalAddress.strContactID == vstrContactID) thisPostalAddressList = findRequests.fetch() if len(thisPostalAddressList) > 0: thisPostalAddress = thisPostalAddressList[0] else: thisPostalAddress = PostalAddress() thisPostalAddress.writeChurchID( strinput=thisChurchMember.strChurchID) thisPostalAddress.writeContactID(strinput=vstrContactID) thisPostalAddress.writeBox(strinput=vstrBox) thisPostalAddress.writeCityTown(strinput=vstrCityTown) thisPostalAddress.writeProvince(strinput=vstrProvince) thisPostalAddress.writeCountry(strinput=vstrCountry) thisPostalAddress.writePostalCode(strinput=vstrPostalCode) thisPostalAddress.put() self.response.write("Postal Address updated successfully") elif vstrChoice == "2": vstrSubject = self.request.get('vstrSubject') vstrNotes = self.request.get('vstrNotes') vstrContactID = self.request.get('vstrContactID') findRequests = Notes.query( Notes.strContactID == vstrContactID, Notes.strSubject == vstrSubject, Notes.strNotes == vstrNotes) thisNotesList = findRequests.fetch() if len(thisNotesList) > 0: thisNote = thisNotesList[0] else: thisNote = Notes() thisNote.writeContactID(strinput=vstrContactID) thisNote.writeChurchID( strinput=thisChurchMember.strChurchID) thisDate = datetime.datetime.now() thisDate = thisDate.date() thisNote.writeDateTaken(strinput=thisDate) thisTime = datetime.datetime.now() thisTime = thisTime.time() thisTime = datetime.time(hour=thisTime.hour, minute=thisTime.minute, second=thisTime.second) thisNote.writeTimeTaken(strinput=thisTime) thisNote.writeSubject(strinput=vstrSubject) thisNote.writeNotes(strinput=vstrNotes) thisNote.put() self.response.write("Note successfully uploaded") elif vstrChoice == "3": vstrContactID = self.request.get('vstrContactID') vstrStandNumber = self.request.get('vstrStandNumber') vstrStreetName = self.request.get('vstrStreetName') vstrPhyCityTown = self.request.get('vstrPhyCityTown') vstrPhyProvince = self.request.get('vstrPhyProvince') vstrPhyCountry = self.request.get('vstrPhyCountry') vstrPhyPostalCode = self.request.get('vstrPhyPostalCode') findRequests = PhysicalAddress.query( PhysicalAddress.strContactID == vstrContactID) thisPhysicalAddressList = findRequests.fetch() if len(thisPhysicalAddressList) > 0: thisPhysicalAddress = thisPhysicalAddressList[0] else: thisPhysicalAddress = PhysicalAddress() thisPhysicalAddress.writeContactID(strinput=vstrContactID) thisPhysicalAddress.writeChurchID( strinput=thisChurchMember.strChurchID) thisPhysicalAddress.writeStandNumber( strinput=vstrStandNumber) thisPhysicalAddress.writeStreetName( strinput=vstrStreetName) thisPhysicalAddress.writeCityTown(strinput=vstrPhyCityTown) thisPhysicalAddress.writeProvince(strinput=vstrPhyProvince) thisPhysicalAddress.writeCountry(strinput=vstrPhyCountry) thisPhysicalAddress.writePostalCode( strinput=vstrPhyPostalCode) thisPhysicalAddress.put() self.response.write( "Physical Address successfully updated") elif vstrChoice == "4": vstrCell = self.request.get('vstrCell') findRequests = Contacts.query( Contacts.strChurchID == thisChurchMember.strChurchID, Contacts.strCell == vstrCell) thisContactList = findRequests.fetch() if len(thisContactList) > 0: thisContact = thisContactList[0] else: thisContact = Contacts() findRequests = SMSInBox.query( SMSInBox.strContactID == thisContact.strContactID) thisInBoxMessagesList = findRequests.fetch() findRequests = SMSOutBox.query( SMSOutBox.strContactID == thisContact.strContactID) thisSMSOutBoxList = findRequests.fetch() template = template_env.get_template( 'templates/contacts/sub/sms.html') context = { 'thisInBoxMessagesList': thisInBoxMessagesList, 'thisSMSOutBoxList': thisSMSOutBoxList, 'thisContact': thisContact } self.response.write(template.render(context)) elif vstrChoice == "5": from mysms import SMSAccount, SMSPortalVodacom, SMSPortalBudget, DeliveryReport vstrMessage = self.request.get('vstrMessage') vstrContactID = self.request.get('vstrContactID') vstrCell = self.request.get('vstrCell') findRequest = SMSAccount.query( SMSAccount.strChurchID == thisChurchMember.strChurchID) thisSMSAccountList = findRequest.fetch() if len(thisSMSAccountList) > 0: thisSMSAccount = thisSMSAccountList[0] else: thisSMSAccount = SMSAccount() if thisSMSAccount.strUsePortal == "Vodacom": findRequest = SMSPortalVodacom.query() thisPortalList = findRequest.fetch() if len(thisPortalList) > 0: thisPortal = thisPortalList[0] else: thisPortal = SMSPortalVodacom() i = 0 message = mail.EmailMessage() message.sender = thisPortal.strSenderAddress message.to = thisPortal.strEmailAddress message.subject = vstrCell message.body = vstrMessage message.send() thisPortal.strAvailableCredit = thisPortal.strAvailableCredit - 1 thisDeliveryReport = DeliveryReport() thisDeliveryReport.writeGroupID(vstrContactID) thisDeliveryReport.writeCell(vstrCell) thisDeliveryReport.writeDelivered(strinput=True) thisDate = datetime.datetime.now() strThisDate = thisDate.date() strThisTime = thisDate.time() strThisTime = datetime.time(hour=strThisTime.hour, minute=strThisTime.minute, second=strThisTime.second) thisDeliveryReport.writeDate(strinput=strThisDate) thisDeliveryReport.writeTime(strinput=strThisTime) thisDeliveryReport.writeMessageID(strinput=vstrMessage) thisDeliveryReport.put() thisPortal.put() thisSMSAccount.strTotalSMS = thisSMSAccount.strTotalSMS - 1 thisSMSAccount.put() thisOutBox = SMSOutBox() thisOutBox.writeMessage(strinput=vstrMessage) thisOutBox.writeContactID(strinput=vstrContactID) thisOutBox.writeMessageID( strinput=thisOutBox.CreateMessageID()) thisOutBox.writeDateSent(strinput=strThisDate) thisOutBox.writeTimeSent(strinput=strThisTime) thisOutBox.put() self.response.write("SMS Successfully sent") elif vstrChoice == "6": vstrCell = self.request.get('vstrCell') findRequest = Contacts.query(Contacts.strCell == vstrCell) thisContactList = findRequest.fetch() if len(thisContactList) > 0: thisContact = thisContactList[0] else: thisContact = Contacts() findRequest = EmailInBox.query( EmailInBox.strContactID == thisContact.strContactID) thisEmailInboxList = findRequest.fetch() findRequest = EmailOutBox.query( EmailOutBox.strContactID == thisContact.strContactID) thisEmailOutBoxList = findRequest.fetch() template = template_env.get_template( 'templates/contacts/sub/email.html') context = { 'vstrCell': vstrCell, 'thisEmailInboxList': thisEmailInboxList, 'thisEmailOutBoxList': thisEmailOutBoxList } self.response.write(template.render(context)) elif vstrChoice == "7": vstrCell = self.request.get('vstrCell') vstrSubject = self.request.get('vstrSubject') vstrMessage = self.request.get('vstrMessage') findRequest = Contacts.query(Contacts.strCell == vstrCell) thisContactList = findRequest.fetch() if len(thisContactList) > 0: thisContact = thisContactList[0] else: thisContact = Contacts() findRequest = EmailOutBox.query( EmailOutBox.strSubject == vstrSubject, EmailOutBox.strMessage == vstrMessage) thisEmailOutBoxList = findRequest.fetch() if len(thisEmailOutBoxList) > 0: thisEmailOutBox = thisEmailOutBoxList[0] else: thisEmailOutBox = EmailOutBox() thisEmailOutBox.writeContactID( strinput=thisContact.strContactID) thisEmailOutBox.writeMessageID( strinput=thisEmailOutBox.CreateMessageID()) thisEmailOutBox.writeMessage(strinput=vstrMessage) thisDate = datetime.datetime.now() thisDate = thisDate.date() thisTime = datetime.datetime.now() thisTime = datetime.time(hour=thisTime.hour, minute=thisTime.minute, second=thisTime.second) if thisEmailOutBox.sendEmail(): thisEmailOutBox.writeIsSent(strinput=True) thisEmailOutBox.writeTimeSent(strinput=thisTime) thisEmailOutBox.writeDateSent(strinput=thisDate) thisEmailOutBox.put() self.response.write("Successfully sent an Email") else: self.response.write("Error Sending Email")
def post(self): Guser = users.get_current_user() from church import ChurchMember,UserRights if Guser: vstrChoice = self.request.get('vstrChoice') findRequest = UserRights.query(UserRights.strMemberID == Guser.user_id()) thisUserRightList = findRequest.fetch() if len(thisUserRightList) > 0: thisUserRight = thisUserRightList[0] else: thisUserRight = UserRights() findRequest = ChurchMember.query(ChurchMember.strMemberID == Guser.user_id()) thisChurchMemberList = findRequest.fetch() if len(thisChurchMemberList) > 0: thisChurchMember = thisChurchMemberList[0] else: thisChurchMember = ChurchMember() vstrDateTime = datetime.datetime.now() strDate = vstrDateTime.date() strTime = datetime.time(hour=vstrDateTime.hour,minute=vstrDateTime.minute,second=vstrDateTime.second) if thisUserRight.strAdminUser or thisUserRight.strSuperUser: if vstrChoice == "0": vstrListID = self.request.get('vstrListID') findRequest = Letters.query(Letters.strListID == vstrListID) thisLettersList = findRequest.fetch() template = template_env.get_template('templates/newsletter/sub/letters.html') context = {'thisLettersList':thisLettersList,'vstrListID':vstrListID} self.response.write(template.render(context)) elif vstrChoice == "1": vstrLetterHeading = self.request.get('vstrLetterHeading') vstrLetterBody = self.request.get('vstrLetterBody') vstrListID = self.request.get('vstrListID') findRequest = Letters.query(Letters.strLetterHeading == vstrLetterHeading) thisLettersList = findRequest.fetch() if len(thisLettersList) > 0: thisLetter = thisLettersList[0] else: thisLetter = Letters() thisLetter.writeArticlesID(strinput=thisLetter.CreateArticleID()) thisLetter.writeIndex(strinput=thisLetter.AdvanceIndex(strinput=vstrListID)) thisLetter.writeHostedLink(strinput=thisLetter.CreateHostedLink()) thisLetter.writeDateCreated(strinput=strDate) thisLetter.writeTimeCreated(strinput=strTime) thisLetter.writeMemberID(strinput=Guser.user_id()) thisLetter.writeChurchID(strinput=thisChurchMember.strChurchID) thisLetter.writeLetterHeading(strinput=vstrLetterHeading) thisLetter.writeLetterBody(strinput=vstrLetterBody) thisLetter.writeListID(strinput=vstrListID) thisLetter.put() self.response.write("Article successfully updated") elif vstrChoice == "2": vstrListID = self.request.get('vstrListID') findRequest = ContactList.query(ContactList.strListID == vstrListID) thisContactList = findRequest.fetch() template = template_env.get_template('templates/newsletter/sub/contact.html') context = {'thisContactList':thisContactList,'vstrListID':vstrListID} self.response.write(template.render(context)) elif vstrChoice == "3": vstrListID = self.request.get('vstrListID') vstrContacts = self.request.get('vstrContacts') findRequest = ChurchMember.query(ChurchMember.strMemberID == Guser.user_id()) thisChurchMemberList = findRequest.fetch() if len(thisChurchMemberList) > 0: thisChurchMember = thisChurchMemberList[0] else: thisChurchMember = ChurchMember() strContactList = vstrContacts.split("|") for thisContact in strContactList: thisContactList = thisContact.split(",") if len(thisContactList) == 4: findRequest = ContactList.query(ContactList.strListID == vstrListID,ContactList.strEmail == thisContactList[1]) strthisContactList = findRequest.fetch() if len(strthisContactList) > 0: strContact = strthisContactList[0] else: strContact = ContactList() strContact.writeListID(strinput=vstrListID) strContact.writeCell(strinput=thisContactList[0]) strContact.writeEmail(strinput=thisContactList[1]) strContact.writeNames(strinput=thisContactList[2]) strContact.writeSurname(strinput=thisContactList[3]) strContact.writeChurchID(strinput=thisChurchMember.strChurchID) strContact.put() self.response.write("Contact list updated successfully") elif vstrChoice == "4": vstrListID = self.request.get('vstrListID') vstrNames = self.request.get('vstrNames') vstrSurname = self.request.get('vstrSurname') vstrCellNumber = self.request.get('vstrCellNumber') vstrEmail = self.request.get('vstrEmail') findRequest = ChurchMember.query(ChurchMember.strMemberID == Guser.user_id()) thisChurchMemberList = findRequest.fetch() if len(thisChurchMemberList) > 0: thisChurchMember = thisChurchMemberList[0] else: thisChurchMember = ChurchMember() findRequest = ContactList.query(ContactList.strListID == vstrListID,ContactList.strEmail == vstrEmail) thisContactList = findRequest.fetch() if len(thisContactList) > 0: thisContact = thisContactList[0] else: thisContact = ContactList() thisContact.writeChurchID(strinput=thisChurchMember.strChurchID) thisContact.writeListID(strinput=vstrListID) thisContact.writeNames(strinput=vstrNames) thisContact.writeSurname(strinput=vstrSurname) thisContact.writeCell(strinput=vstrCellNumber) thisContact.writeEmail(strinput=vstrEmail) thisContact.put() self.response.write("Successfully uploaded contact") elif vstrChoice == "5": vstrListID = self.request.get('vstrListID') vstrListID = vstrListID.strip() vstrRemoveEmail = self.request.get('vstrRemoveEmail') vstrRemoveEmail = vstrRemoveEmail.strip() findRequest = ContactList.query(ContactList.strEmail == vstrRemoveEmail,ContactList.strListID == vstrListID) thisContactList = findRequest.fetch() contactRemoved = False for thisContact in thisContactList: thisContact.key.delete() contactRemoved = True if contactRemoved: self.response.write("Successfully removed email") else: self.response.write("Contact not removed : " + vstrRemoveEmail) elif vstrChoice == "6": vstrListID = self.request.get('vstrListID') vstrListID = vstrListID.strip() findRequest = MailingList.query(MailingList.strListID == vstrListID) thisMailingList = findRequest.fetch() template = template_env.get_template('templates/newsletter/sub/schedule.html') context = {'thisMailingList':thisMailingList,'vstrListID':vstrListID} self.response.write(template.render(context)) elif vstrChoice == "7": vstrListID = self.request.get('vstrListID') vstrDate = self.request.get('vstrDate') strDateList = vstrDate.split("/") strMonth = strDateList[0] strDay = strDateList[1] strYear = strDateList[2] vstrTime = self.request.get('vstrTime') if "AM" in vstrTime: vstrTime = vstrTime.replace("AM","") vstrTime = vstrTime.strip() strTimeList = vstrTime.split(":") strHour = strTimeList[0] strMinute = strTimeList[1] elif "PM" in vstrTime: vstrTime = vstrTime.replace("PM","") vstrTime = vstrTime.strip() strTimeList = vstrTime.split(":") strHour = strTimeList[0] strHour = int(strHour) strHour += 12 strMinute = strTimeList[1] else: vstrTime = vstrTime.strip() strTimeList = vstrTime.split(":") strHour = strTimeList[0] strMinute = strTimeList[1] vstrThisDate = datetime.date(year=int(strYear),month=int(strMonth),day=int(strDay)) vstrTime = datetime.time(hour=int(strHour),minute=int(strMinute)) findRequest = MailingList.query(MailingList.strListID == vstrListID) thisMailingList = findRequest.fetch() if len(thisMailingList) > 0: thisMailing = thisMailingList[0] thisMailing.writeStartSendingDate(strinput=vstrThisDate) thisMailing.writeStartSendingTime(strinput=vstrTime) thisMailing.put() self.response.write("Successfully updated Scheduled date and time") else: self.response.write("Error updating scheduled date and time")
def get(self): Guser = users.get_current_user() from accounts import Products if Guser: if users.is_current_user_admin(): findRequest = AppRequests.query( AppRequests.strRequestAccepted == True) thisAppRequestList = findRequest.fetch() findRequest = ContactMessages.query( ContactMessages.strResponseSent == False) thisContactMessagesList = findRequest.fetch() findRequest = Administrators.query() thisAdminList = findRequest.fetch() findRequest = Products.query() thisProductsList = findRequest.fetch() template = template_env.get_template( 'templates/dashboard/dashboard.html') context = { 'thisAdminList': thisAdminList, 'thisAppRequestList': thisAppRequestList, 'thisContactMessagesList': thisContactMessagesList, 'thisProductsList': thisProductsList } self.response.write(template.render(context)) else: findRequest = UserRights.query( UserRights.strMemberID == Guser.user_id()) thisUserRightsList = findRequest.fetch() if len(thisUserRightsList) > 0: thisUserRights = thisUserRightsList[0] else: thisUserRights = UserRights() findRequest = ChurchMember.query( ChurchMember.strMemberID == Guser.user_id()) thisChurchMemberList = findRequest.fetch() if len(thisChurchMemberList) > 0: thisChurchMember = thisChurchMemberList[0] else: thisChurchMember = ChurchMember() if thisUserRights.strAdminUser: findRequest = Administrators.query( Administrators.strAdminID == Guser.user_id()) thisAdminList = findRequest.fetch() if len(thisAdminList) > 0: thisAdmin = thisAdminList[0] else: thisAdmin = Administrators() template = template_env.get_template( 'templates/dashboard/adminUsers.html') context = { 'thisAdmin': thisAdmin, 'thisChurchMember': thisChurchMember } self.response.write(template.render(context)) elif thisUserRights.strSuperUser: template = template_env.get_template( 'templates/dashboard/superUsers.html') context = {'thisChurchMember': thisChurchMember} self.response.write(template.render(context)) elif thisUserRights.strChurchMember: template = template_env.get_template( 'templates/dashboard/churchMemberUser.html') context = {'thisChurchMember': thisChurchMember} self.response.write(template.render(context)) else: template = template_env.get_template( 'templates/dashboard/Visitor.html') context = {'thisChurchMember': thisChurchMember} self.response.write(template.render(context))