@@ -0,0 +1,4 @@ | |||
db.sqlite3 | |||
bin/* | |||
venv/* | |||
lib/* |
@@ -0,0 +1,12 @@ | |||
from django import forms | |||
import datetime | |||
class NoticeForm(forms.Form): | |||
date_formats = ['%d.%m.%Y', '%d.%m.%y'] | |||
title = forms.CharField(label='Titel', max_length=80) | |||
text = forms.CharField(label='Text', max_length=400) | |||
start = forms.DateField(label='Von', | |||
input_formats=date_formats, | |||
initial=datetime.date.today) | |||
end = forms.DateField(label='Bis', | |||
input_formats=date_formats, | |||
initial=datetime.date.today) |
@@ -0,0 +1,24 @@ | |||
# Generated by Django 2.2.7 on 2019-11-12 12:46 | |||
from django.db import migrations, models | |||
class Migration(migrations.Migration): | |||
initial = True | |||
dependencies = [ | |||
] | |||
operations = [ | |||
migrations.CreateModel( | |||
name='Notice', | |||
fields=[ | |||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | |||
('notice_title', models.CharField(max_length=80)), | |||
('notice_text', models.CharField(max_length=400)), | |||
('pub_start', models.DateTimeField()), | |||
('pub_end', models.DateTimeField()), | |||
], | |||
), | |||
] |
@@ -0,0 +1,7 @@ | |||
from rest_framework import serializers | |||
from .models import Notice | |||
class NoticeSerializer(serializers.ModelSerializer): | |||
class Meta: | |||
model = Notice | |||
fields = ('id' , 'notice_title','notice_text', 'pub_start', 'pub_end') |
@@ -0,0 +1,11 @@ | |||
{% extends 'base.html'%} | |||
{% block content %} | |||
<h1>Neue Nachricht</h1> | |||
<form method="POST"> | |||
{% csrf_token %} | |||
{{ form.as_p }} | |||
<button type="submit" class="save btn btn-default">Speichern</button> | |||
</form> | |||
{% endblock %} |
@@ -0,0 +1,16 @@ | |||
{% extends 'base.html'%} | |||
{% block content %} | |||
<div class="container"> | |||
{% for notice in notices %} | |||
<h3> {{ notice.notice_title }}</h3> | |||
<p> {{ notice.notice_text }}</p> | |||
<p><a href="{% url 'delete' deleteId=notice.id%}" class="btn btn-danger">Meldung löschen</a></p> | |||
<hr> | |||
{% endfor %} | |||
<p><a href="{% url 'new' %}" class="btn btn-info" role="button">Neue Nachricht</a></p> | |||
<p><a href="{% url 'logout' %}" class="btn btn-warning">Abmelden</a></p> | |||
{% endblock %} |