def update(self, session, password='', message='', **params): account = session.admin_account(params) if account.is_new: if c.AT_OR_POST_CON and not password: message = 'You must enter a password' else: password = password if c.AT_OR_POST_CON else genpasswd() account.hashed = bcrypt.hashpw(password, bcrypt.gensalt()) message = message or check(account) if not message: message = 'Account settings uploaded' attendee = session.attendee( account.attendee_id ) # dumb temporary hack, will fix later with tests account.attendee = attendee session.add(account) if account.is_new and not c.AT_OR_POST_CON: session.commit() body = render('emails/accounts/new_account.txt', { 'account': account, 'password': password, 'creator': AdminAccount.admin_name() }, encoding=None) send_email.delay(c.ADMIN_EMAIL, attendee.email, 'New ' + c.EVENT_NAME + ' Ubersystem Account', body, model=attendee.to_dict('id')) else: session.rollback() raise HTTPRedirect('index?message={}', message)
def printed_badge_change(attendee): if attendee.badge_printed_name != attendee.orig_value_of('badge_printed_name') \ and not AdminAccount.admin_name() \ and localized_now() > c.get_printed_badge_deadline_by_type(attendee.badge_type_real): return '{} badges have already been ordered, so you cannot change the badge printed name.'.format( attendee.badge_type_label if attendee.badge_type in c.PREASSIGNED_BADGE_TYPES else "Supporter")
def update(self, session, password='', message='', **params): account = session.admin_account(params, checkgroups=['access']) if account.is_new: if c.AT_OR_POST_CON and not password: message = 'You must enter a password' else: password = password if c.AT_OR_POST_CON else genpasswd() account.hashed = bcrypt.hashpw(password, bcrypt.gensalt()) message = message or check(account) if not message: message = 'Account settings uploaded' attendee = session.attendee(account.attendee_id) # dumb temporary hack, will fix later with tests account.attendee = attendee session.add(account) if account.is_new and not c.AT_OR_POST_CON: body = render('emails/accounts/new_account.txt', { 'account': account, 'password': password, 'creator': AdminAccount.admin_name() }, encoding=None) send_email.delay( c.ADMIN_EMAIL, attendee.email, 'New ' + c.EVENT_NAME + ' Ubersystem Account', body, model=attendee.to_dict('id')) else: session.rollback() raise HTTPRedirect('index?message={}', message)