Mercurial > kallithea
changeset 1673:333b3e7c991f beta
Added email sending test site
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sat, 12 Nov 2011 12:20:50 +0200 |
parents | 13d6da57b0cf |
children | 6f0143e5efe5 |
files | rhodecode/controllers/admin/settings.py rhodecode/lib/celerylib/tasks.py rhodecode/templates/admin/settings/settings.html |
diffstat | 3 files changed, 39 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/rhodecode/controllers/admin/settings.py Sat Nov 12 12:04:17 2011 +0200 +++ b/rhodecode/controllers/admin/settings.py Sat Nov 12 12:20:50 2011 +0200 @@ -231,7 +231,7 @@ ui_key = request.POST.get('new_hook_ui_key') ui_value = request.POST.get('new_hook_ui_value') try: - + if ui_value and ui_key: RhodeCodeUi.create_or_update_hook(ui_key, ui_value) h.flash(_('Added new hook'), @@ -240,7 +240,7 @@ # check for edits update = False _d = request.POST.dict_of_lists() - for k, v in zip(_d.get('hook_ui_key',[]), _d.get('hook_ui_value_new',[])): + for k, v in zip(_d.get('hook_ui_key', []), _d.get('hook_ui_value_new', [])): RhodeCodeUi.create_or_update_hook(k, v) update = True @@ -254,6 +254,16 @@ return redirect(url('admin_edit_setting', setting_id='hooks')) + + + if setting_id == 'email': + test_email = request.POST.get('test_email') + test_email_subj = 'RhodeCode TestEmail' + test_email_body = 'RhodeCode Email test' + + run_task(tasks.send_email, [test_email], test_email_subj, + test_email_body) + h.flash(_('Email task created'), category='success') return redirect(url('admin_settings')) @HasPermissionAllDecorator('hg.admin') @@ -268,8 +278,8 @@ if setting_id == 'hooks': hook_id = request.POST.get('hook_id') RhodeCodeUi.delete(hook_id) - - + + @HasPermissionAllDecorator('hg.admin') def show(self, setting_id, format='html'): """
--- a/rhodecode/lib/celerylib/tasks.py Sat Nov 12 12:04:17 2011 +0200 +++ b/rhodecode/lib/celerylib/tasks.py Sat Nov 12 12:20:50 2011 +0200 @@ -347,7 +347,7 @@ if not recipients: # if recipients are not defined we send to email_config + all admins - admins = [u.email for u in User.query().filter(User.admin==True).all()] + admins = [u.email for u in User.query().filter(User.admin == True).all()] recipients = [email_config.get('email_to')] + admins mail_from = email_config.get('app_email_from') @@ -361,7 +361,7 @@ smtp_auth = email_config.get('smtp_auth') try: - m = SmtpMailer(mail_from, user, passwd, mail_server,smtp_auth, + m = SmtpMailer(mail_from, user, passwd, mail_server, smtp_auth, mail_port, ssl, tls, debug=debug) m.send(recipients, subject, body) except:
--- a/rhodecode/templates/admin/settings/settings.html Sat Nov 12 12:04:17 2011 +0200 +++ b/rhodecode/templates/admin/settings/settings.html Sat Nov 12 12:20:50 2011 +0200 @@ -188,5 +188,28 @@ }); }); </script> + + <h3>${_('Test Email')}</h3> + ${h.form(url('admin_setting', setting_id='email'),method='put')} + <div class="form"> + <!-- fields --> + + <div class="fields"> + <div class="field"> + <div class="label"> + <label for="test_email">${_('Email to')}:</label> + </div> + <div class="input"> + ${h.text('test_email',size=30)} + </div> + </div> + + <div class="buttons"> + ${h.submit('send',_('Send'),class_="ui-button")} + </div> + </div> + </div> + ${h.end_form()} + </div> </%def>