def __call__(self): session = DBSession() a_id = self.request.matchdict['a_id'] applicant = get_applicant(session, a_id) session.delete(applicant) session.flush() return dict(applicants=get_applicants(session), msg="Applicant has been removed from list.")
def __call__(self): session = DBSession() t_id = self.request.matchdict['t_id'] t = get_transaction(session, t_id) if t.locked(): return self.redir_to_list(t.year, t.month, msg='Cannot remove transaction "{}":'\ ' It is locked.'.format(t), show_list=True) else: session.delete(t) session.flush() return self.redir_to_list(t.date.year, t.date.month, msg='Transaction "{}" has been deleted.'\ .format(t), show_list=True)
def __call__(self): session = DBSession() tt_id = self.request.matchdict['tt_id'] tt = get_transaction_type(session, tt_id) if not tt.locked: session.delete(tt) session.flush() return self.redirect('/transaction-types?msg='\ 'Transaction type "{}" has been deleted.'\ .format(tt.name)) else: return self.redirect('/transaction-types?msg=Cannot remove'\ ' transaction type "{}": transactions'\ ' refer to it.'.format(tt.name))
def __call__(self): session = DBSession() a_id = self.request.matchdict['a_id'] applicant = get_applicant(session, a_id) # copy over our knowledge of him/her member = Member(self.request, applicant.fname, '', applicant.lname) now = datetime.now() txt = "Joined orientation in {}, became member in {}/{}.".format(\ applicant.month, now.month, now.year) member.mem_adm_comment = "{}\n{}".format(txt, applicant.comment) member.mem_email = applicant.email member.mem_home_tel = applicant.telnr member.mem_household_size = applicant.household_size member.validate() session.add(member) session.delete(applicant) session.flush() send_pwdreset_request(member, self.request.application_url, first=True) return self.redirect("/member/{}?msg=Applicant has been made "\ "into a new Member and got an email to set up a "\ "password."\ .format(member.mem_id))
def __call__(self): db_session = DBSession() wg = get_wg(db_session, self.request) if not wg: raise Exception( "Don't know which workgroup this is supposed to be.") shift = get_shift(db_session, self.request) if not shift: raise Exception("No shift with id %d" % self.request.matchdict['s_id']) def redir(msg): return self.redir_to_shiftlist(wg, shift.year, shift.month, msg) if not wg.active: return redir( 'Workgroup is inactive, editing shifts therefore not possible.' ) action = self.request.matchdict['action'] if action == "": raise Exception('No action given.') if action == "setmember": if not 'mem_id' in self.request.params: return redir('No member selected.') if not self.user in wg.members and not self.user.mem_admin: return redir( 'You are not allowed to assign shifts in this workgroup.') if self.request.params['mem_id'] == '--': member = None else: member = get_member(db_session, self.request) # prepare some things for mailing schedule_url = '{}/workgroup/{}/shifts/{}/{}'.format( self.request.application_url, shift.workgroup.id, shift.year, shift.month) q = 'This email was automatically generated, so please do not '\ 'directly reply to it. You may direct any questions regarding '\ 'the workgroup to your coordinator(s). Only technical questions '\ 'go to [email protected].'\ '\n\nBest,\nVokomokum' old_member = shift.member def mail_old_assignee(): # send old assignee an email if old_member and not self.user == old_member: subject = 'You have been signed out of a shift.' body = 'Hi,\n\n{} has signed you off a shift that '\ 'you were previously assigned to.\nThe shift is '\ 'now:\n\n{}\n\nYou can view the shift '\ 'schedule at {}.\n{}'.format( ascii_save(self.user.fullname), shift, schedule_url, q) sendmail(old_member.mem_email, subject, body, folder='shifts') if member: shift.member = member shift.state = 'assigned' shift.validate() if not self.user == member: # send new assignee an email subject = 'You have been assigned to a shift.' body = 'Hi,\n\n{} has assigned you to a shift: '\ '\n\n{}\n\nYou can view the shift schedule at {}'\ '\n\n{}'.format(ascii_save(self.user.fullname), str(shift), schedule_url, q) sendmail(member.mem_email, subject, body, folder='shifts') # let coordinator(s) know, as well subject = "Workgroup {}: The shift for {} on day '{}' in "\ "{}/{} is now assigned to {}".format(shift.workgroup, shift.task, shift.day, shift.month, shift.year, ascii_save(shift.member.fullname)) body = "The assignment was done by member {}."\ .format(ascii_save(self.user.fullname)) if old_member: body += " The previous assignee was: {}."\ .format(ascii_save(old_member.fullname)) else: body += " No one was assigned to this shift before." body += "\n\n{}".format(q) for c in wg.leaders: if c is not self.user: sendmail(c.mem_email, subject, body, folder='shifts') # and inform previous assignee mail_old_assignee() name = ascii_save(shift.member.fullname) return redir(u'{} has been signed up for the shift.'\ .format(name)) else: if shift.is_locked and not self.user in wg.leaders\ and not self.user.mem_admin: return redir( 'Shift is already locked. Ask your workgroup admin for help.' ) shift.member = None shift.state = 'open' shift.validate() mail_old_assignee() # let coordinator(s) know, as well subject = "Workgroup {}: Member {} was unassigned from the "\ "shift for {} on day '{}' in {}/{}"\ .format(shift.workgroup, ascii_save(old_member.fullname), shift.task, shift.day, shift.month, shift.year) body = "The un-assignment was done by member {}."\ .format(ascii_save(self.user.fullname)) body += "\n\n{}".format(q) for c in wg.leaders: if c is not self.user: sendmail(c.mem_email, subject, body, folder='shifts') return redir('Shift is now open.') return redir('You are not allowed to do this.') elif action == "settask": if self.user in wg.leaders or self.user.mem_admin: if not 'task' in self.request.params: return dict(msg='No task given.') shift.task = self.request.params['task'] shift.validate() return redir('Changed task of shift.') return redir('You are not allowed to edit the task.') elif action == "setday": if self.user in wg.leaders or self.user.mem_admin: if not 'day' in self.request.params: return dict(msg='No day given.') shift.day = self.request.params['day'] shift.validate() return redir('Changed day of shift to {}.'.format(shift.day)) return redir('You are not allowed to set the day.') elif action == "setstate": if self.user in wg.leaders or self.user.mem_admin: if not 'state' in self.request.params: return redir('No state given.') shift.state = self.request.params['state'] shift.validate() return redir('Changed shift state to {}.'.format(shift.state)) return redir('You are not allowed to set the state.') elif action == 'delete': if self.user in wg.leaders or self.user.mem_admin: db_session.delete(shift) return redir('Deleted shift.') return redir('You are not allowed to delete a shift.')