mirror of
https://github.com/chibicitiberiu/ytsm.git
synced 2024-02-24 05:43:31 +00:00
Added a basic notification system. Long processes will call the notification API, and the notification events are registered. For now, notifications are pushed to the client by polling (client polls every second for new events). A basic status message is now displayed when the sync process starts and ends.
This commit is contained in:
@ -13,6 +13,7 @@ from YtManagerApp.management.videos import get_videos
|
||||
from YtManagerApp.models import Subscription, SubscriptionFolder, VIDEO_ORDER_CHOICES, VIDEO_ORDER_MAPPING
|
||||
from YtManagerApp.utils import youtube
|
||||
from YtManagerApp.views.controls.modal import ModalMixin
|
||||
from YtManagerApp.management.notification_manager import get_current_notification_id
|
||||
|
||||
|
||||
class VideoFilterForm(forms.Form):
|
||||
@ -94,7 +95,8 @@ def __tree_sub_id(sub_id):
|
||||
def index(request: HttpRequest):
|
||||
if request.user.is_authenticated:
|
||||
context = {
|
||||
'filter_form': VideoFilterForm()
|
||||
'filter_form': VideoFilterForm(),
|
||||
'current_notification_id': get_current_notification_id(),
|
||||
}
|
||||
return render(request, 'YtManagerApp/index.html', context)
|
||||
else:
|
||||
|
12
app/YtManagerApp/views/notifications.py
Normal file
12
app/YtManagerApp/views/notifications.py
Normal file
@ -0,0 +1,12 @@
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.http import HttpRequest, JsonResponse
|
||||
|
||||
from YtManagerApp.management.notification_manager import get_notifications
|
||||
|
||||
|
||||
@login_required
|
||||
def ajax_get_notifications(request: HttpRequest, last_id: int):
|
||||
user = request.user
|
||||
notifications = get_notifications(user, last_id)
|
||||
notifications = list(notifications)
|
||||
return JsonResponse(notifications, safe=False)
|
Reference in New Issue
Block a user