def save(self):
     categories_default = CategoryDefault.query.filter(
         CategoryDefault.id.in_(self.categories.data))
     for category_default in categories_default:
         category = copy_attributes(Category(), category_default,
                                    exclude=('background', ))
         translation = Translation(english=category_default.title.english)
         db.session.add(translation)
         db.session.flush()
         category.title = translation
         category.meeting = g.meeting
         filename = duplicate_uploaded_file(category_default.background,
                                            'backgrounds')
         if filename:
             category.background = filename.basename()
         db.session.add(category)
     db.session.commit()
Example #2
0
 def save(self):
     categories_default = CategoryDefault.query.filter(
         CategoryDefault.id.in_(self.categories.data))
     for category_default in categories_default:
         category = copy_attributes(Category(),
                                    category_default,
                                    exclude=('background', ))
         translation = Translation(english=category_default.title.english)
         db.session.add(translation)
         db.session.flush()
         category.title = translation
         category.tags = category_default.tags
         category.meeting = g.meeting
         filename = duplicate_uploaded_file(category_default.background,
                                            'backgrounds')
         if filename:
             category.background = filename.basename()
         db.session.add(category)
     db.session.commit()
 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