This commit is contained in:
Nadege committed 2019-12-09 18:24:21 +01:00
1 parent f91294bf07
commit 533301e520
5 files changed
+19 -1

No files matched your search

+6
View File
@@ -16,6 +16,12 @@
</div>
</div>
<script>
var es = new ReconnectingEventSource('/events/');
es.addEventListener('message', function (e) {
console.log(e.data);location.reload();false
})
</script>
{% endblock %}
+2
View File
@@ -4,6 +4,7 @@ from django.http import HttpResponse, JsonResponse
from django.shortcuts import render, redirect
from django.utils import timezone
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
@@ -36,6 +37,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)