/
githubmirror
/
edx-platform
Обзор
Документация
Войти
/
githubmirror
/
edx-platform
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
release-ulmo
openedx/features/calendar_sync/api.py
32 строки
1011 B
Dillon Dumesnil
AA-36: Link to toggle calendar sync
10 мар 2020, 21:45
Не верифицирован
10 мар 2020, 21:45
a59155e
Код
Авторство
О чём код?
""" API for the Calendar Sync Application """ from .models import UserCalendarSyncConfig SUBSCRIBE = 'subscribe' UNSUBSCRIBE = 'unsubscribe' def subscribe_user_to_calendar(user, course_key): """ Enables the Calendar Sync config for a particular user and course. Will create if needed. Parameters: user (User): The user to subscribe course_key (CourseKey): The course key for the subscription """ defaults = {'enabled': True} UserCalendarSyncConfig.objects.update_or_create(user=user, course_key=course_key, defaults=defaults) def unsubscribe_user_to_calendar(user, course_key): """ Disables the Calendar Sync config for a particular user and course. If the instance does not exist, this function will do nothing. Parameters: user (User): The user to subscribe course_key (CourseKey): The course key for the subscription """ UserCalendarSyncConfig.objects.filter(user=user, course_key=course_key).update(enabled=False)