Example #1
0
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.'))
Example #2
0
    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)
Example #3
0
    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)
Example #4
0
    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)
Example #5
0
 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'))
Example #6
0
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."))
Example #7
0
    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)
Example #8
0
    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)
Example #9
0
    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)
Example #10
0
class AgentForm(IndicoForm):
    name = StringField(
        _('Name'), [DataRequired()],
        description=_(
            "The name of the agent. Only used in the administration interface."
        ))
Example #11
0
 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'))
Example #12
0
 def _process(self):
     db.session.delete(self.agent)
     flash(_('Agent deleted'), 'success')
     return redirect(url_for('plugins.details', plugin='livesync'))
Example #13
0
 def _process(self):
     db.session.delete(self.agent)
     flash(_('Agent deleted'), 'success')
     return jsonify_data(flash=False)
Example #14
0
 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'))
Example #15
0
 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'))
Example #16
0
 def _process(self):
     db.session.delete(self.agent)
     flash(_('Agent deleted'), 'success')
     return redirect(url_for('plugins.details', plugin='livesync'))