Jakub Staněk 3 years ago
parent
commit
9106239c72
  1. 7
      LICENSE
  2. 0
      bazar/__init__.py
  3. 8
      bazar/admin.py
  4. 6
      bazar/apps.py
  5. 7
      bazar/forms.py
  6. 24
      bazar/migrations/0001_initial.py
  7. 0
      bazar/migrations/__init__.py
  8. 11
      bazar/models.py
  9. 19
      bazar/templates/feedback.html
  10. 16
      bazar/templates/feedbackinfo.html
  11. 18
      bazar/templates/hlavni.html
  12. 18
      bazar/templates/index.html
  13. 3
      bazar/tests.py
  14. 28
      bazar/views.py
  15. 22
      manage.py
  16. 0
      samostatna_prace/__init__.py
  17. 16
      samostatna_prace/asgi.py
  18. 125
      samostatna_prace/settings.py
  19. 27
      samostatna_prace/urls.py
  20. 16
      samostatna_prace/wsgi.py

7
LICENSE

@ -0,0 +1,7 @@
This Program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.
This Program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this Program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
In addition, as a special exception, Red Hat, Inc. gives You the additional right to link the code of this Program with code not covered under the GNU General Public License ("Non-GPL Code") and to distribute linked combinations including the two, subject to the limitations in this paragraph. Non-GPL Code permitted under this exception must only link to the code of this Program through those well defined interfaces identified in the file named EXCEPTION found in the source code files (the "Approved Interfaces"). The files of Non-GPL Code may instantiate templates or use macros or inline functions from the Approved Interfaces without causing the resulting work to be covered by the GNU General Public License. Only Red Hat, Inc. may make changes or additions to the list of Approved Interfaces. You must obey the GNU General Public License in all respects for all of the Program code and other code used in conjunction with the Program except the Non-GPL Code covered by this exception. If you modify this file, you may extend this exception to your version of the file, but you are not obligated to do so. If you do not wish to provide this exception without modification, you must delete this exception statement from your version and license this file solely under the GPL without exception.

0
bazar/__init__.py

8
bazar/admin.py

@ -0,0 +1,8 @@
from django.contrib import admin
from django.contrib import admin
from .models import feedbackModel
admin.site.register(feedbackModel)
# Register your models here.

6
bazar/apps.py

@ -0,0 +1,6 @@
from django.apps import AppConfig
class BazarConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'bazar'

7
bazar/forms.py

@ -0,0 +1,7 @@
from django.forms import ModelForm
from .models import feedbackModel
class feedbackForm(ModelForm):
class Meta:
model = feedbackModel
fields = '__all__'

24
bazar/migrations/0001_initial.py

@ -0,0 +1,24 @@
# Generated by Django 4.0.3 on 2022-03-10 17:00
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='feedbackModel',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('nazev', models.CharField(max_length=100)),
('zprava', models.TextField(max_length=10000)),
('jmeno', models.TextField(default=str, max_length=100)),
('datum', models.TextField(default=str, max_length=100)),
],
),
]

0
bazar/migrations/__init__.py

11
bazar/models.py

@ -0,0 +1,11 @@
from django.db import models
class feedbackModel(models.Model):
nazev = models.CharField(max_length=100)
zprava = models.TextField(max_length=10000)
jmeno = models.TextField(max_length=100, default=str)
datum = models.TextField(max_length=100, default=str)
def __str__(self):
return self.nazev + " " + self.zprava + " | " + self.jmeno + " | " + self.datum
# Create your models here.

19
bazar/templates/feedback.html

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<a href="/">Domů</a>
<ul>
{% for i in feedback %}
<li>
<a href="/feedbackinfo/{{i.id}}">{{ i.nazev }}</a>
</li>
{% endfor %}
</ul>
</body>
</html>

16
bazar/templates/feedbackinfo.html

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>{{feedbackinfo.nazev}}</h1>
<p> {{feedbackinfo.zprava}}</p>
<p> {{feedbackinfo.datum}}</p>
<p> {{feedbackinfo.jmeno}}</p>
<a href="/feedback/">Zpět</a>
</body>
</html>

18
bazar/templates/hlavni.html

@ -0,0 +1,18 @@
{% load crispy_forms_tags %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<form action="" method="post">
{% csrf_token %}
{{form | crispy}}
<input type="submit">
</form>
<a href="/feedback/">Nabídka</a>
</body>
</html>

18
bazar/templates/index.html

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hlavní stránka</title>
</head>
<body>
<h1>Staněk</h1>
<br>
<a href="hlavni/">Formulář</a>
<br>
<a href="feedback">Nabídky</a>
</body>
</html>

3
bazar/tests.py

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

28
bazar/views.py

@ -0,0 +1,28 @@
from django.shortcuts import render
from .forms import feedbackForm
from .models import feedbackModel
def indexView(request):
return render(request,"index.html")
def feedbackview(request):
feedback = feedbackModel.objects.all()
return render(request, "feedback.html",{'feedback':feedback})
def feedbackinfoview(request, i):
feedbackinfo = feedbackModel.objects.get(id=i)
return render(request, "feedbackinfo.html",{'feedbackinfo':feedbackinfo})
def hlavniView(request):
form = feedbackForm
if request.method == "POST":
form = feedbackForm(request.POST)
if form.is_valid():
form.save()
context = {'form':form}
return render(request,"hlavni.html", context)
# Create your views here.

22
manage.py

@ -0,0 +1,22 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'samostatna_prace.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()

0
samostatna_prace/__init__.py

16
samostatna_prace/asgi.py

@ -0,0 +1,16 @@
"""
ASGI config for samostatna_prace project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'samostatna_prace.settings')
application = get_asgi_application()

125
samostatna_prace/settings.py

@ -0,0 +1,125 @@
"""
Django settings for samostatna_prace project.
Generated by 'django-admin startproject' using Django 4.0.3.
For more information on this file, see
https://docs.djangoproject.com/en/4.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.0/ref/settings/
"""
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-r!88k!fgrvlitf5iy*6jekb=f-q0e(nyw064ng^t3k9)euiki4'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'bazar',
'crispy_forms',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'samostatna_prace.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'samostatna_prace.wsgi.application'
# Database
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/4.0/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/
STATIC_URL = 'static/'
# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

27
samostatna_prace/urls.py

@ -0,0 +1,27 @@
"""samostatna_prace URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.0/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 operator import index
from django.contrib import admin
from django.urls import path
from bazar.views import indexView, hlavniView, feedbackview, feedbackinfoview
urlpatterns = [
path('admin/', admin.site.urls),
path('',indexView),
path('hlavni/',hlavniView),
path('feedback/',feedbackview),
path('feedbackinfo/<int:i>',feedbackinfoview)
]

16
samostatna_prace/wsgi.py

@ -0,0 +1,16 @@
"""
WSGI config for samostatna_prace project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.0/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'samostatna_prace.settings')
application = get_wsgi_application()
Loading…
Cancel
Save