@@ -11,19 +11,3 @@ class NoticeForm(forms.Form): | |||
end = forms.DateField(label='Bis', | |||
input_formats=date_formats, | |||
initial=datetime.datetime.today() + datetime.timedelta(days=1)) | |||
class EditNoticeForm(forms.Form): | |||
def __init__(self, *args, **kwargs): | |||
self.title = forms.CharField(label='Titel', | |||
max_length=80, | |||
initial=kwargs.pop('notice_title')) | |||
self.text = forms.CharField(label='Text', | |||
max_length=400, | |||
initial=kwargs.pop('notice_text')) | |||
self.start = forms.DateField(label='Von', | |||
initial=kwargs.pop('notice.pub_start'), | |||
input_formats=NoticeForm.date_formats) | |||
self.end = forms.DateField(label='Bis', | |||
initial=kwargs.pop('pub_end'), | |||
input_formats=NoticeForm.date_formats) | |||
super(EditNoticeForm, self).__init__(*args, **kwargs) |
@@ -5,7 +5,6 @@ urlpatterns = [ | |||
path('', views.index, name='posts'), | |||
path('new', views.new, name='new'), | |||
path('delete/<int:deleteId>', views.delete, name='delete'), | |||
path('edit/<int:editId>', views.edit, name='edit'), | |||
path('notices/', views.notice_list), | |||
path('notices/<int:id>/', views.notice_detail), |
@@ -11,7 +11,7 @@ from rest_framework.renderers import JSONRenderer | |||
from rest_framework.parsers import JSONParser | |||
from .models import Notice | |||
from .forms import NoticeForm, EditNoticeForm | |||
from .forms import NoticeForm | |||
from .serializers import NoticeSerializer | |||
logger = None | |||
@@ -65,34 +65,6 @@ def delete(request, deleteId=None): | |||
return redirect('posts') | |||
def edit(request, editId=None): | |||
init_loger(__name__) | |||
logger.debug(editId) | |||
logger.debug(request.method) | |||
editNotice = None | |||
if editId: | |||
editNotice = Notice.objects.get(id=editId) | |||
logger.debug(editNotice) | |||
if editNotice: | |||
form = EditNoticeForm(editNotice) | |||
#form.title = editNotice.notice_title | |||
#form.notice_to_form(editNotice) | |||
logger.info(form) | |||
#if form.is_valid(): | |||
# return HttpResponse(status=204) | |||
context = {'form' : form} | |||
return render(request, 'posts/edit.html', context) | |||
""" | |||
newNotice = 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() | |||
send_event('notice', 'message', newNotice.id) | |||
return redirect('posts') | |||
""" | |||
@csrf_exempt | |||
def notice_list(request): | |||
if request.method == 'GET': |
@@ -21,7 +21,6 @@ Index | |||
<p>{{ notice.notice_text }}</p> | |||
<p> | |||
<a href="{% url 'delete' deleteId=notice.id %}" class="btn btn-danger" role="button">Delete</a> | |||
<a href="{% url 'edit' editId=notice.id %}" class="btn btn-info" role="button">Edit</a> | |||
</p> | |||
{% if message %} | |||
<script> |