comparison rhodecode/controllers/admin/settings.py @ 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 2c0d35e336b5
children 8cb7f5c4d494
comparison
equal deleted inserted replaced
1672:13d6da57b0cf 1673:333b3e7c991f
229 229
230 if setting_id == 'hooks': 230 if setting_id == 'hooks':
231 ui_key = request.POST.get('new_hook_ui_key') 231 ui_key = request.POST.get('new_hook_ui_key')
232 ui_value = request.POST.get('new_hook_ui_value') 232 ui_value = request.POST.get('new_hook_ui_value')
233 try: 233 try:
234 234
235 if ui_value and ui_key: 235 if ui_value and ui_key:
236 RhodeCodeUi.create_or_update_hook(ui_key, ui_value) 236 RhodeCodeUi.create_or_update_hook(ui_key, ui_value)
237 h.flash(_('Added new hook'), 237 h.flash(_('Added new hook'),
238 category='success') 238 category='success')
239 239
240 # check for edits 240 # check for edits
241 update = False 241 update = False
242 _d = request.POST.dict_of_lists() 242 _d = request.POST.dict_of_lists()
243 for k, v in zip(_d.get('hook_ui_key',[]), _d.get('hook_ui_value_new',[])): 243 for k, v in zip(_d.get('hook_ui_key', []), _d.get('hook_ui_value_new', [])):
244 RhodeCodeUi.create_or_update_hook(k, v) 244 RhodeCodeUi.create_or_update_hook(k, v)
245 update = True 245 update = True
246 246
247 if update: 247 if update:
248 h.flash(_('Updated hooks'), category='success') 248 h.flash(_('Updated hooks'), category='success')
252 h.flash(_('error occurred during hook creation'), 252 h.flash(_('error occurred during hook creation'),
253 category='error') 253 category='error')
254 254
255 return redirect(url('admin_edit_setting', setting_id='hooks')) 255 return redirect(url('admin_edit_setting', setting_id='hooks'))
256 256
257
258
259 if setting_id == 'email':
260 test_email = request.POST.get('test_email')
261 test_email_subj = 'RhodeCode TestEmail'
262 test_email_body = 'RhodeCode Email test'
263
264 run_task(tasks.send_email, [test_email], test_email_subj,
265 test_email_body)
266 h.flash(_('Email task created'), category='success')
257 return redirect(url('admin_settings')) 267 return redirect(url('admin_settings'))
258 268
259 @HasPermissionAllDecorator('hg.admin') 269 @HasPermissionAllDecorator('hg.admin')
260 def delete(self, setting_id): 270 def delete(self, setting_id):
261 """DELETE /admin/settings/setting_id: Delete an existing item""" 271 """DELETE /admin/settings/setting_id: Delete an existing item"""
266 # method='delete') 276 # method='delete')
267 # url('admin_setting', setting_id=ID) 277 # url('admin_setting', setting_id=ID)
268 if setting_id == 'hooks': 278 if setting_id == 'hooks':
269 hook_id = request.POST.get('hook_id') 279 hook_id = request.POST.get('hook_id')
270 RhodeCodeUi.delete(hook_id) 280 RhodeCodeUi.delete(hook_id)
271 281
272 282
273 @HasPermissionAllDecorator('hg.admin') 283 @HasPermissionAllDecorator('hg.admin')
274 def show(self, setting_id, format='html'): 284 def show(self, setting_id, format='html'):
275 """ 285 """
276 GET /admin/settings/setting_id: Show a specific item""" 286 GET /admin/settings/setting_id: Show a specific item"""
277 # url('admin_setting', setting_id=ID) 287 # url('admin_setting', setting_id=ID)