Browse Source

PR7

master
Laura 5 years ago
parent
commit
06bcbd1d4f
11 changed files with 183 additions and 176 deletions
  1. 2
    1
      PR/settings.py
  2. 1
    0
      manage.py
  3. 12
    0
      polls/forms.py
  4. 6
    1
      polls/models.py
  5. 11
    4
      polls/urls.py
  6. 54
    2
      polls/views.py
  7. 41
    162
      templates/base.html
  8. 8
    0
      templates/polls/about.html
  9. 11
    0
      templates/polls/edit.html
  10. 17
    6
      templates/polls/index.html
  11. 20
    0
      templates/polls/notice.html

+ 2
- 1
PR/settings.py View File

# 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',


LANGUAGE_CODE = 'de-de' LANGUAGE_CODE = 'de-de'


TIME_ZONE = 'Europe/Berlin'
TIME_ZONE = 'UTC'


USE_I18N = True USE_I18N = True



+ 1
- 0
manage.py View File



if __name__ == '__main__': if __name__ == '__main__':
main() main()


+ 12
- 0
polls/forms.py View File

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)

+ 6
- 1
polls/models.py View File

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()

+ 11
- 4
polls/urls.py View File

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'),
] ]

+ 54
- 2
polls/views.py View File

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')

+ 41
- 162
templates/base.html View File



<!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> </head>

<body> <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>&copy; Danke</footer>
</body> </body>
</html> </html>

+ 8
- 0
templates/polls/about.html View File

{% extends "base.html" %}
{% block content %}

<h2>Seite Infos</h2>
<p>
123 test Eugen
</p>
{% endblock %}ml>

+ 11
- 0
templates/polls/edit.html View File

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

+ 17
- 6
templates/polls/index.html View File

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

+ 20
- 0
templates/polls/notice.html View File

{% 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…
Cancel
Save