Browse Source

reset without edit func

master
Heimbs 5 years ago
parent
commit
7dac572f9d
4 changed files with 1 additions and 47 deletions
  1. 0
    16
      news/posts/forms.py
  2. 0
    1
      news/posts/urls.py
  3. 1
    29
      news/posts/views.py
  4. 0
    1
      news/templates/posts/index.html

+ 0
- 16
news/posts/forms.py View File

@@ -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)

+ 0
- 1
news/posts/urls.py View File

@@ -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),

+ 1
- 29
news/posts/views.py View File

@@ -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':

+ 0
- 1
news/templates/posts/index.html View File

@@ -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>

Loading…
Cancel
Save