示例#1
0
 def _create_new_contribution(self,
                              event,
                              old_contrib,
                              preserve_session=True,
                              excluded_attrs=None):
     attrs = (get_simple_column_attrs(Contribution)
              | {'own_room', 'own_venue'}) - {'abstract_id'}
     if excluded_attrs is not None:
         attrs -= excluded_attrs
     new_contrib = Contribution()
     new_contrib.populate_from_attrs(old_contrib, attrs)
     new_contrib.subcontributions = list(
         self._clone_subcontribs(old_contrib.subcontributions))
     new_contrib.acl_entries = clone_principals(ContributionPrincipal,
                                                old_contrib.acl_entries,
                                                self._event_role_map)
     new_contrib.references = list(
         self._clone_references(ContributionReference,
                                old_contrib.references))
     new_contrib.person_links = list(
         self._clone_person_links(ContributionPersonLink,
                                  old_contrib.person_links))
     new_contrib.field_values = list(
         self._clone_fields(old_contrib.field_values))
     if old_contrib.type is not None:
         new_contrib.type = self._contrib_type_map[old_contrib.type]
     if preserve_session:
         if old_contrib.session is not None:
             new_contrib.session = self._session_map[old_contrib.session]
         if old_contrib.session_block is not None:
             new_contrib.session_block = self._session_block_map[
                 old_contrib.session_block]
     event.contributions.append(new_contrib)
     return new_contrib
示例#2
0
 def _clone_contribs(self, new_event):
     attrs = (get_simple_column_attrs(Contribution) | {'own_room', 'own_venue'}) - {'abstract_id'}
     query = (Contribution.query.with_parent(self.old_event)
              .options(undefer('_last_friendly_subcontribution_id'),
                       joinedload('own_venue'),
                       joinedload('own_room').lazyload('*'),
                       joinedload('session'),
                       joinedload('session_block').lazyload('session'),
                       joinedload('type'),
                       subqueryload('acl_entries'),
                       subqueryload('subcontributions').joinedload('references'),
                       subqueryload('references'),
                       subqueryload('person_links'),
                       subqueryload('field_values')))
     for old_contrib in query:
         contrib = Contribution()
         contrib.populate_from_attrs(old_contrib, attrs)
         contrib.subcontributions = list(self._clone_subcontribs(old_contrib.subcontributions))
         contrib.acl_entries = clone_principals(ContributionPrincipal, old_contrib.acl_entries)
         contrib.references = list(self._clone_references(ContributionReference, old_contrib.references))
         contrib.person_links = list(self._clone_person_links(ContributionPersonLink, old_contrib.person_links))
         contrib.field_values = list(self._clone_fields(old_contrib.field_values))
         if old_contrib.type is not None:
             contrib.type = self._contrib_type_map[old_contrib.type]
         if old_contrib.session is not None:
             contrib.session = self._session_map[old_contrib.session]
         if old_contrib.session_block is not None:
             contrib.session_block = self._session_block_map[old_contrib.session_block]
         new_event.contributions.append(contrib)
         self._contrib_map[old_contrib] = contrib
示例#3
0
 def _clone_contribs(self, new_event):
     attrs = (get_simple_column_attrs(Contribution) | {'own_room', 'own_venue'}) - {'abstract_id'}
     query = (Contribution.query.with_parent(self.old_event)
              .options(undefer('_last_friendly_subcontribution_id'),
                       joinedload('own_venue'),
                       joinedload('own_room').lazyload('*'),
                       joinedload('session'),
                       joinedload('session_block').lazyload('session'),
                       joinedload('type'),
                       subqueryload('acl_entries'),
                       subqueryload('subcontributions').joinedload('references'),
                       subqueryload('references'),
                       subqueryload('person_links'),
                       subqueryload('field_values')))
     for old_contrib in query:
         contrib = Contribution()
         contrib.populate_from_attrs(old_contrib, attrs)
         contrib.subcontributions = list(self._clone_subcontribs(old_contrib.subcontributions))
         contrib.acl_entries = clone_principals(ContributionPrincipal, old_contrib.acl_entries)
         contrib.references = list(self._clone_references(ContributionReference, old_contrib.references))
         contrib.person_links = list(self._clone_person_links(ContributionPersonLink, old_contrib.person_links))
         contrib.field_values = list(self._clone_fields(old_contrib.field_values))
         if old_contrib.type is not None:
             contrib.type = self._contrib_type_map[old_contrib.type]
         if old_contrib.session is not None:
             contrib.session = self._session_map[old_contrib.session]
         if old_contrib.session_block is not None:
             contrib.session_block = self._session_block_map[old_contrib.session_block]
         new_event.contributions.append(contrib)
         self._contrib_map[old_contrib] = contrib
示例#4
0
文件: clone.py 项目: indico/indico
 def _create_new_contribution(self, event, old_contrib, preserve_session=True, excluded_attrs=None):
     attrs = (get_simple_column_attrs(Contribution) | {'own_room', 'own_venue'}) - {'abstract_id'}
     if excluded_attrs is not None:
         attrs -= excluded_attrs
     new_contrib = Contribution()
     new_contrib.populate_from_attrs(old_contrib, attrs)
     new_contrib.subcontributions = list(self._clone_subcontribs(old_contrib.subcontributions))
     new_contrib.acl_entries = clone_principals(ContributionPrincipal, old_contrib.acl_entries)
     new_contrib.references = list(self._clone_references(ContributionReference, old_contrib.references))
     new_contrib.person_links = list(self._clone_person_links(ContributionPersonLink, old_contrib.person_links))
     new_contrib.field_values = list(self._clone_fields(old_contrib.field_values))
     if old_contrib.type is not None:
         new_contrib.type = self._contrib_type_map[old_contrib.type]
     if preserve_session:
         if old_contrib.session is not None:
             new_contrib.session = self._session_map[old_contrib.session]
         if old_contrib.session_block is not None:
             new_contrib.session_block = self._session_block_map[old_contrib.session_block]
     event.contributions.append(new_contrib)
     return new_contrib