add new project

This commit is contained in:
2019-12-10 15:27:07 +01:00
parent 487a8b5ed2
commit 6ed7b6a96b
3 changed files with 30 additions and 34 deletions
+6 -3
View File
@@ -7,6 +7,7 @@ from posts.serializer import NoticeSerializer
from django.http import JsonResponse
from rest_framework.parsers import JSONParser
from django.views.decorators.csrf import csrf_exempt
from django_eventstream import send_event
# Create your views here.
@@ -27,12 +28,13 @@ def new(request):
if request.method == "POST":
form = NoticeForm(request.POST)
if form.is_valid():
newNotice = Notice(notice_title=form.cleaned_data['title'],
new_Notice = Notice(notice_title=form.cleaned_data['title'],
notice_text=form.cleaned_data['text'],
pub_start=form.cleaned_data['start'],
pub_end=form.cleaned_data['end'])
newNotice.save()
#return redirect('index')
new_Notice.save()
send_event('notice', 'message', new_Notice.id)
return redirect('index')
context = {'form': NoticeForm()}
return render(request, 'posts/edit.html', context)
@@ -41,6 +43,7 @@ def delete(request, deleteId=None):
if deleteId != None:
delNotice = Notice.objects.get(id=deleteId)
if delNotice != None:
send_event('notice', 'message', delNotice.id)
delNotice.delete()
return redirect('index')