commit 3901201460ed3366e0413d7ccccf274553888d18 Author: Jakub Kropáček Date: Mon Dec 18 21:00:37 2023 +0100 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f11b75 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ diff --git a/account/__init__.py b/account/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/account/__pycache__/__init__.cpython-312.pyc b/account/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..4dc5918 Binary files /dev/null and b/account/__pycache__/__init__.cpython-312.pyc differ diff --git a/account/__pycache__/admin.cpython-312.pyc b/account/__pycache__/admin.cpython-312.pyc new file mode 100644 index 0000000..c572795 Binary files /dev/null and b/account/__pycache__/admin.cpython-312.pyc differ diff --git a/account/__pycache__/apps.cpython-312.pyc b/account/__pycache__/apps.cpython-312.pyc new file mode 100644 index 0000000..9afe147 Binary files /dev/null and b/account/__pycache__/apps.cpython-312.pyc differ diff --git a/account/__pycache__/models.cpython-312.pyc b/account/__pycache__/models.cpython-312.pyc new file mode 100644 index 0000000..0140df8 Binary files /dev/null and b/account/__pycache__/models.cpython-312.pyc differ diff --git a/account/__pycache__/urls.cpython-312.pyc b/account/__pycache__/urls.cpython-312.pyc new file mode 100644 index 0000000..9152a61 Binary files /dev/null and b/account/__pycache__/urls.cpython-312.pyc differ diff --git a/account/__pycache__/views.cpython-312.pyc b/account/__pycache__/views.cpython-312.pyc new file mode 100644 index 0000000..d10ca6a Binary files /dev/null and b/account/__pycache__/views.cpython-312.pyc differ diff --git a/account/admin.py b/account/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/account/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/account/apps.py b/account/apps.py new file mode 100644 index 0000000..2c684a9 --- /dev/null +++ b/account/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class AccountConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "account" diff --git a/account/migrations/__init__.py b/account/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/account/migrations/__pycache__/__init__.cpython-312.pyc b/account/migrations/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..415a57d Binary files /dev/null and b/account/migrations/__pycache__/__init__.cpython-312.pyc differ diff --git a/account/models.py b/account/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/account/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/account/templates/account/login.html b/account/templates/account/login.html new file mode 100644 index 0000000..5fc5313 --- /dev/null +++ b/account/templates/account/login.html @@ -0,0 +1,20 @@ +{% extends "facturio/base.html" %} + +{% block title %}Login{% endblock %} + +{% block content %} +
+
+ {% csrf_token %} +
+ + +
+
+ + +
+ +
+
+{% endblock %} diff --git a/account/templates/account/me.html b/account/templates/account/me.html new file mode 100644 index 0000000..636e701 --- /dev/null +++ b/account/templates/account/me.html @@ -0,0 +1,15 @@ +{% extends "facturio/base.html" %} + +{% block title %}About Me{% endblock %} + +{% block content %} +
+

About Me

+
+
+
Welcome, {{ request.user.username }}!
+

Email: {{ request.user.email }}

+
+
+
+{% endblock %} diff --git a/account/templates/account/register.html b/account/templates/account/register.html new file mode 100644 index 0000000..cd31cfa --- /dev/null +++ b/account/templates/account/register.html @@ -0,0 +1,5 @@ +{% extends "facturio/base.html" %} +{% block title %}Register{% endblock %} +{% block content %} +

TODO: register

+{% endblock %} \ No newline at end of file diff --git a/account/tests.py b/account/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/account/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/account/urls.py b/account/urls.py new file mode 100644 index 0000000..2184e52 --- /dev/null +++ b/account/urls.py @@ -0,0 +1,12 @@ +from django.http import HttpResponse +from django.urls import path, re_path + +from . import views + +urlpatterns = [ + path("", views.me, name="me"), + path("me/", views.me, name="me_exp"), + path("login/", views.auth_login, name="login"), + path("logout/", views.auth_logout, name="logout"), + path("register/", views.auth_register, name="register"), +] diff --git a/account/views.py b/account/views.py new file mode 100644 index 0000000..6e1a9c4 --- /dev/null +++ b/account/views.py @@ -0,0 +1,40 @@ +from django.conf import settings +from django.contrib.auth import authenticate, login, logout +from django.contrib.auth.decorators import login_required +from django.http import HttpRequest, HttpResponse, JsonResponse +from django.shortcuts import redirect, render + + +def auth_login(req: HttpRequest) -> HttpResponse: + if req.method == "POST": + username = req.POST["username"] + password = req.POST["password"] + user = authenticate(req, username=username, password=password) + if not user: + return JsonResponse( + { + "message": "Invalid cretendials" + }, + status=401 + ) + else: + login(req, user) + redirect_url = getattr(req.GET, "next", settings.LOGIN_REDIRECT_URL) + return redirect(redirect_url) + elif req.method == "GET": + return render(req, "account/login.html") + return HttpResponse(status=405) + + +@login_required +def auth_logout(req: HttpRequest) -> HttpResponse: + logout(req) + return redirect(settings.LOGOUT_REDIRECT_URL) + + +def auth_register(req: HttpRequest) -> HttpResponse: + return render(req, "account/register.html") + +@login_required +def me(req: HttpRequest) -> HttpResponse: + return render(req, "account/me.html") diff --git a/db.sqlite3 b/db.sqlite3 new file mode 100644 index 0000000..ce718fe Binary files /dev/null and b/db.sqlite3 differ diff --git a/facturio/__init__.py b/facturio/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/facturio/__pycache__/__init__.cpython-312.pyc b/facturio/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..a6b7f86 Binary files /dev/null and b/facturio/__pycache__/__init__.cpython-312.pyc differ diff --git a/facturio/__pycache__/settings.cpython-312.pyc b/facturio/__pycache__/settings.cpython-312.pyc new file mode 100644 index 0000000..3e2e0ce Binary files /dev/null and b/facturio/__pycache__/settings.cpython-312.pyc differ diff --git a/facturio/__pycache__/urls.cpython-312.pyc b/facturio/__pycache__/urls.cpython-312.pyc new file mode 100644 index 0000000..f2edb07 Binary files /dev/null and b/facturio/__pycache__/urls.cpython-312.pyc differ diff --git a/facturio/__pycache__/wsgi.cpython-312.pyc b/facturio/__pycache__/wsgi.cpython-312.pyc new file mode 100644 index 0000000..ee5289e Binary files /dev/null and b/facturio/__pycache__/wsgi.cpython-312.pyc differ diff --git a/facturio/asgi.py b/facturio/asgi.py new file mode 100644 index 0000000..e395568 --- /dev/null +++ b/facturio/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for facturio 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/5.0/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "facturio.settings") + +application = get_asgi_application() diff --git a/facturio/settings.py b/facturio/settings.py new file mode 100644 index 0000000..b63d289 --- /dev/null +++ b/facturio/settings.py @@ -0,0 +1,128 @@ +""" +Django settings for facturio project. + +Generated by 'django-admin startproject' using Django 5.0. + +For more information on this file, see +https://docs.djangoproject.com/en/5.0/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/5.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/5.0/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = "django-insecure-+l+g3)q1zz2bz7=mz4ys6lhu5uj+=ucj34flm^clo4vb3(wmdp" + +# 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", + "account.apps.AccountConfig" +] + +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 = "facturio.urls" + +TEMPLATES = [ + { + "BACKEND": "django.template.backends.django.DjangoTemplates", + "DIRS": [BASE_DIR / "templates"], + "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", + ], + }, + }, +] + +STATICFILES_DIRS = [ + BASE_DIR / "static", +] + +WSGI_APPLICATION = "facturio.wsgi.application" + +# Database +# https://docs.djangoproject.com/en/5.0/ref/settings/#databases + +DATABASES = { + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": BASE_DIR / "db.sqlite3", + } +} + +# Password validation +# https://docs.djangoproject.com/en/5.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/5.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/5.0/howto/static-files/ + +STATIC_URL = "static/" + +# Default primary key field type +# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" + +# Login configuration +LOGIN_BASE_URL = "/account" +LOGIN_URL = f"{LOGIN_BASE_URL}/login" +LOGOUT_REDIRECT_URL = f"/" +LOGIN_REDIRECT_URL = f"{LOGIN_BASE_URL}/me" diff --git a/facturio/urls.py b/facturio/urls.py new file mode 100644 index 0000000..5f34c30 --- /dev/null +++ b/facturio/urls.py @@ -0,0 +1,34 @@ +""" +URL configuration for facturio project. + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/5.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 django.contrib import admin +# TODO: remove +from django.http import HttpRequest, HttpResponse +from django.shortcuts import render +from django.urls import path, include + + +# TODO: remove +def demo(req: HttpRequest) -> HttpResponse: + return render(req, "facturio/invoice.html") + + +urlpatterns = [ + path("", demo, name="main-page"), + path("account/", include("account.urls")), + path("admin/", admin.site.urls), +] + diff --git a/facturio/wsgi.py b/facturio/wsgi.py new file mode 100644 index 0000000..57369aa --- /dev/null +++ b/facturio/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for facturio 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/5.0/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "facturio.settings") + +application = get_wsgi_application() diff --git a/manage.py b/manage.py new file mode 100755 index 0000000..3e35f11 --- /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", "facturio.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/poetry.lock b/poetry.lock new file mode 100644 index 0000000..1b9573a --- /dev/null +++ b/poetry.lock @@ -0,0 +1,67 @@ +# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. + +[[package]] +name = "asgiref" +version = "3.7.2" +description = "ASGI specs, helper code, and adapters" +optional = false +python-versions = ">=3.7" +files = [ + {file = "asgiref-3.7.2-py3-none-any.whl", hash = "sha256:89b2ef2247e3b562a16eef663bc0e2e703ec6468e2fa8a5cd61cd449786d4f6e"}, + {file = "asgiref-3.7.2.tar.gz", hash = "sha256:9e0ce3aa93a819ba5b45120216b23878cf6e8525eb3848653452b4192b92afed"}, +] + +[package.extras] +tests = ["mypy (>=0.800)", "pytest", "pytest-asyncio"] + +[[package]] +name = "django" +version = "5.0" +description = "A high-level Python web framework that encourages rapid development and clean, pragmatic design." +optional = false +python-versions = ">=3.10" +files = [ + {file = "Django-5.0-py3-none-any.whl", hash = "sha256:3a9fd52b8dbeae335ddf4a9dfa6c6a0853a1122f1fb071a8d5eca979f73a05c8"}, + {file = "Django-5.0.tar.gz", hash = "sha256:7d29e14dfbc19cb6a95a4bd669edbde11f5d4c6a71fdaa42c2d40b6846e807f7"}, +] + +[package.dependencies] +asgiref = ">=3.7.0" +sqlparse = ">=0.3.1" +tzdata = {version = "*", markers = "sys_platform == \"win32\""} + +[package.extras] +argon2 = ["argon2-cffi (>=19.1.0)"] +bcrypt = ["bcrypt"] + +[[package]] +name = "sqlparse" +version = "0.4.4" +description = "A non-validating SQL parser." +optional = false +python-versions = ">=3.5" +files = [ + {file = "sqlparse-0.4.4-py3-none-any.whl", hash = "sha256:5430a4fe2ac7d0f93e66f1efc6e1338a41884b7ddf2a350cedd20ccc4d9d28f3"}, + {file = "sqlparse-0.4.4.tar.gz", hash = "sha256:d446183e84b8349fa3061f0fe7f06ca94ba65b426946ffebe6e3e8295332420c"}, +] + +[package.extras] +dev = ["build", "flake8"] +doc = ["sphinx"] +test = ["pytest", "pytest-cov"] + +[[package]] +name = "tzdata" +version = "2023.3" +description = "Provider of IANA time zone data" +optional = false +python-versions = ">=2" +files = [ + {file = "tzdata-2023.3-py2.py3-none-any.whl", hash = "sha256:7e65763eef3120314099b6939b5546db7adce1e7d6f2e179e3df563c70511eda"}, + {file = "tzdata-2023.3.tar.gz", hash = "sha256:11ef1e08e54acb0d4f95bdb1be05da659673de4acbd21bf9c69e94cc5e907a3a"}, +] + +[metadata] +lock-version = "2.0" +python-versions = "^3.12" +content-hash = "1c6ab57fc89858a0923620d3307e9173662bad9b58d9dde4f567267506e03587" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..9c01d30 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,16 @@ +[tool.poetry] +name = "facturio" +version = "0.1.0" +description = "" +authors = ["Jakub Kropáček "] +license = "MIT" +readme = "README.md" + +[tool.poetry.dependencies] +python = "^3.12" +django = "^5.0" + + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" diff --git a/templates/facturio/base.html b/templates/facturio/base.html new file mode 100644 index 0000000..9615bd7 --- /dev/null +++ b/templates/facturio/base.html @@ -0,0 +1,53 @@ + + + + + Facturio - {% block title %}App{% endblock %} + + + + + +
+ {% block content %} {% endblock %} +
+ + + \ No newline at end of file diff --git a/templates/facturio/invoice.html b/templates/facturio/invoice.html new file mode 100644 index 0000000..12413f2 --- /dev/null +++ b/templates/facturio/invoice.html @@ -0,0 +1,189 @@ + + + + + + + Faktura + + + +
+

Faktura 2023-0001

+
+ +
+
+

Dodavatel

+
    +
  • Název Vaší společnosti nebo jméno
  • +
  • Vaše adresa
  • +
  • Vaše město, PSČ
  • +

    +
  • IČO: 123456789
  • +
  • DIČ: CZ123456789 jestli jste plátce DPH
  • +

    +
  • Bankovní účet: 123-456789
  • +
+
+ +
+

Odběratel

+
    +
  • Název společnosti nebo jméno zákazníka
  • +
  • Adresa zákazníka
  • +
  • Město zákazníka, PSČ
  • +

    +
  • IČO zákazníka: 987654321
  • +
  • DIČ zákazníka: CZ987654321 jestli je plátce DPH
  • +

    +
  • Datum vystavení: 16. prosince 2023
  • +
  • Datum splatnosti: 16. prosince 2023
  • +
+
+
+ +
+

Detaily faktury

+ + + + + + + + + + + + + + + + + + + +
#JednotkaPopis položkyCena za MJCelkem
1ksPoložka 150,00 Kč50,00 Kč
+ +
+

Celkem: 100,00 Kč

+
+
+ + + +