示例#1
0
def _ensure_consistency(contrib):
    """Unschedule contribution if not consistent with timetable.

    A contribution that has no session assigned, may not be scheduled
    inside a session.  A contribution that has a session assigned may
    only be scheduled inside a session block associated with that
    session, and that session block must match the session block of
    the contribution.

    :return: A bool indicating whether the contribution has been
             unscheduled to preserve consistency.
    """
    entry = contrib.timetable_entry
    if entry is None:
        return False
    if entry.parent_id is None and (contrib.session is not None
                                    or contrib.session_block is not None):
        # Top-level entry but we have a session/block set
        delete_timetable_entry(entry, log=False)
        return True
    elif entry.parent_id is not None:
        parent = entry.parent
        # Nested entry but no or a different session/block set
        if parent.session_block.session != contrib.session or parent.session_block != contrib.session_block:
            delete_timetable_entry(entry, log=False)
            return True
    return False
示例#2
0
def _ensure_consistency(contrib):
    """Unschedule contribution if not consistent with timetable

    A contribution that has no session assigned, may not be scheduled
    inside a session.  A contribution that has a session assigned may
    only be scheduled inside a session block associated with that
    session, and that session block must match the session block of
    the contribution.

    :return: A bool indicating whether the contribution has been
             unscheduled to preserve consistency.
    """
    entry = contrib.timetable_entry
    if entry is None:
        return False
    if entry.parent_id is None and (contrib.session is not None or contrib.session_block is not None):
        # Top-level entry but we have a session/block set
        delete_timetable_entry(entry, log=False)
        return True
    elif entry.parent_id is not None:
        parent = entry.parent
        # Nested entry but no or a different session/block set
        if parent.session_block.session != contrib.session or parent.session_block != contrib.session_block:
            delete_timetable_entry(entry, log=False)
            return True
    return False
示例#3
0
 def _process(self):
     if self.entry.type == TimetableEntryType.SESSION_BLOCK:
         delete_session_block(self.entry.session_block)
     elif self.entry.type == TimetableEntryType.CONTRIBUTION and self.event_new.type != 'conference':
         delete_contribution(self.entry.contribution)
     else:
         delete_timetable_entry(self.entry)
     return jsonify_data(flash=False)
示例#4
0
 def _process_DELETE(self):
     """Delete a timetable entry"""
     if self.entry.type == TimetableEntryType.SESSION_BLOCK:
         delete_session_block(self.entry.session_block)
     elif self.event.type != 'conference' and self.entry.type == TimetableEntryType.CONTRIBUTION:
         delete_contribution(self.entry.contribution)
     else:
         delete_timetable_entry(self.entry)
示例#5
0
文件: manage.py 项目: ipaste/indico
 def _process_DELETE(self):
     """Delete a timetable entry"""
     if self.entry.type == TimetableEntryType.SESSION_BLOCK:
         delete_session_block(self.entry.session_block)
     elif self.event.type != 'conference' and self.entry.type == TimetableEntryType.CONTRIBUTION:
         delete_contribution(self.entry.contribution)
     else:
         delete_timetable_entry(self.entry)
示例#6
0
 def _process(self):
     if self.entry.type == TimetableEntryType.SESSION_BLOCK:
         delete_session_block(self.entry.session_block)
     elif self.entry.type == TimetableEntryType.CONTRIBUTION and self.event_new.type != 'conference':
         delete_contribution(self.entry.contribution)
     else:
         delete_timetable_entry(self.entry)
     return jsonify_data(flash=False)
示例#7
0
def delete_contribution(contrib):
    contrib.is_deleted = True
    if contrib.timetable_entry is not None:
        delete_timetable_entry(contrib.timetable_entry, log=False)
    db.session.flush()
    signals.event.contribution_deleted.send(contrib)
    logger.info('Contribution %s deleted by %s', contrib, session.user)
    contrib.event_new.log(EventLogRealm.management, EventLogKind.negative, 'Contributions',
                          'Contribution "{}" has been deleted'.format(contrib.title), session.user)
示例#8
0
 def _process(self):
     day = self.entry.start_dt.astimezone(self.entry.event.tzinfo).date()
     block = self.entry.parent
     if self.entry.type == TimetableEntryType.SESSION_BLOCK:
         delete_session_block(self.entry.session_block)
     elif self.entry.type == TimetableEntryType.CONTRIBUTION and self.event.type != 'conference':
         delete_contribution(self.entry.contribution)
     else:
         delete_timetable_entry(self.entry)
     return jsonify_data(update=serialize_day_update(self.event, day, block=block, session_=self.session),
                         flash=False)
示例#9
0
文件: legacy.py 项目: florv/indico
 def _process(self):
     day = self.entry.start_dt.astimezone(self.entry.event_new.tzinfo).date()
     block = self.entry.parent
     if self.entry.type == TimetableEntryType.SESSION_BLOCK:
         delete_session_block(self.entry.session_block)
     elif self.entry.type == TimetableEntryType.CONTRIBUTION and self.event_new.type != 'conference':
         delete_contribution(self.entry.contribution)
     else:
         delete_timetable_entry(self.entry)
     return jsonify_data(update=serialize_day_update(self.event_new, day, block=block, session_=self.session),
                         flash=False)
示例#10
0
def delete_session_block(session_block):
    from indico.modules.events.contributions.operations import delete_contribution
    from indico.modules.events.timetable.operations import delete_timetable_entry
    session_ = session_block.session
    event = session_.event
    unschedule_contribs = session_.event.type_ == EventType.conference
    for contribution in session_block.contributions[:]:
        contribution.session_block = None
        if unschedule_contribs:
            delete_timetable_entry(contribution.timetable_entry, log=False)
        else:
            delete_contribution(contribution)
    for entry in session_block.timetable_entry.children[:]:
        delete_timetable_entry(entry, log=False)
    delete_timetable_entry(session_block.timetable_entry, log=False)
    signals.event.session_block_deleted.send(session_block)
    if session_block in session_.blocks:
        session_.blocks.remove(session_block)
    if not session_.blocks and session_.event.type != 'conference':
        delete_session(session_)
    db.session.flush()
    event.log(EventLogRealm.management,
              EventLogKind.negative,
              'Sessions',
              f'Session block "{session_block.title}" has been deleted',
              session.user,
              meta={'session_block_id': session_block.id})
    logger.info('Session block %s deleted by %s', session_block, session.user)
示例#11
0
def delete_session_block(session_block):
    from indico.modules.events.timetable.operations import delete_timetable_entry
    session_ = session_block.session
    for contribution in session_block.contributions[:]:
        contribution.session_block = None
        delete_timetable_entry(contribution.timetable_entry, log=False)
    for entry in session_block.timetable_entry.children[:]:
        delete_timetable_entry(entry, log=False)
    delete_timetable_entry(session_block.timetable_entry, log=False)
    signals.event.session_block_deleted.send(session_block)
    session_.blocks.remove(session_block)
    if not session_.blocks and session_.event_new.type != 'conference':
        delete_session(session_)
    db.session.flush()
    logger.info('Session block %s deleted by %s', session_block, session.user)
示例#12
0
def delete_session_block(session_block):
    from indico.modules.events.timetable.operations import delete_timetable_entry
    session_ = session_block.session
    for contribution in session_block.contributions[:]:
        contribution.session_block = None
        delete_timetable_entry(contribution.timetable_entry, log=False)
    for entry in session_block.timetable_entry.children[:]:
        delete_timetable_entry(entry, log=False)
    delete_timetable_entry(session_block.timetable_entry, log=False)
    signals.event.session_block_deleted.send(session_block)
    if session_block in session_.blocks:
        session_.blocks.remove(session_block)
    if not session_.blocks and session_.event_new.type != 'conference':
        delete_session(session_)
    db.session.flush()
    logger.info('Session block %s deleted by %s', session_block, session.user)