Praktikum8
This commit is contained in:
parent
10d2dabced
commit
d3fc3d5e39
4
news1/.gitignore
vendored
Normal file
4
news1/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
db.sqlite3
|
||||||
|
bin/*
|
||||||
|
venv/*
|
||||||
|
lib/*
|
0
news1/djangoprojekt.patch
Normal file
0
news1/djangoprojekt.patch
Normal file
12
news1/posts/forms.py
Normal file
12
news1/posts/forms.py
Normal file
@ -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)
|
24
news1/posts/migrations/0001_initial.py
Normal file
24
news1/posts/migrations/0001_initial.py
Normal file
@ -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()),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
7
news1/posts/serializers.py
Normal file
7
news1/posts/serializers.py
Normal file
@ -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')
|
11
news1/posts/templates/posts/edit.html
Normal file
11
news1/posts/templates/posts/edit.html
Normal file
@ -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 %}
|
16
news1/posts/templates/posts/notice.html
Normal file
16
news1/posts/templates/posts/notice.html
Normal file
@ -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 %}
|
Loading…
x
Reference in New Issue
Block a user