def delete(self, participant_id, field_slug):
        participant = self.get_object(participant_id)
        cf = self.get_custom_field(participant, field_slug)
        cfv = self.get_custom_field_value(cf, participant)

        filename = cfv.value
        db.session.delete(cfv)
        db.session.commit()
        unlink_participant_custom_file(filename)
        return jsonify()
    def delete(self, participant_id, field_slug):
        participant = self.get_object(participant_id)
        cf = self.get_custom_field(participant, field_slug)
        cfv = self.get_custom_field_value(cf, participant)

        filename = cfv.value
        db.session.delete(cfv)
        db.session.commit()
        unlink_participant_custom_file(filename)
        return jsonify()
Esempio n. 3
0
 def save(self, cf, participant, cfv=None):
     if not self.data:
         return
     cfv = cfv or cf.get_or_create_value(participant)
     current_filename = cfv.value
     try:
         cfv.value = custom_upload.save(self.data, name=str(uuid4()) + '.')
     except:
         sentry.captureException()
         return cfv
     unlink_participant_custom_file(current_filename)
     if not cfv.id:
         db.session.add(cfv)
     return cfv
 def save(self, cf, participant, cfv=None):
     if not self.data:
         return
     cfv = cfv or cf.get_or_create_value(participant)
     current_filename = cfv.value
     try:
         cfv.value = custom_upload.save(self.data, name=str(uuid4()) + '.')
     except:
         sentry.captureException()
         return cfv
     unlink_participant_custom_file(current_filename)
     if not cfv.id:
         db.session.add(cfv)
     return cfv
    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)
Esempio n. 7
0
 def save(self, cf, participant, cfv=None):
     if not self.data:
         return
     cfv = cfv or cf.get_or_create_value(participant)
     current_filename = cfv.value
     try:
         cfv.value = custom_upload.save(self.data, name=str(uuid4()) + '.')
     except Exception as e:
         if app.config.get('SENTRY_DSN'):
             capture_exception(e)
         else:
             import traceback
             print(traceback.format_exc())
         return cfv
     unlink_participant_custom_file(current_filename)
     if not cfv.id:
         db.session.add(cfv)
     return cfv
 def _clone_custom_field_value(self, participant, custom_field_clone,
                               custom_field_value):
     cfv = (CustomFieldValue.query.filter_by(
         custom_field=custom_field_clone).filter_by(
             participant=participant).scalar())
     if cfv:
         if custom_field_clone.field_type == CustomField.IMAGE:
             unlink_participant_custom_file(cfv.value)
         cfv = copy_attributes(cfv, custom_field_value)
     else:
         cfv = copy_attributes(CustomFieldValue(), custom_field_value)
         cfv.custom_field_id = custom_field_clone.id
         cfv.participant_id = participant.id
         db.session.add(cfv)
     if custom_field_clone.field_type == CustomField.IMAGE:
         filename = duplicate_uploaded_file(custom_field_value.value,
                                            'custom')
         cfv.value = filename.basename()
     return cfv
 def _clone_custom_field_value(self, participant, custom_field_clone,
                               custom_field_value):
     cfv = (CustomFieldValue.query
            .filter_by(custom_field=custom_field_clone)
            .filter_by(participant=participant)
            .scalar())
     if cfv:
         if custom_field_clone.field_type == CustomField.IMAGE:
             unlink_participant_custom_file(cfv.value)
         cfv = copy_attributes(cfv, custom_field_value)
     else:
         cfv = copy_attributes(CustomFieldValue(), custom_field_value)
         cfv.custom_field_id = custom_field_clone.id
         cfv.participant_id = participant.id
         db.session.add(cfv)
     if custom_field_clone.field_type == CustomField.IMAGE:
         filename = duplicate_uploaded_file(custom_field_value.value,
                                            'custom')
         cfv.value = filename.basename()
     return cfv