PR7
This commit is contained in:
parent
06b093517a
commit
06bcbd1d4f
@ -31,6 +31,7 @@ ALLOWED_HOSTS = []
|
|||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
|
'polls.apps.PollsConfig',
|
||||||
'django.contrib.admin',
|
'django.contrib.admin',
|
||||||
'django.contrib.auth',
|
'django.contrib.auth',
|
||||||
'django.contrib.contenttypes',
|
'django.contrib.contenttypes',
|
||||||
@ -106,7 +107,7 @@ AUTH_PASSWORD_VALIDATORS = [
|
|||||||
|
|
||||||
LANGUAGE_CODE = 'de-de'
|
LANGUAGE_CODE = 'de-de'
|
||||||
|
|
||||||
TIME_ZONE = 'Europe/Berlin'
|
TIME_ZONE = 'UTC'
|
||||||
|
|
||||||
USE_I18N = True
|
USE_I18N = True
|
||||||
|
|
||||||
|
@ -19,3 +19,4 @@ def main():
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
12
polls/forms.py
Normal file
12
polls/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)
|
@ -1,3 +1,8 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
# Create your models here.
|
# 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'))
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from django.conf.urls import url
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
from . import views
|
from polls import views
|
||||||
|
|
||||||
urlpatterns = [
|
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.
|
# 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):
|
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 {
|
<!DOCTYPE html>
|
||||||
padding: 0 10px;
|
<html lang="de">
|
||||||
line-height: 1.8;
|
<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">
|
||||||
ul li {
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
padding-right: 10px;
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
|
||||||
line-height: 1.6;
|
<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>
|
||||||
h3 {
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
|
||||||
padding: 5px 20px;
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
|
||||||
margin: 0;
|
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
|
||||||
}
|
<title>{% block title %}First Django PR{% endblock %}</title>
|
||||||
|
|
||||||
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>
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="container">
|
<nav>
|
||||||
<div id="header">
|
{% block nav %}
|
||||||
<h1>EUGEN WEB</h1>
|
<nav class="navbar navbar-expand-sm bg-dark navbar-dark">
|
||||||
<a href="/download/template/1" target="_blank">download Link</a>
|
<ul class="navbar-nav">
|
||||||
</div>
|
<li class="nav-item">
|
||||||
<div id="wrapper">
|
<a class="nav-link" href="/polls/home">Home</a>
|
||||||
<div id="content">
|
</li>
|
||||||
<p><strong>1. Main Content</strong></p>
|
<li class="nav-item">
|
||||||
<h3>Ueberschrift 1 </h3>
|
<a class="nav-link" href="https://www.google.de/?hl=de">google</a>
|
||||||
<p>
|
</li>
|
||||||
üüüüü
|
<li class="nav-item">
|
||||||
</p>
|
<a class="nav-link" href="https://www.th-nuernberg.de/fakultaeten/efi/">Efi</a>
|
||||||
<p>
|
</li>
|
||||||
TEXT1.1
|
<li class="nav-item">
|
||||||
</p>
|
<a class="nav-link" href="/polls/about">about</a>
|
||||||
<h3>Ueberschrift2</h3>
|
</li>
|
||||||
<p>
|
<li class="nav-item">
|
||||||
TEXT2
|
<a class="nav-link" href="/polls/notice">notice</a>
|
||||||
</p>
|
</li>
|
||||||
</div>
|
</ul>
|
||||||
</div>
|
</nav>
|
||||||
<div id="navigation">
|
{% endblock %}
|
||||||
<p><strong>2. Navigation Menu</strong></p>
|
</nav>
|
||||||
<h3>Seiten</h3>
|
<section id="content">
|
||||||
<ul>
|
{% block content %}{% endblock %}
|
||||||
<li><a href="https://www.google.de/" target="_blank">GOOGLE</a></li>
|
</section>
|
||||||
|
<footer>© Danke</footer>
|
||||||
<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>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
8
templates/polls/about.html
Normal file
8
templates/polls/about.html
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<h2>Seite Infos</h2>
|
||||||
|
<p>
|
||||||
|
123 test Eugen
|
||||||
|
</p>
|
||||||
|
{% endblock %}ml>
|
11
templates/polls/edit.html
Normal file
11
templates/polls/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 %}
|
@ -1,9 +1,20 @@
|
|||||||
{% extends 'base.html' %}
|
{% extends "base.html" %}
|
||||||
|
|
||||||
{% block titel%}
|
|
||||||
Index-von Test
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>123 TEST</h1>
|
|
||||||
|
<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 %}
|
{% endblock %}
|
20
templates/polls/notice.html
Normal file
20
templates/polls/notice.html
Normal file
@ -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 %}
|
Loading…
x
Reference in New Issue
Block a user