Exemple #1
0
 def delete(self, setting_id):
     """DELETE /admin/settings/setting_id: Delete an existing item"""
     # Forms posted to this method should contain a hidden field:
     #    <input type="hidden" name="_method" value="DELETE" />
     # Or using helpers:
     #    h.form(url('admin_setting', setting_id=ID),
     #           method='delete')
     # url('admin_setting', setting_id=ID)
     if setting_id == 'hooks':
         hook_id = request.POST.get('hook_id')
         RhodeCodeUi.delete(hook_id)
Exemple #2
0
 def delete(self, setting_id):
     """DELETE /admin/settings/setting_id: Delete an existing item"""
     # Forms posted to this method should contain a hidden field:
     #    <input type="hidden" name="_method" value="DELETE" />
     # Or using helpers:
     #    h.form(url('admin_setting', setting_id=ID),
     #           method='delete')
     # url('admin_setting', setting_id=ID)
     if setting_id == 'hooks':
         hook_id = request.POST.get('hook_id')
         RhodeCodeUi.delete(hook_id)
         Session().commit()
Exemple #3
0
    def settings_hooks_update(self):
        """POST or DELETE /admin/settings/hooks: All items in the collection"""
        # url('admin_settings_hooks')
        c.active = 'hooks'
        if c.visual.allow_custom_hooks_settings:
            ui_key = request.POST.get('new_hook_ui_key')
            ui_value = request.POST.get('new_hook_ui_value')

            hook_id = request.POST.get('hook_id')
            new_hook = False

            model = SettingsModel()
            try:
                if ui_value and ui_key:
                    model.create_or_update_hook(ui_key, ui_value)
                    h.flash(_('Added new hook'), category='success')
                    new_hook = True
                elif hook_id:
                    RhodeCodeUi.delete(hook_id)
                    Session().commit()

                # 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', [])):
                    model.create_or_update_hook(k, v)
                    update = True

                if update and not new_hook:
                    h.flash(_('Updated hooks'), category='success')
                Session().commit()
            except Exception:
                log.exception("Exception during hook creation")
                h.flash(_('Error occurred during hook creation'),
                        category='error')

        return redirect(url('admin_settings_hooks'))