diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..fe5bff9 --- /dev/null +++ b/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. diff --git a/bazar/__init__.py b/bazar/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bazar/admin.py b/bazar/admin.py new file mode 100644 index 0000000..80862b3 --- /dev/null +++ b/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. diff --git a/bazar/apps.py b/bazar/apps.py new file mode 100644 index 0000000..31878a2 --- /dev/null +++ b/bazar/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class BazarConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'bazar' diff --git a/bazar/forms.py b/bazar/forms.py new file mode 100644 index 0000000..ee4e7d6 --- /dev/null +++ b/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__' \ No newline at end of file diff --git a/bazar/migrations/0001_initial.py b/bazar/migrations/0001_initial.py new file mode 100644 index 0000000..243e42f --- /dev/null +++ b/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)), + ], + ), + ] diff --git a/bazar/migrations/__init__.py b/bazar/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bazar/models.py b/bazar/models.py new file mode 100644 index 0000000..e15699e --- /dev/null +++ b/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. diff --git a/bazar/templates/feedback.html b/bazar/templates/feedback.html new file mode 100644 index 0000000..a4bfad1 --- /dev/null +++ b/bazar/templates/feedback.html @@ -0,0 +1,19 @@ + + + + + + + Document + + + Domů + + + \ No newline at end of file diff --git a/bazar/templates/feedbackinfo.html b/bazar/templates/feedbackinfo.html new file mode 100644 index 0000000..f3b88c3 --- /dev/null +++ b/bazar/templates/feedbackinfo.html @@ -0,0 +1,16 @@ + + + + + + + Document + + +

{{feedbackinfo.nazev}}

+

{{feedbackinfo.zprava}}

+

{{feedbackinfo.datum}}

+

{{feedbackinfo.jmeno}}

+Zpět + + \ No newline at end of file diff --git a/bazar/templates/hlavni.html b/bazar/templates/hlavni.html new file mode 100644 index 0000000..79ad873 --- /dev/null +++ b/bazar/templates/hlavni.html @@ -0,0 +1,18 @@ +{% load crispy_forms_tags %} + + + + + + + Document + + +
+ {% csrf_token %} + {{form | crispy}} + +
+ Nabídka + + \ No newline at end of file diff --git a/bazar/templates/index.html b/bazar/templates/index.html new file mode 100644 index 0000000..4bc116f --- /dev/null +++ b/bazar/templates/index.html @@ -0,0 +1,18 @@ + + + + + + + Hlavní stránka + + +

Staněk

+
+ Formulář +
+ Nabídky + + + + \ No newline at end of file diff --git a/bazar/tests.py b/bazar/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/bazar/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/bazar/views.py b/bazar/views.py new file mode 100644 index 0000000..c16e8a8 --- /dev/null +++ b/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. diff --git a/manage.py b/manage.py new file mode 100644 index 0000000..4831eef --- /dev/null +++ b/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() diff --git a/samostatna_prace/__init__.py b/samostatna_prace/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/samostatna_prace/asgi.py b/samostatna_prace/asgi.py new file mode 100644 index 0000000..f75a349 --- /dev/null +++ b/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() diff --git a/samostatna_prace/settings.py b/samostatna_prace/settings.py new file mode 100644 index 0000000..b0af2fd --- /dev/null +++ b/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' diff --git a/samostatna_prace/urls.py b/samostatna_prace/urls.py new file mode 100644 index 0000000..0251653 --- /dev/null +++ b/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/',feedbackinfoview) +] diff --git a/samostatna_prace/wsgi.py b/samostatna_prace/wsgi.py new file mode 100644 index 0000000..89a156e --- /dev/null +++ b/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()