예제 #1
0
def clone_event(event, start_dt, cloners, category=None):
    """Clone an event on a given date/time.

    Runs all required cloners.

    :param start_dt: The start datetime of the new event;
    :param cloners: A set containing the names of all enabled cloners;
    :param category: The `Category` the new event will be created in.
    """
    end_dt = start_dt + event.duration
    data = {
        'start_dt': start_dt,
        'end_dt': end_dt,
        'timezone': event.timezone,
        'title': event.title,
        'description': event.description,
    }
    new_event = create_event(category or event.category,
                             event.type_,
                             data,
                             features=features_event_settings.get(
                                 event, 'enabled'),
                             add_creator_as_manager=False)

    # Run the modular cloning system
    EventCloner.run_cloners(event, new_event, cloners)
    signals.event.cloned.send(event, new_event=new_event)

    # Grant access to the event creator -- must be done after modular cloners
    # since cloning the event ACL would result in a duplicate entry
    with new_event.logging_disabled:
        new_event.update_principal(session.user, full_access=True)

    return new_event
예제 #2
0
    def clone(self, startDate):
        # startDate is in the timezone of the event
        old_event = self.as_event
        start_dt = old_event.tzinfo.localize(startDate).astimezone(utc)
        end_dt = start_dt + old_event.duration
        data = {
            'start_dt': start_dt,
            'end_dt': end_dt,
            'timezone': old_event.timezone,
            'title': old_event.title,
            'description': old_event.description,
            'visibility': old_event.visibility
        }
        event = create_event(old_event.category, old_event.type_, data,
                             features=features_event_settings.get(self, 'enabled'),
                             add_creator_as_manager=False)

        # Run the new modular cloning system
        EventCloner.run_cloners(old_event, event)
        signals.event.cloned.send(old_event, new_event=event)

        # Grant access to the event creator -- must be done after modular cloners
        # since cloning the event ACL would result in a duplicate entry
        with event.logging_disabled:
            event.update_principal(session.user, full_access=True)

        return event.as_legacy
예제 #3
0
def clone_event(event, start_dt, cloners, category=None):
    """Clone an event on a given date/time.

    Runs all required cloners.

    :param start_dt: The start datetime of the new event;
    :param cloners: A set containing the names of all enabled cloners;
    :param category: The `Category` the new event will be created in.
    """
    end_dt = start_dt + event.duration
    data = {
        'start_dt': start_dt,
        'end_dt': end_dt,
        'timezone': event.timezone,
        'title': event.title,
        'description': event.description,
    }
    new_event = create_event(category or event.category, event.type_, data,
                             features=features_event_settings.get(event, 'enabled'),
                             add_creator_as_manager=False)

    # Run the modular cloning system
    EventCloner.run_cloners(event, new_event, cloners)
    signals.event.cloned.send(event, new_event=new_event)

    # Grant access to the event creator -- must be done after modular cloners
    # since cloning the event ACL would result in a duplicate entry
    with new_event.logging_disabled:
        new_event.update_principal(session.user, full_access=True)

    return new_event
예제 #4
0
파일: util.py 프로젝트: DirkHoffmann/indico
def get_enabled_features(event, only_explicit=False):
    """Returns a set of enabled feature names for an event"""
    enabled_features = features_event_settings.get(event, 'enabled')
    if enabled_features is not None:
        return set(enabled_features)
    elif only_explicit:
        return set()
    else:
        return {name for name, feature in get_feature_definitions().iteritems() if feature.is_default_for_event(event)}
예제 #5
0
def get_enabled_features(event, only_explicit=False):
    """Returns a set of enabled feature names for an event"""
    enabled_features = features_event_settings.get(event, 'enabled')
    if enabled_features is not None:
        return set(enabled_features)
    elif only_explicit:
        return set()
    else:
        return {name for name, feature in get_feature_definitions().iteritems() if feature.is_default_for_event(event)}
예제 #6
0
파일: util.py 프로젝트: innovexa/IDC-Events
def is_feature_enabled(event, name):
    """Checks if a feature is enabled for an event.

    :param event: The event (or event ID) to check.
    :param name: The name of the feature.
    """
    feature = get_feature_definition(name)
    enabled_features = features_event_settings.get(event, 'enabled')
    if enabled_features is not None:
        return feature.name in enabled_features
    else:
        if isinstance(event, (basestring, int, long)):
            event = Event.get(event)
        return event and feature.is_default_for_event(event)
예제 #7
0
파일: util.py 프로젝트: DirkHoffmann/indico
def is_feature_enabled(event, name):
    """Checks if a feature is enabled for an event.

    :param event: The event (or event ID) to check.
    :param name: The name of the feature.
    """
    feature = get_feature_definition(name)
    enabled_features = features_event_settings.get(event, 'enabled')
    if enabled_features is not None:
        return feature.name in enabled_features
    else:
        if isinstance(event, (basestring, int, long)):
            event = Event.get(event)
        return event and feature.is_default_for_event(event)
예제 #8
0
def clone_event(event,
                n_occurrence,
                start_dt,
                cloners,
                category=None,
                refresh_users=False):
    """Clone an event on a given date/time.

    Runs all required cloners.

    :param n_occurrence: The 1-indexed number of the occurrence, if this is a "recurring" clone, otherwise `0`
    :param start_dt: The start datetime of the new event;
    :param cloners: A set containing the names of all enabled cloners;
    :param category: The `Category` the new event will be created in.
    :aparam refresh_users: Whether `EventPerson` data should be updated from
                           their linked `User` object
    """
    end_dt = start_dt + event.duration
    data = {
        'start_dt': start_dt,
        'end_dt': end_dt,
        'timezone': event.timezone,
        'title': event.title,
        'description': event.description,
        'own_map_url': event.own_map_url
    }
    new_event = create_event(category or event.category,
                             event.type_,
                             data,
                             features=features_event_settings.get(
                                 event, 'enabled'),
                             add_creator_as_manager=False,
                             cloning=True)

    # Run the modular cloning system
    EventCloner.run_cloners(event, new_event, cloners, n_occurrence)
    if refresh_users:
        new_event.refresh_event_persons(notify=False)
    signals.event.cloned.send(event, new_event=new_event)

    # Grant access to the event creator -- must be done after modular cloners
    # since cloning the event ACL would result in a duplicate entry
    with new_event.logging_disabled:
        new_event.update_principal(session.user, full_access=True)

    return new_event