def post(self, participant_id, field_slug):
        participant = self.get_object(participant_id)
        cf = self.get_custom_field(participant, field_slug)

        if participant.participant_type == Participant.PARTICIPANT:
            form_class = ParticipantEditForm
        else:
            form_class = MediaParticipantEditForm

        field_types = [CustomField.IMAGE]
        Object = custom_object_factory(participant, field_types)
        Form = custom_form_factory(form_class, field_slugs=[field_slug])
        form = Form(obj=Object())

        if form.validate():
            form.save(participant)
            cfv = (cf.custom_field_values.filter_by(participant=participant)
                   .scalar())
            if cfv:
                data = get_custom_file_as_filestorage(cfv.value)
            else:
                data = {}
        else:
            return make_response(jsonify(form.errors), 400)

        html = render_template('meetings/custom_field/_image_widget.html',
                               data=data)
        return jsonify(html=html)
    def post(self, participant_id, field_slug):
        participant = self.get_object(participant_id)
        cf = self.get_custom_field(participant, field_slug)

        if participant.participant_type == Participant.PARTICIPANT:
            form_class = ParticipantEditForm
            g.rule_type = Rule.PARTICIPANT
        else:
            form_class = MediaParticipantEditForm
            g.rule_type = Rule.MEDIA

        field_types = [CustomField.IMAGE]
        Object = custom_object_factory(participant, field_types)
        Form = custom_form_factory(form_class, field_slugs=[field_slug])
        form = Form(obj=Object())

        if form.validate():
            form.save(participant)
            cfv = (cf.custom_field_values.filter_by(
                participant=participant).scalar())
            if cfv:
                data = get_custom_file_as_filestorage(cfv.value)
            else:
                data = {}
        else:
            return make_response(jsonify(form.errors), 400)

        html = render_template('meetings/custom_field/_image_widget.html',
                               data=data)
        return jsonify(html=html)
Exemple #3
0
 def process_formdata(self, valuelist):
     use_current_file = request.form.get(self.name + '-use-current-file')
     if use_current_file:
         self._use_current_file = True
         self.data = get_custom_file_as_filestorage(
             filename=use_current_file)
     else:
         super(_BaseFileFieldMixin, self).process_formdata(valuelist)
 def process_formdata(self, valuelist):
     use_current_file = request.form.get(self.name + '-use-current-file')
     if use_current_file:
         self._use_current_file = True
         self.data = get_custom_file_as_filestorage(
             filename=use_current_file)
     else:
         super(_BaseFileFieldMixin, self).process_formdata(valuelist)
    def post(self, participant_id, field_slug):
        participant = self.get_object(participant_id)
        cf = self.get_custom_field(participant, field_slug, field_type='image')
        cfv = self.get_custom_field_value(cf, participant)

        newfile = rotate_file(cfv.value, 'custom')
        if newfile == cfv.value:
            return make_response(jsonify(), 400)

        unlink_participant_custom_file(cfv.value)
        cfv.value = newfile
        db.session.commit()

        data = get_custom_file_as_filestorage(newfile)
        html = render_template('meetings/custom_field/_image_widget.html',
                               data=data)
        return jsonify(html=html)
    def post(self, participant_id, field_slug):
        participant = self.get_object(participant_id)
        cf = self.get_custom_field(participant, field_slug,
                                   field_type='image')
        cfv = self.get_custom_field_value(cf, participant)

        newfile = rotate_file(cfv.value, 'custom')
        if newfile == cfv.value:
            return make_response(jsonify(), 400)

        unlink_participant_custom_file(cfv.value)
        cfv.value = newfile
        db.session.commit()

        data = get_custom_file_as_filestorage(newfile)
        html = render_template('meetings/custom_field/_image_widget.html',
                               data=data)
        return jsonify(html=html)
Exemple #7
0
 def process_data(self, value):
     super(_BaseFileFieldMixin, self).process_data(value)
     if isinstance(value, basestring):
         self._use_current_file = True
         self.data = get_custom_file_as_filestorage(filename=value)
 def process_data(self, value):
     super(_BaseFileFieldMixin, self).process_data(value)
     if isinstance(value, basestring):
         self._use_current_file = True
         self.data = get_custom_file_as_filestorage(filename=value)