Ejemplo n.º 1
0
Archivo: clone.py Proyecto: wdbm/indico
 def _clone_contrib_fields(self, new_event):
     attrs = get_simple_column_attrs(ContributionField) - {'field_data'}
     for old_contrib_field in self.old_event.contribution_fields:
         contrib_field = ContributionField()
         contrib_field.populate_from_attrs(old_contrib_field, attrs)
         contrib_field.field_data = deepcopy(old_contrib_field.field_data)
         new_event.contribution_fields.append(contrib_field)
         self._contrib_field_map[old_contrib_field] = contrib_field
Ejemplo n.º 2
0
 def _clone_contrib_fields(self, new_event):
     attrs = get_simple_column_attrs(ContributionField) - {'field_data'}
     for old_contrib_field in self.old_event.contribution_fields:
         contrib_field = ContributionField()
         contrib_field.populate_from_attrs(old_contrib_field, attrs)
         contrib_field.field_data = deepcopy(old_contrib_field.field_data)
         new_event.contribution_fields.append(contrib_field)
         self._contrib_field_map[old_contrib_field] = contrib_field
Ejemplo n.º 3
0
 def _migrate_contribution_field(self, old_field, position):
     field_type = old_field.__class__.__name__
     if field_type in ('AbstractTextAreaField', 'AbstractInputField',
                       'AbstractField'):
         multiline = field_type == 'AbstractTextAreaField' or (
             field_type == 'AbstractField'
             and getattr(old_field, '_type', 'textarea') == 'textarea')
         limitation = getattr(old_field, '_limitation', 'chars')
         field_data = {
             'max_length':
             int(old_field._maxLength) if limitation == 'chars' else None,
             'max_words':
             int(old_field._maxLength) if limitation == 'words' else None,
             'multiline':
             multiline
         }
         field_type = 'text'
     elif field_type == 'AbstractSelectionField':
         options = []
         for opt in old_field._options:
             uuid = unicode(uuid4())
             self.event_ns.legacy_field_option_id_map[old_field._id,
                                                      int(opt.id)] = uuid
             options.append({
                 'option': convert_to_unicode(opt.value),
                 'id': uuid,
                 'is_deleted': False
             })
         for opt in old_field._deleted_options:
             uuid = unicode(uuid4())
             self.event_ns.legacy_field_option_id_map[old_field._id,
                                                      int(opt.id)] = uuid
             options.append({
                 'option': convert_to_unicode(opt.value),
                 'id': uuid,
                 'is_deleted': True
             })
         field_data = {'options': options, 'display_type': 'select'}
         field_type = 'single_choice'
     else:
         self.print_error('Unrecognized field type {}'.format(field_type))
         return
     if old_field._id in self.event_ns.legacy_contribution_field_map:
         self.print_warning(
             "%[yellow!]There is already a field with legacy_id '{}')!%[reset]"
             .format(old_field._id))
         return
     field = ContributionField(event=self.event,
                               field_type=field_type,
                               is_active=old_field._active,
                               title=convert_to_unicode(old_field._caption),
                               is_required=old_field._isMandatory,
                               field_data=field_data,
                               position=position,
                               legacy_id=old_field._id)
     self.event_ns.legacy_contribution_field_map[old_field._id] = field
     if not self.quiet:
         self.print_info('%[green]Contribution field%[reset] {}'.format(
             field.title))
Ejemplo n.º 4
0
 def _process(self):
     form = self.field_cls.create_config_form()
     if form.validate_on_submit():
         contrib_field = ContributionField()
         field = self.field_cls(contrib_field)
         field.update_object(form.data)
         self.event.contribution_fields.append(contrib_field)
         db.session.flush()
         self.event.log(EventLogRealm.management, EventLogKind.positive, 'Contributions',
                        'Added field: {}'.format(contrib_field.title), session.user)
         return jsonify_data(flash=False)
     return jsonify_template('forms/form_common_fields_first.html', form=form)
Ejemplo n.º 5
0
 def _process_args(self):
     RHManageContributionsBase._process_args(self)
     self.contrib_field = ContributionField.get_one(
         request.view_args['contrib_field_id'])
Ejemplo n.º 6
0
 def _process_args(self):
     RHManageContributionsBase._process_args(self)
     self.contrib_field = ContributionField.get_one(request.view_args['contrib_field_id'])
Ejemplo n.º 7
0
 def _checkParams(self, params):
     RHManageContributionsBase._checkParams(self, params)
     self.contrib_field = ContributionField.get_one(request.view_args['contrib_field_id'])
Ejemplo n.º 8
0
 def _checkParams(self, params):
     RHManageContributionsBase._checkParams(self, params)
     self.contrib_field = ContributionField.get_one(
         request.view_args['contrib_field_id'])