Browse Source

03.12

master
Mai Gillmann 4 years ago
commit
d970005a13

+ 16
- 0
.idea/dataSources.xml View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="db" uuid="1511f2ca-09be-4991-9948-4b664fe506bb">
<driver-ref>sqlite.xerial</driver-ref>
<synchronize>true</synchronize>
<imported>true</imported>
<remarks>SQLite</remarks>
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
<jdbc-url>jdbc:sqlite:$PROJECT_DIR$/db.sqlite3</jdbc-url>
<driver-properties>
<property name="enable_load_extension" value="true" />
</driver-properties>
</data-source>
</component>
</project>

+ 6
- 0
.idea/vcs.xml View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

+ 13
- 0
posts/forms.py View File

@@ -0,0 +1,13 @@
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
- 0
posts/migrations/0001_initial.py View File

@@ -0,0 +1,24 @@
# Generated by Django 2.2.6 on 2019-11-19 13:19

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
posts/migrations/__init__.py View File


+ 7
- 0
posts/serializers.py View 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
- 0
posts/urls.py View File

@@ -0,0 +1,11 @@
from django.urls import path
from . import views

urlpatterns = [
path('', views.index, name='index'),
path('new', views.new, name='new'),
path('delete/<int:deleteId>', views.delete, name='delete'),

path('notices/', views.notice_list),
path('notices/<int:id>/', views.notice_detail),
]

+ 45
- 0
templates/base.html View File

@@ -0,0 +1,45 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{% block title %} {% endblock %}</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
</head>
<body>
{% block navigation %}
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="http://127.0.0.1:8000/">BlahBlahWebseite</a>
</div>
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="https://www.th-nuernberg.de/fakultaeten/efi/">efi-Homepage</a></li>
<li><a href="https://www.google.de">Google</a></li>
<li><a href="https://getbootstrap.com/docs/3.4/getting-started/">Bootstrap</a></li>
<li><a href="#">Weiß nicht</a></li>
</ul>
</div>
</nav>
{% endblock %}

<div class="container">
<div class="jumbotron">
<h1>Probieren</h1>
<p>Hier ist etwas blahblah.</p>
</div>
</div>

{% block content %}

<div>
<p>Hier ist etwas.</p>
<p>Da ist noch etwas.</p>
</div>
{% endblock %}


</body>
</html>

+ 13
- 0
templates/posts/edit.html View File

@@ -0,0 +1,13 @@
{% extends 'base.html' %}
{% block title %}
Edit
{% endblock %}

{% 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 %}

+ 34
- 0
templates/posts/index.html View File

@@ -0,0 +1,34 @@
{% extends 'base.html' %}

{% block title %}
Index
{% endblock %}

{% block content %}
<h1>Index der Applikation</h1>
<form action="/posts" method="POST">


{% for notice in notices %}
<div>
<p>published: {{ notice.pub_start }}</p>
<h2><a href="">{{ notice.notice_title }}</a></h2>
<p>{{ notice.notice_text|linebreaksbr }}</p>
<p>
<a href="{% url 'delete' deleteId=notice.id %}" class="btn btn-danger">
Meldung löschen
</a>
</p>
</div>
{% endfor %}

<div>
<p>
<a href="{% url 'new' %}" class="btn btn-info" role="button">Neue Nachricht</a>
</p>
</div>


</form>
{% endblock %}


Loading…
Cancel
Save