コード例 #1
0
ファイル: websockets.py プロジェクト: webkom/lego
def notify_event_updated(event, **kwargs):
    full_access_group = group_for_event(event, True)
    limited_access_group = group_for_event(event, False)
    serializer = EventReadDetailedSocketSerializer(
        {"type": "SOCKET_EVENT_UPDATED", "payload": event, "meta": kwargs}
    )

    notify_group(full_access_group, serializer.data)
    notify_group(limited_access_group, serializer.data)
コード例 #2
0
ファイル: websockets.py プロジェクト: webkom/lego
def notify_event_registration(action_type, registration, **kwargs):
    full_access_group = group_for_event(registration.event, True)
    partial_access_group = group_for_event(registration.event, False)

    kwargs["event_id"] = registration.event.id
    full_serializer = RegistrationReadSocketSerializer(
        {"type": action_type, "payload": registration, "meta": kwargs}
    )
    partial_serializer = RegistrationReadAnonymizedSocketSerializer(
        {"type": action_type, "payload": registration, "meta": kwargs}
    )

    notify_group(full_access_group, full_serializer.data)
    notify_group(partial_access_group, partial_serializer.data)
コード例 #3
0
def notify_event_updated(event, **kwargs):
    group = group_for_event(event)
    serializer = EventReadDetailedSocketSerializer({
        "type": "SOCKET_EVENT_UPDATED",
        "payload": event,
        "meta": kwargs
    })

    notify_group(group, serializer.data)
コード例 #4
0
def notify_event_registration(action_type, registration, **kwargs):
    group = group_for_event(registration.event)
    kwargs["event_id"] = registration.event.id
    serializer = RegistrationReadSocketSerializer({
        "type": action_type,
        "payload": registration,
        "meta": kwargs
    })
    notify_group(group, serializer.data)
コード例 #5
0
ファイル: websockets.py プロジェクト: vhellem/lego
def notify_event_updated(event, **kwargs):
    group = group_for_event(event)
    serializer = EventReadDetailedSocketSerializer({
        'type': 'SOCKET_EVENT_UPDATED',
        'payload': event,
        'meta': kwargs
    })

    notify_group(group, serializer.data)
コード例 #6
0
ファイル: websockets.py プロジェクト: vhellem/lego
def notify_event_registration(action_type, registration, **kwargs):
    group = group_for_event(registration.event)
    kwargs['event_id'] = registration.event.id
    serializer = RegistrationReadSocketSerializer({
        'type': action_type,
        'payload': registration,
        'meta': kwargs
    })
    notify_group(group, serializer.data)
コード例 #7
0
def find_event_groups(user):
    """
    Find all channels groups the user belongs to as a result
    of being signed up to future events.
    """
    queryset = Event.objects.filter(start_time__gt=datetime.now())
    if not user.has_perm(LIST, queryset):
        permission_handler = get_permission_handler(queryset.model)
        queryset = permission_handler.filter_queryset(user, queryset)

    groups = []
    for event in queryset:
        groups.append(group_for_event(event))

    return groups
コード例 #8
0
ファイル: websockets.py プロジェクト: webkom/lego
def find_event_groups(user):
    """
    Find all channels groups the user belongs to as a result
    of being signed up to future events.

    Since we use websockets for registrations and event description updates, include events
    that has not started and that started less than two days ago.
    """
    queryset = Event.objects.filter(start_time__gt=datetime.now() - timedelta(days=2))
    if not user.has_perm(LIST, queryset):
        permission_handler = get_permission_handler(queryset.model)
        queryset = permission_handler.filter_queryset(user, queryset)

    groups = []
    for event in queryset:
        groups.append(group_for_event(event, event.user_should_see_regs(user)))

    return groups