Changeset - 333b3e7c991f
[Not reviewed]
beta
0 3 0
Marcin Kuzminski - 14 years ago 2011-11-12 11:20:50
marcin@python-works.com
Added email sending test site
3 files changed with 39 insertions and 6 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/admin/settings.py
Show inline comments
 
@@ -231,7 +231,7 @@ class SettingsController(BaseController)
 
            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 @@ class SettingsController(BaseController)
 
                # 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 @@ class SettingsController(BaseController)
 

	
 
            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 @@ class SettingsController(BaseController)
 
        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'):
 
        """
rhodecode/lib/celerylib/tasks.py
Show inline comments
 
@@ -347,7 +347,7 @@ def send_email(recipients, subject, body
 

	
 
    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 @@ def send_email(recipients, subject, body
 
    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:
rhodecode/templates/admin/settings/settings.html
Show inline comments
 
@@ -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>    
0 comments (0 inline, 0 general)