Beispiel #1
0
 def process_form(self, form):
     try:
         controls = list(self.request.POST.items())
         appstruct = skip_csrf_token(form.validate(controls))
     except ValidationFailure as e:
         return dict(title=self.title, form=e.render())
     except Exception:
         self.session.flash("<strong>Error:</strong> Could not update settings.", queue="danger")
     else:
         settings = self.collection.find_one() or {}
         settings.update(dict(pinned_processes=list(appstruct['pinned_processes'])))
         self.collection.save(settings)
         self.request.registry.notify(SettingsChanged(self.request, appstruct))
         self.session.flash('Successfully updated settings!', queue='success')
     return HTTPFound(location=self.request.route_path('settings_processes'))
Beispiel #2
0
 def panel(self):
     form = Form(schema=Schema().bind(request=self.request), buttons=('update',))
     if 'update' in self.request.POST:
         try:
             controls = self.request.POST.items()
             appstruct = form.validate(controls)
             settings = self.request.db.settings.find_one() or {}
             settings.update(skip_csrf_token(appstruct))
             self.request.db.settings.save(settings)
             self.request.registry.notify(SettingsChanged(self.request, appstruct))
         except ValidationFailure, e:
             LOGGER.exception('validation of form failed.')
             return dict(title="Parameters", form=e.render())
         except Exception, e:
             LOGGER.exception('update failed.')
             self.request.session.flash('Update of Solr parameters failed.', queue='danger')
Beispiel #3
0
 def appstruct(self):
     appstruct = self.collection.find_one() or {}
     return skip_csrf_token(appstruct)
 def process_form(self, form):
     try:
         controls = self.request.POST.items()
         appstruct = skip_csrf_token(form.validate(controls))
     except ValidationFailure, e:
         return dict(title=self.title, form=e.render())
Beispiel #5
0
 def appstruct(self):
     appstruct = self.request.db.settings.find_one() or {}
     return skip_csrf_token(appstruct)
Beispiel #6
0
 def success(self, appstruct):
     self.wizard_state.set(self.name, skip_csrf_token(appstruct))