From c97f4b9c7f7b3349f471a869ecb1f4cbde36ff7e Mon Sep 17 00:00:00 2001 From: pouanideumassisergebeaujard Date: Tue, 10 Dec 2019 15:33:46 +0100 Subject: [PATCH] Praktikum8 --- news1/db.sqlite3 | Bin 147456 -> 147456 bytes news1/news1/settings.py | 5 +++++ news1/posts/templates/posts/notice.html | 12 +++++++++++- news1/posts/views.py | 3 +++ news1/templates/base.html | 5 ++++- 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/news1/db.sqlite3 b/news1/db.sqlite3 index a45eba5fd515a9dc6ffab3bc1dcd8eef45c38110..ef1c6ad8c08dfe60398a041c6e24b162cd11694f 100644 GIT binary patch delta 1209 zcma)*Pj3=I7{+&5OHy{1DXmDUjm3n6F`?c0vn;#BCaCG5NfQ&lfD0^8{&d+2-L{EY zf}DCVS`)pP^inUzOT&SSCmSz(g>o=8Ui=P5r;xR%gfiLF?E9PNd7pQt(U@*DreEG< zE3XzGu$7Z1!4)>#-dTAe`8Z*X@qZRu!dm-wBq7{sCb_AN)>JCDqrzQO#JC>cE0VHq z8Jp;7+{|VaGhHA#(*Ch^jnxo|K%$|zM&xA)OGrsHlb${=*(OS-Wnv>;ua|dqLa?z{ zwN+f%G|KyVwa+hH@K_^~CXr==RFx>rB-`g-e{~|XW`Xr_;E(|w&;y6{Md7<};*0IVkL9=H@WY=kujf$#p^9OEkWV&)vd9Tk`{^P$(3OMYmu)gF{{>NOf|j zpSEq=b|GgxrQGl`;Sk2QZr1a8%hq+>B}akqk86B=AXlbqoJR-6h8hD=1_c5b8{7M} zaXOb#z*!mvC1hDnBql>pV2~a}7$OHx2!R1)S(afKlQFWNWHj z1woVGe;~8!ZW;jy0T0{&58MC;vk`#M53}5V+#eD!GaxZCIx;ajFgGqZIWsgiGlR;X zx5}RZI#31y58?n1;OMgJ_05JGzXW=KLRP2D?S1Xx1~M; FTLBvXJ^BCu diff --git a/news1/news1/settings.py b/news1/news1/settings.py index 353a30a..cefc0f0 100644 --- a/news1/news1/settings.py +++ b/news1/news1/settings.py @@ -39,6 +39,9 @@ INSTALLED_APPS = [ 'django.contrib.staticfiles', 'posts', 'rest_framework', + 'channels', + 'django_eventstream', + ] MIDDLEWARE = [ @@ -49,6 +52,7 @@ MIDDLEWARE = [ 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', + 'django_grip.GripMiddleware' ] ROOT_URLCONF = 'news1.urls' @@ -71,6 +75,7 @@ TEMPLATES = [ ] WSGI_APPLICATION = 'news1.wsgi.application' +ASGI_APPLICATION = 'news1.routing.application' # Database diff --git a/news1/posts/templates/posts/notice.html b/news1/posts/templates/posts/notice.html index 58e6888..4af4b39 100644 --- a/news1/posts/templates/posts/notice.html +++ b/news1/posts/templates/posts/notice.html @@ -3,6 +3,7 @@ +
{% for notice in notices %}

{{ notice.notice_title }}

@@ -13,4 +14,13 @@

Neue Nachricht

Abmelden

-{% endblock %} \ No newline at end of file + +
+ + +{% endblock %} diff --git a/news1/posts/views.py b/news1/posts/views.py index c260a87..58f62eb 100644 --- a/news1/posts/views.py +++ b/news1/posts/views.py @@ -1,6 +1,7 @@ from django.contrib.auth.decorators import login_required from django.shortcuts import render, redirect from django.views.decorators.csrf import csrf_exempt +from django_eventstream import send_event from rest_framework.parsers import JSONParser from posts.forms import NoticeForm @@ -27,6 +28,7 @@ def new(request): pub_start=form.cleaned_data['start'], pub_end=form.cleaned_data['end']) newNotice.save() + send_event('notice', 'message', newNotice.id) return redirect('index') context = {'form': NoticeForm()} return render(request, 'posts/edit.html', context) @@ -36,6 +38,7 @@ def delete(request, deleteId=None): delNotice= Notice.objects.get(id=deleteId) if delNotice!= None: delNotice.delete() + send_event('notice', 'message', deleteId) return redirect('index') @csrf_exempt def notice_list(request): diff --git a/news1/templates/base.html b/news1/templates/base.html index f68622f..0678e17 100644 --- a/news1/templates/base.html +++ b/news1/templates/base.html @@ -1,6 +1,9 @@ +{% load static %} + + @@ -60,4 +63,4 @@ - \ No newline at end of file +