class SettingsForm(IndicoForm): queue_entry_ttl = IntegerField( _('Queue entry TTL'), [NumberRange(min=0)], description= _("How many days should processed entries be kept in the queue. " "The time counts from the creation of the queue entries, so if the " "LiveSync task is not running for some time, queue entries may be " "deleted during the next run after processing them. Setting it to 0 " "disables automatic deletion.")) excluded_categories = MultipleItemsField( _('Excluded categories'), fields=[{ 'id': 'id', 'caption': _("Category ID"), 'required': True }], description=_( "Changes to objects inside these categories or any of their " "subcategories are excluded.")) disable_queue_runs = BooleanField( _('Disable queue runs'), widget=SwitchWidget(), description=_('Disable all scheduled queue runs.')) skip_category_changes = BooleanField( _('Skip category changes'), widget=SwitchWidget(), description=_( 'Skip category changes when processing the queue. This can be ' 'useful in large instances when there are significant changes ' 'to large categories in order to avoid processing those ' 'immediately.'))
def _process(self): form = self.backend.form(obj=FormDefaults(name=self.backend.title)) if form.validate_on_submit(): data = form.data name = data.pop('name') agent = LiveSyncAgent(name=name, backend_name=self.backend_name, settings=data) db.session.add(agent) flash(_('Agent added'), 'success') flash(_("Don't forget to run the initial export!"), 'highlight') return jsonify_data(flash=False) return jsonify_template('edit_agent.html', render_plugin_template, form=form, backend=self.backend, edit=False)
def _process(self): form = self.backend.form(obj=FormDefaults(name=self.backend.title)) if form.validate_on_submit(): data = form.data name = data.pop('name') agent = LiveSyncAgent(name=name, backend_name=self.backend_name, settings=data) db.session.add(agent) flash(_('Agent added'), 'success') flash(_("Don't forget to run the initial export!"), 'highlight') return redirect(url_for('plugins.details', plugin='livesync')) return WPLiveSync.render_template('edit_agent.html', form=form, backend=self.backend)
def _process_args(self): self.backend_name = request.view_args['backend'] try: self.backend = current_plugin.backend_classes[self.backend_name] except KeyError: raise NotFound if self.backend.unique and LiveSyncAgent.query.filter_by(backend_name=self.backend_name).has_rows(): raise UserValueError(_('This backend is already in use'))
class SettingsForm(IndicoForm): queue_entry_ttl = IntegerField( _('Queue entry TTL'), [NumberRange(min=0)], description= _("How many days should processed entries be kept in the queue. " "The time counts from the creation of the queue entries, so if the " "LiveSync task is not running for some time, queue entries may be " "deleted during the next run after processing them. Setting it to 0 " "disables automatic deletion.")) excluded_categories = MultipleItemsField( _('Excluded categories'), fields=[{ 'id': 'id', 'caption': _("Category ID"), 'required': True }], description=_( "Changes to objects inside these categories or any of their " "subcategories are excluded."))
def _process(self): form = self.agent.backend.form(obj=FormDefaults(self.agent, {'name'}, **self.agent.settings)) if form.validate_on_submit(): data = form.data self.agent.name = data.pop('name') self.agent.settings = data flash(_('Agent updated'), 'success') return redirect(url_for('plugins.details', plugin='livesync')) return WPLiveSync.render_template('edit_agent.html', form=form, backend=self.agent.backend, agent=self.agent)
def _process(self): form = self.agent.backend.form(obj=FormDefaults(name=self.agent.name, **self.agent.settings)) if form.validate_on_submit(): data = form.data self.agent.name = data.pop('name') self.agent.settings = data flash(_('Agent updated'), 'success') return jsonify_data(flash=False) return jsonify_template('edit_agent.html', render_plugin_template, form=form, backend=self.agent.backend, edit=True)
def _process(self): form = self.agent.backend.form( obj=FormDefaults(self.agent, {'name'}, **self.agent.settings)) if form.validate_on_submit(): data = form.data self.agent.name = data.pop('name') self.agent.settings = data flash(_('Agent updated'), 'success') return redirect(url_for('plugins.details', plugin='livesync')) return WPLiveSync.render_template('edit_agent.html', form=form, backend=self.agent.backend, agent=self.agent)
class AgentForm(IndicoForm): name = StringField( _('Name'), [DataRequired()], description=_( "The name of the agent. Only used in the administration interface." ))
def _checkParams(self): self.agent = LiveSyncAgent.find_one(id=request.view_args['agent_id']) if self.agent.backend is None: flash(_('Cannot edit an agent that is not loaded'), 'error') return redirect(url_for('plugins.details', plugin='livesync'))
def _process(self): db.session.delete(self.agent) flash(_('Agent deleted'), 'success') return redirect(url_for('plugins.details', plugin='livesync'))
def _process(self): db.session.delete(self.agent) flash(_('Agent deleted'), 'success') return jsonify_data(flash=False)
def _process_args(self): self.agent = LiveSyncAgent.get_or_404(request.view_args['agent_id']) if self.agent.backend is None: flash(_('Cannot edit an agent that is not loaded'), 'error') return redirect(url_for('plugins.details', plugin='livesync'))