def send_button(self, *args, **input): if mail_form.validate(input): if False and 'attachment' in input and hasattr( input['attachment'], 'filename'): send( input['recipient'], input['subject'], input['message'], [ Attachment( input['attachment'].filename, input['attachment'].file, ) ], ) success('message sent with attachment') else: send_as( (input['from_name'], input['from_email']), input['recipient'], input['subject'], input['message'], ) success('message sent') return home('mail')
def save_password_button(self, key, *args, **data): form = get_reset_password_form(key) if form.validate(data): user = context.site.users.first(username=key) if user: new_password = form.evaluate()['new_password'] user.set_password(new_password) success('password updated') return home('users/' + key)
def random(self): for n in range(5): choice([ lambda: success('Success %s' % n), lambda: warning('Warning %s' % n), lambda: error('Error %s' % n), ])() return redirect_to('/sample/alerts')
def success(self): success('that was great!') return page(markdown('return to [index](/sample/alerts)'), title='Alerts')
def success(self): success('that was great!') return redirect_to('/sample/alerts')