Compare commits

...

No commits in common. "f66c98fa1145dff83f0dfd77134547f3d1fa2678" and "8a364f60e55c0aec31e9ad0feeb67639b78d1e79" have entirely different histories.

5224 changed files with 256 additions and 9472 deletions

90
.gitignore vendored Executable file
View File

@ -0,0 +1,90 @@
### OSX ###
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear on external disk
.Spotlight-V100
.Trashes
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml
# Translations
*.mo
*.pot
# Sphinx documentation
docs/_build/
# PyBuilder
target/
### Django ###
*.log
*.pot
*.pyc
**__pycache__/
local_settings.py
.env
**/db.sqlite3
# PyCharm
**/.idea/

0
.idea/misc.xml generated Normal file → Executable file
View File

0
.idea/modules.xml generated Normal file → Executable file
View File

0
.idea/news.iml generated Normal file → Executable file
View File

0
.idea/vcs.xml generated Normal file → Executable file
View File

5072
.idea/workspace.xml generated

File diff suppressed because it is too large Load Diff

View File

@ -1,20 +0,0 @@
{% extends 'base.html' %}
{% block title %}
News
{% endblock %}
{% block content %}
<h1> Index der Polls-Applikation</h1>
<div class="container">
{% for notice in notices %}
<h3>{{ notice.notice_title }}</h3>
<p>{{ notice.notice_text }}</p>
{% endfor %}
</div>
{% endblock %}

BIN
db.sqlite3 Normal file → Executable file

Binary file not shown.

0
news/__init__.py Normal file → Executable file
View File

Binary file not shown.

Binary file not shown.

7
news/settings.py Normal file → Executable file
View File

@ -20,7 +20,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'fl5b%@nhc2$@uyb)=w_2=#tf@q=%tc63r-4+njboarc*s5&3=e'
SECRET_KEY = 'a7-sm+iebhs_%pupu2emt!he8)x#u_l45vux&kbl6ze4hswfo5'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
@ -37,7 +37,8 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'posts.apps.PostsConfig'
'posts.apps.PostsConfig',
'rest_framework',
]
MIDDLEWARE = [
@ -105,7 +106,7 @@ AUTH_PASSWORD_VALIDATORS = [
# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/
LANGUAGE_CODE = 'en-us'
LANGUAGE_CODE = 'de-de'
TIME_ZONE = 'UTC'

17
news/urls.py Normal file → Executable file
View File

@ -1,18 +1,3 @@
"""news URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.2/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
@ -20,3 +5,5 @@ urlpatterns = [
path('posts/', include('posts.urls')),
path('admin/', admin.site.urls),
]

0
news/wsgi.py Normal file → Executable file
View File

0
posts/__init__.py Normal file → Executable file
View File

0
posts/admin.py Normal file → Executable file
View File

0
posts/apps.py Normal file → Executable file
View File

14
posts/forms.py Normal file
View File

@ -0,0 +1,14 @@
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)

2
posts/migrations/0001_initial.py Normal file → Executable file
View File

@ -1,4 +1,4 @@
# Generated by Django 2.2.7 on 2019-11-19 13:44
# Generated by Django 2.2.7 on 2019-11-19 13:28
from django.db import migrations, models

0
posts/migrations/__init__.py Normal file → Executable file
View File

9
posts/models.py Normal file → Executable file
View File

@ -1,8 +1,9 @@
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()
notice_title = models.CharField(max_length=80)
notice_text = models.CharField(max_length=400)
pub_start = models.DateTimeField()
pub_end = models.DateTimeField()

7
posts/serializers.py Normal file
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')

0
posts/tests.py Normal file → Executable file
View File

6
posts/urls.py Normal file → Executable file
View File

@ -2,5 +2,9 @@ from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index')
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),
]

74
posts/views.py Normal file → Executable file
View File

@ -1,12 +1,74 @@
from django.shortcuts import render
from django.shortcuts import render, redirect
from .models import Notice
from django.utils import timezone
from .forms import NoticeForm
from .serializers import NoticeSerializer
from django.http import JsonResponse, HttpResponse
from rest_framework.parsers import JSONParser
from django.views.decorators.csrf import csrf_exempt
# Create your views here.
def index(request):
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, 'Posts/index.html', context)
notices = notices.filter(pub_start__lte=timezone.now())
notices = notices.filter(pub_end__gte=timezone.now())
context = {"notices": notices}
return render(request, 'posts/index.html', context)
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, 'posts/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')
@csrf_exempt
def notice_list(request):
if request.method == 'GET':
notices = Notice.objects.all()
serializer = NoticeSerializer(notices, many=True)
return JsonResponse(serializer.data, safe=False)
elif request.method == 'POST':
data = JSONParser().parse(request)
serializer = NoticeSerializer(data=data)
if serializer.is_valid():
serializer.save()
return JsonResponse(serializer.data, status=201)
return JsonResponse(serializer.errors, status=400)
@csrf_exempt
def notice_detail(request, id):
try:
notice = Notice.objects.get(id=id)
except Notice.DoesNotExist:
return HttpResponse(status=404)
if request.method == 'GET':
serializer = NoticeSerializer(notice)
return JsonResponse(serializer.data)
elif request.method == 'PUT':
data = JSONParser().parse(request)
serializer = NoticeSerializer(notice, data=data)
if serializer.is_valid():
serializer.save()
return JsonResponse(serializer.data)
return JsonResponse(serializer.errors, status=400)
elif request.method == 'DELETE':
notice.delete()
return HttpResponse(status=204)

8
Templates/base.html → templates/base.html Normal file → Executable file
View File

@ -2,7 +2,9 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{% block title %} Platzhalter {% endblock %} </title>
<title>{% block title %} Platzhalter {% endblock %}</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin="anonymous"></script>
@ -16,7 +18,5 @@
<body>
{% block navigation %} Platzhalter {% endblock %}
{% block content %} Platzhalter {% endblock %}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</body>
</html>
</html>

17
templates/posts/edit.html Normal file
View File

@ -0,0 +1,17 @@
{% extends 'base.html' %}
{% block title %}
News
{% endblock %}
{%block content %}
<div class="container">
<h1>Neue Nachricht</h1>
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
<button type="submit" class="save btn btn-default">Speichern</button>
</form>
</div>
{% endblock %}

26
templates/posts/index.html Executable file
View File

@ -0,0 +1,26 @@
{% extends 'base.html' %}
{% block title %}
News
{% endblock %}
{% block content %}
<div class="container">
{% for notice in notices %}
<h3>{{ notice.notice_title }}</h3>
<p>{{ notice.notice_text }}</p>
<p><a href="{% url 'new' %}" class="btn btn-info" role="button">Neue Nachricht</a></p>
<p><a href= "{% url 'delete' deleteId=notice.id %}" class="btn btn-danger">
Meldung loeschen</a></p>
{% endfor %}
</div>
{% endblock %}

2
venv/bin/activate Normal file → Executable file
View File

@ -37,7 +37,7 @@ deactivate () {
# unset irrelevant variables
deactivate nondestructive
VIRTUAL_ENV="/Users/khaloufam70043/PycharmProjects/Django/venv"
VIRTUAL_ENV="/Users/herrerahuezoul67409/PycharmProjects/Django/venv"
export VIRTUAL_ENV
_OLD_VIRTUAL_PATH="$PATH"

2
venv/bin/activate.csh Normal file → Executable file
View File

@ -8,7 +8,7 @@ alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PA
# Unset irrelevant variables.
deactivate nondestructive
setenv VIRTUAL_ENV "/Users/khaloufam70043/PycharmProjects/Django/venv"
setenv VIRTUAL_ENV "/Users/herrerahuezoul67409/PycharmProjects/Django/venv"
set _OLD_VIRTUAL_PATH="$PATH"
setenv PATH "$VIRTUAL_ENV/bin:$PATH"

2
venv/bin/activate.fish Normal file → Executable file
View File

@ -29,7 +29,7 @@ end
# unset irrelevant variables
deactivate nondestructive
set -gx VIRTUAL_ENV "/Users/khaloufam70043/PycharmProjects/Django/venv"
set -gx VIRTUAL_ENV "/Users/herrerahuezoul67409/PycharmProjects/Django/venv"
set -gx _OLD_VIRTUAL_PATH $PATH
set -gx PATH "$VIRTUAL_ENV/bin" $PATH

View File

@ -1,4 +1,4 @@
#!/Users/khaloufam70043/PycharmProjects/Django/venv/bin/python
#!/Users/herrerahuezoul67409/PycharmProjects/Django/venv/bin/python
# -*- coding: utf-8 -*-
import re

View File

@ -1,4 +1,4 @@
#!/Users/khaloufam70043/PycharmProjects/Django/venv/bin/python
#!/Users/herrerahuezoul67409/PycharmProjects/Django/venv/bin/python
from django.core import management
if __name__ == "__main__":

View File

@ -1,4 +1,4 @@
#!/Users/khaloufam70043/PycharmProjects/Django/venv/bin/python
#!/Users/herrerahuezoul67409/PycharmProjects/Django/venv/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'setuptools==39.1.0','console_scripts','easy_install'
__requires__ = 'setuptools==39.1.0'
import re

View File

@ -1,4 +1,4 @@
#!/Users/khaloufam70043/PycharmProjects/Django/venv/bin/python
#!/Users/herrerahuezoul67409/PycharmProjects/Django/venv/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'setuptools==39.1.0','console_scripts','easy_install-3.7'
__requires__ = 'setuptools==39.1.0'
import re

View File

@ -1,4 +1,4 @@
#!/Users/khaloufam70043/PycharmProjects/Django/venv/bin/python
#!/Users/herrerahuezoul67409/PycharmProjects/Django/venv/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'pip==10.0.1','console_scripts','pip'
__requires__ = 'pip==10.0.1'
import re

View File

@ -1,4 +1,4 @@
#!/Users/khaloufam70043/PycharmProjects/Django/venv/bin/python
#!/Users/herrerahuezoul67409/PycharmProjects/Django/venv/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'pip==10.0.1','console_scripts','pip3'
__requires__ = 'pip==10.0.1'
import re

View File

@ -1,4 +1,4 @@
#!/Users/khaloufam70043/PycharmProjects/Django/venv/bin/python
#!/Users/herrerahuezoul67409/PycharmProjects/Django/venv/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'pip==10.0.1','console_scripts','pip3.7'
__requires__ = 'pip==10.0.1'
import re

View File

@ -1,4 +1,4 @@
#!/Users/khaloufam70043/PycharmProjects/Django/venv/bin/python
#!/Users/herrerahuezoul67409/PycharmProjects/Django/venv/bin/python
# -*- coding: utf-8 -*-
import re

View File

@ -1,27 +0,0 @@
Copyright (c) Django Software Foundation and individual contributors.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of Django nor the names of its contributors may be used
to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -1,84 +0,0 @@
Metadata-Version: 2.1
Name: Django
Version: 2.2.7
Summary: A high-level Python Web framework that encourages rapid development and clean, pragmatic design.
Home-page: https://www.djangoproject.com/
Author: Django Software Foundation
Author-email: foundation@djangoproject.com
License: BSD
Project-URL: Documentation, https://docs.djangoproject.com/
Project-URL: Funding, https://www.djangoproject.com/fundraising/
Project-URL: Source, https://github.com/django/django
Project-URL: Tracker, https://code.djangoproject.com/
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Classifier: Topic :: Internet :: WWW/HTTP :: WSGI
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.5
Requires-Dist: pytz
Requires-Dist: sqlparse
Provides-Extra: argon2
Requires-Dist: argon2-cffi (>=16.1.0) ; extra == 'argon2'
Provides-Extra: bcrypt
Requires-Dist: bcrypt ; extra == 'bcrypt'
Django is a high-level Python Web framework that encourages rapid development
and clean, pragmatic design. Thanks for checking it out.
All documentation is in the "``docs``" directory and online at
https://docs.djangoproject.com/en/stable/. If you're just getting started,
here's how we recommend you read the docs:
* First, read ``docs/intro/install.txt`` for instructions on installing Django.
* Next, work through the tutorials in order (``docs/intro/tutorial01.txt``,
``docs/intro/tutorial02.txt``, etc.).
* If you want to set up an actual deployment server, read
``docs/howto/deployment/index.txt`` for instructions.
* You'll probably want to read through the topical guides (in ``docs/topics``)
next; from there you can jump to the HOWTOs (in ``docs/howto``) for specific
problems, and check out the reference (``docs/ref``) for gory details.
* See ``docs/README`` for instructions on building an HTML version of the docs.
Docs are updated rigorously. If you find any problems in the docs, or think
they should be clarified in any way, please take 30 seconds to fill out a
ticket here: https://code.djangoproject.com/newticket
To get more help:
* Join the ``#django`` channel on irc.freenode.net. Lots of helpful people hang
out there. See https://en.wikipedia.org/wiki/Wikipedia:IRC/Tutorial if you're
new to IRC.
* Join the django-users mailing list, or read the archives, at
https://groups.google.com/group/django-users.
To contribute to Django:
* Check out https://docs.djangoproject.com/en/dev/internals/contributing/ for
information about getting involved.
To run Django's test suite:
* Follow the instructions in the "Unit tests" section of
``docs/internals/contributing/writing-code/unit-tests.txt``, published online at
https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/unit-tests/#running-the-unit-tests

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +0,0 @@
Wheel-Version: 1.0
Generator: bdist_wheel (0.33.1)
Root-Is-Purelib: true
Tag: py3-none-any

View File

@ -1,3 +0,0 @@
[console_scripts]
django-admin = django.core.management:execute_from_command_line

0
venv/lib/python3.7/site-packages/django/__init__.py Normal file → Executable file
View File

0
venv/lib/python3.7/site-packages/django/__main__.py Normal file → Executable file
View File

View File

0
venv/lib/python3.7/site-packages/django/apps/config.py Normal file → Executable file
View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

Some files were not shown because too many files have changed in this diff Show More