Exemple #1
0
def create_contribution(event, contrib_data, custom_fields_data=None, session_block=None, extend_parent=False):
    start_dt = contrib_data.pop('start_dt', None)
    contrib = Contribution(event_new=event)
    contrib.populate_from_dict(contrib_data)
    if start_dt is not None:
        schedule_contribution(contrib, start_dt=start_dt, session_block=session_block, extend_parent=extend_parent)
    if custom_fields_data:
        set_custom_fields(contrib, custom_fields_data)
    db.session.flush()
    signals.event.contribution_created.send(contrib)
    logger.info('Contribution %s created by %s', contrib, session.user)
    contrib.event_new.log(EventLogRealm.management, EventLogKind.positive, 'Contributions',
                          'Contribution "{}" has been created'.format(contrib.title), session.user)
    return contrib
Exemple #2
0
    def clone_single_contribution(cls, contribution, preserve_session=False):
        """Clone a single contribution within the same event.

        :param contribution: The `Contribution` to clone
        :param preserve_session: Whether to assign and schedule
        :return: The newly created contribution
        """
        event = contribution.event
        cloner = cls(event)
        cloner._person_map = dict(zip(event.persons, event.persons))
        cloner._session_map = {contribution.session: contribution.session}
        cloner._session_block_map = {contribution.session_block: contribution.session_block}
        cloner._contrib_type_map = {contribution.type: contribution.type}
        cloner._contrib_field_map = dict(zip(event.contribution_fields, event.contribution_fields))
        cloner._contrib_map = {}
        cloner._subcontrib_map = {}
        new_contribution = cloner._create_new_contribution(event, contribution,
                                                           preserve_session=preserve_session,
                                                           excluded_attrs={'friendly_id'})
        if preserve_session:
            entry = schedule_contribution(new_contribution, contribution.timetable_entry.start_dt,
                                          session_block=new_contribution.session_block)
            event.timetable_entries.append(entry)
        db.session.flush()
        return new_contribution
Exemple #3
0
 def _schedule(self, contrib, start_dt):
     return schedule_contribution(contrib,
                                  start_dt,
                                  session_block=self.session_block,
                                  extend_parent=True)
Exemple #4
0
 def _schedule(self, contrib, start_dt):
     return schedule_contribution(contrib, start_dt, session_block=self.session_block)
Exemple #5
0
 def _schedule(self, contrib, start_dt):
     return schedule_contribution(contrib, start_dt, session_block=self.session_block, extend_parent=True)