Beispiel #1
0
 class ResetpassForm(self.form_base_class):
     form_widget_args = {}
     form_edit_rules = [
         rules.Field('new_password'),
         rules.Field('new_password_confirm')
     ]
     _form_edit_rules = rules.RuleSet(self, form_edit_rules)
     action = HiddenField('')
     url = HiddenField('')
     new_password = fields.PasswordField(
         '新密码', [validators.required(message='密码是必填字段')])
     new_password_confirm = fields.PasswordField(
         '密码确认', [
             validators.equal_to(fieldname='new_password',
                                 message='确认密码须一致')
         ])
Beispiel #2
0
    def __init__(self, **kwargs):
        """
            Constructor

            :param kwargs:
                Additional options
        """
        for k in self._defaults:
            if not hasattr(self, k):
                setattr(self, k, None)

        for k, v in iteritems(kwargs):
            setattr(self, k, v)

        # Convert form rules
        form_rules = getattr(self, 'form_rules', None)

        if form_rules:
            self._form_rules = rules.RuleSet(self, form_rules)
        else:
            self._form_rules = None
Beispiel #3
0
 def _form_create_rules(self):
     return rules.RuleSet(self, self.create_form_rules)
Beispiel #4
0
 def _form_edit_rules(self):
     return rules.RuleSet(self, self.edit_form_rules)
Beispiel #5
0
 def _refresh_form_rules_cache(self):
     super(ScriptView, self)._refresh_form_rules_cache()
     self._form_simple_create_rules = rules.RuleSet(
         self, ['project', 'name', 'alias'])
Beispiel #6
0
    def edit_view(self):
        """
        Over-write default edit_view with the multi-step forms.

        :return:
        """
        id = get_mdict_item_or_list(request.args, 'id')
        model = self.get_one(id)
        form = self.edit_form(obj=model)

        if request.method == 'POST' and '_goto_prev' in request.form:
            if form.previous_step:
                session['previous_step'] = form.previous_step.data
            url = request.base_url + "?id={}".format(id)
            return redirect(url)

        if request.method == 'POST' and '_continue_edit_step' in request.form and self.update_model(
                form, model):
            if form.next_step:
                session['next_step'] = form.next_step.data
            url = request.base_url + "?id={}".format(id)
            return redirect(url)

        movie = Movie.query.filter(Movie.config_id == model.id).filter(
            Movie.type == MovieType.MOVIE_TYPE_CONFIG).order_by(
                Movie.id.desc()).first()
        if movie:
            self._template_args['movie'] = movie
            if movie.status == MovieStatus.MOVIE_STATUS_NEW or (
                    model.gcps_src_0_x and not model.aoi_bbox):
                self.form_edit_rules = ()
                self.edit_template = 'cameraconfig/edit_waiting.html'
            elif model.aoi_bbox:
                previous_session = session.get('previous_step')
                next_session = session.get('next_step')

                if previous_session:
                    if previous_session == "2":
                        self._get_step2_details()
                    else:
                        self._get_step_1_details_for_edit()
                    session.pop('previous_step')

                elif next_session:
                    if next_session == "2":
                        self._get_step2_details()
                    else:
                        self._get_step_3_details()
                    session.pop('next_step')
                else:
                    self._get_step_3_details()
            else:
                if session.get('previous_step') == '1':
                    self._get_step_1_details_for_edit()
                    session.pop('previous_step')
                else:
                    self._get_step2_details()
        else:
            self.form_edit_rules = (
                "time_start",
                "time_end",
                "file_name",
            )
            self.edit_template = 'cameraconfig/edit_step1.html'

        self._form_edit_rules = rules.RuleSet(self, self.form_edit_rules)
        return super(CameraConfigView, self).edit_view()