@@ -31,6 +31,7 @@ ALLOWED_HOSTS = [] | |||
# Application definition | |||
INSTALLED_APPS = [ | |||
'polls.apps.PollsConfig', | |||
'django.contrib.admin', | |||
'django.contrib.auth', | |||
'django.contrib.contenttypes', | |||
@@ -106,7 +107,7 @@ AUTH_PASSWORD_VALIDATORS = [ | |||
LANGUAGE_CODE = 'de-de' | |||
TIME_ZONE = 'Europe/Berlin' | |||
TIME_ZONE = 'UTC' | |||
USE_I18N = True | |||
@@ -19,3 +19,4 @@ def main(): | |||
if __name__ == '__main__': | |||
main() | |||
@@ -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) |
@@ -1,3 +1,8 @@ | |||
from django.db import models | |||
# Create your models here. | |||
class Notice(models.Model): | |||
notice_title = models.CharField(max_length=80) | |||
notice_text = models.CharField(max_length=400) | |||
pub_start = models.DateTimeField() | |||
pub_end = models.DateTimeField() |
@@ -14,11 +14,18 @@ Including another URLconf | |||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) | |||
""" | |||
from django.conf.urls import url | |||
from django.urls import path | |||
from . import views | |||
from polls import views | |||
urlpatterns = [ | |||
path('', views.index , name='index'), | |||
#path('', views.index , name='index'), | |||
path('new', views.new, name='new'), | |||
#path('index',views.index, name='index'), | |||
path('notice',views.index, name = 'index'), | |||
path('welcome', views.welcome_seite), | |||
path('home', views.welcome_seite), | |||
path('about', views.about_seite), | |||
path('delete/<int:deleteId>', views.delete, name ='delete') | |||
#url(r'^new', views.new, name='new'), | |||
] |
@@ -1,5 +1,57 @@ | |||
from django.http import HttpResponse | |||
from django.shortcuts import render,redirect | |||
from .models import Notice | |||
from django.utils import timezone | |||
import logging | |||
from polls.forms import NoticeForm | |||
from django.shortcuts import render | |||
# Create your views here. | |||
logger = None | |||
def initLogger(): | |||
global logger | |||
if logger == None: | |||
logger = logging.getLogger('django.db.backends') | |||
logger.setLevel(logging.DEBUG) | |||
logger.addHandler(logging.StreamHandler()) | |||
def delate(request, deleteId=None): | |||
if deleteId !=None: | |||
delNotice = Notice.objects.get(id=deleteId) | |||
if delNotice != None: | |||
delNotice.delete() | |||
return redirect ('index') | |||
def index(request): | |||
return render(request, 'polls/index.html') | |||
notices = Notice.objects.all() | |||
notices = notices.filter(pub_start__lte=timezone.now()) | |||
notices = notices.filter(pub_end__gte=timezone.now()) | |||
#context = {"notices" : notices} | |||
return render(request, 'polls/notice.html',{"notices" : notices}) | |||
#def new(request): | |||
# return render(request, 'polls/edit.html') | |||
def new(request): | |||
if request.method == "POST": | |||
form = NoticeForm(request.POST) | |||
if form.is_valid(): | |||
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() | |||
return redirect('index') | |||
context = {'form': NoticeForm()} | |||
return render(request, 'polls/edit.html', context) | |||
def delete(request, deleteId = None): | |||
if deleteId != None: | |||
delNotice = Notice.objects.get(id=deleteId) | |||
if delNotice != None: | |||
delNotice.delete() | |||
return redirect('index') | |||
def welcome_seite(request): | |||
return render(request, 'polls/index.html') | |||
def about_seite(request): | |||
return render(request, 'polls/about.html') |
@@ -1,169 +1,48 @@ | |||
<!DOCTYPE HTML > | |||
<html lang="de-DE" class="scheme_original"> | |||
<head> | |||
<title>HTML FlexBox Template - Two columns, left menu</title> | |||
<meta http-equiv="content-type" content="text/html"> | |||
<meta name="description" content="Use this HTML basic website layout template with the navigation menu on the left, the main content at the center, the extra stuff on the right."> | |||
<meta name="generator" content="HAPedit 3.1"> | |||
<link rel="canonical" href="https://www.w3docs.com/snippets/html/layout_templates/01.html" /> | |||
<meta property="og:type" content="website" /> | |||
<meta property="og:title" content="HTML FlexBox Template - Two columns, left menu" /> | |||
<meta property="og:description" content="Use this HTML basic website layout template with the navigation menu on the left, the main content at the center, the extra stuff on the right." /> | |||
<meta property="og:image" content="https://www.w3docs.com/build/images/logo-amp.png" /> | |||
<meta property="og:image:type" content="image/jpeg" /> | |||
<meta property="og:image:width" content="192" /> | |||
<meta property="og:image:height" content="192" /> | |||
<meta property="og:image:alt" content="W3dcos" /> | |||
<style type="text/css"> | |||
html, body { | |||
margin: 0; | |||
padding: 0; | |||
} | |||
body { | |||
color: #292929; | |||
font: 90% Roboto, Arial, sans-serif; | |||
font-weight: 300; | |||
} | |||
p { | |||
padding: 0 10px; | |||
line-height: 1.8; | |||
} | |||
ul li { | |||
padding-right: 10px; | |||
line-height: 1.6; | |||
} | |||
h3 { | |||
padding: 5px 20px; | |||
margin: 0; | |||
} | |||
div#header { | |||
position: relative; | |||
} | |||
div#header h1 { | |||
height: 80px; | |||
line-height: 80px; | |||
margin: 0; | |||
padding-left: 10px; | |||
background: #e0e0e0; | |||
color: #292929; | |||
} | |||
div#header a { | |||
position: absolute; | |||
right: 0; | |||
top: 23px; | |||
padding: 10px; | |||
color: #006; | |||
} | |||
div#navigation { | |||
background: #7cb71c; | |||
} | |||
div#navigation li { | |||
list-style: none; | |||
} | |||
div#extra { | |||
background: #147FA9; | |||
} | |||
div#footer { | |||
background: #42444e; | |||
color: #fff; | |||
} | |||
div#footer p { | |||
padding: 20px 10px; | |||
} | |||
div#wrapper { | |||
float: left; | |||
width: 100%; | |||
} | |||
div#content { | |||
margin: 0 25%; | |||
} | |||
div#navigation { | |||
float: left; | |||
width: 25%; | |||
margin-left: -100%; | |||
} | |||
div#extra { | |||
float: left; | |||
width: 25%; | |||
margin-left: -25%; | |||
} | |||
div#footer { | |||
clear: left; | |||
width: 100%; | |||
} | |||
</style> | |||
<!DOCTYPE html> | |||
<html lang="de"> | |||
<head> | |||
{# <link rel="stylesheet" href="/media/css/style.css" />#} | |||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css"> | |||
<meta name="viewport" content="width=device-width, initial-scale=1"> | |||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"> | |||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> | |||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script> | |||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script> | |||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> | |||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script> | |||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script> | |||
<title>{% block title %}First Django PR{% endblock %}</title> | |||
</head> | |||
<body> | |||
<div id="container"> | |||
<div id="header"> | |||
<h1>EUGEN WEB</h1> | |||
<a href="/download/template/1" target="_blank">download Link</a> | |||
</div> | |||
<div id="wrapper"> | |||
<div id="content"> | |||
<p><strong>1. Main Content</strong></p> | |||
<h3>Ueberschrift 1 </h3> | |||
<p> | |||
üüüüü | |||
</p> | |||
<p> | |||
TEXT1.1 | |||
</p> | |||
<h3>Ueberschrift2</h3> | |||
<p> | |||
TEXT2 | |||
</p> | |||
</div> | |||
</div> | |||
<div id="navigation"> | |||
<p><strong>2. Navigation Menu</strong></p> | |||
<h3>Seiten</h3> | |||
<ul> | |||
<li><a href="https://www.google.de/" target="_blank">GOOGLE</a></li> | |||
<li>1</li> | |||
<li>2</li> | |||
</ul> | |||
<h3>Verknupfungen und Bilder </h3> | |||
<ul> | |||
<li>5</li> | |||
<li>6</li> | |||
<li>7</li> | |||
<li>8</li> | |||
</ul> | |||
</div> | |||
<div id="extra"> | |||
<p><strong>3. Additional Stuff</strong></p> | |||
<h3>Stichpunkte:</h3> | |||
<ul> | |||
<li>X</li> | |||
<li>X</li> | |||
<li>X</li> | |||
<li>X</li> | |||
</ul> | |||
</div> | |||
<div id="footer"><p>Footer</p> | |||
</div> | |||
</div> | |||
<script type="text/javascript">AddFillerLink("content", "navigation", "extra")</script> | |||
<nav> | |||
{% block nav %} | |||
<nav class="navbar navbar-expand-sm bg-dark navbar-dark"> | |||
<ul class="navbar-nav"> | |||
<li class="nav-item"> | |||
<a class="nav-link" href="/polls/home">Home</a> | |||
</li> | |||
<li class="nav-item"> | |||
<a class="nav-link" href="https://www.google.de/?hl=de">google</a> | |||
</li> | |||
<li class="nav-item"> | |||
<a class="nav-link" href="https://www.th-nuernberg.de/fakultaeten/efi/">Efi</a> | |||
</li> | |||
<li class="nav-item"> | |||
<a class="nav-link" href="/polls/about">about</a> | |||
</li> | |||
<li class="nav-item"> | |||
<a class="nav-link" href="/polls/notice">notice</a> | |||
</li> | |||
</ul> | |||
</nav> | |||
{% endblock %} | |||
</nav> | |||
<section id="content"> | |||
{% block content %}{% endblock %} | |||
</section> | |||
<footer>© Danke</footer> | |||
</body> | |||
</html> |
@@ -0,0 +1,8 @@ | |||
{% extends "base.html" %} | |||
{% block content %} | |||
<h2>Seite Infos</h2> | |||
<p> | |||
123 test Eugen | |||
</p> | |||
{% endblock %}ml> |
@@ -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 %} |
@@ -1,9 +1,20 @@ | |||
{% extends 'base.html' %} | |||
{% extends "base.html" %} | |||
{% block content %} | |||
<h2>Seite Infos</h2> | |||
<div class="card w-100"> | |||
<div class="card-body"> | |||
{% for notice in notices %} | |||
<h5 class="card-title">{{ notice.notice_title }}</h5> | |||
<p class="card-text">{{ notice.notice_text |linebreaks }}</p> | |||
<p><a href="{% url 'delete' deleteId=notice.id%}" class="btn btn-danger">Nachricht Löschen</a></p> | |||
{% endfor %} | |||
<p><a href="{% url 'new' %}" class="btn btn-info" role="button">Neue Nachricht</a></p> | |||
</div> | |||
</div> | |||
{% block titel%} | |||
Index-von Test | |||
{% endblock %} | |||
{% block content %} | |||
<h1>123 TEST</h1> | |||
{% endblock %} |
@@ -0,0 +1,20 @@ | |||
{% extends "base.html" %} | |||
{% block content %} | |||
<h2>Seite Infos</h2> | |||
<div class="card w-100"> | |||
<div class="card-body"> | |||
{% for notice in notices %} | |||
<h5 class="card-title">{{ notice.notice_title }}</h5> | |||
<p class="card-text">{{ notice.notice_text |linebreaks }}</p> | |||
<p><a href="{% url 'delete' deleteId=notice.id%}" class="btn btn-danger">Nachricht Löschen</a></p> | |||
{% endfor %} | |||
<p><a href="{% url 'new' %}" class="btn btn-info" role="button">Neue Nachricht</a></p> | |||
</div> | |||
</div> | |||
{% endblock %} |