diff --git a/account/admin.py b/account/admin.py index f14386e..6d53b53 100644 --- a/account/admin.py +++ b/account/admin.py @@ -3,6 +3,4 @@ from django.contrib.auth.admin import UserAdmin from .models import User -# Register your models here. - admin.site.register(User, UserAdmin) diff --git a/account/forms.py b/account/forms.py new file mode 100644 index 0000000..3039979 --- /dev/null +++ b/account/forms.py @@ -0,0 +1,13 @@ +from django.contrib.auth.forms import AuthenticationForm, UserCreationForm + +# from .models import User + + +class LoginForm(AuthenticationForm): + pass + +# +# class RegisterForm(UserCreationForm): +# class Meta(UserCreationForm.Meta): +# model = User +# fields = UserCreationForm.Meta.fields diff --git a/account/migrations/0001_initial.py b/account/migrations/0001_initial.py new file mode 100644 index 0000000..753c2a3 --- /dev/null +++ b/account/migrations/0001_initial.py @@ -0,0 +1,131 @@ +# Generated by Django 5.0 on 2023-12-18 21:42 + +import django.contrib.auth.models +import django.contrib.auth.validators +import django.utils.timezone +from django.db import migrations, models + + +class Migration(migrations.Migration): + initial = True + + dependencies = [ + ("auth", "0012_alter_user_first_name_max_length"), + ] + + operations = [ + migrations.CreateModel( + name="User", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("password", models.CharField(max_length=128, verbose_name="password")), + ( + "last_login", + models.DateTimeField( + blank=True, null=True, verbose_name="last login" + ), + ), + ( + "is_superuser", + models.BooleanField( + default=False, + help_text="Designates that this user has all permissions without explicitly assigning them.", + verbose_name="superuser status", + ), + ), + ( + "username", + models.CharField( + error_messages={ + "unique": "A user with that username already exists." + }, + help_text="Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.", + max_length=150, + unique=True, + validators=[ + django.contrib.auth.validators.UnicodeUsernameValidator() + ], + verbose_name="username", + ), + ), + ( + "first_name", + models.CharField( + blank=True, max_length=150, verbose_name="first name" + ), + ), + ( + "last_name", + models.CharField( + blank=True, max_length=150, verbose_name="last name" + ), + ), + ( + "email", + models.EmailField( + blank=True, max_length=254, verbose_name="email address" + ), + ), + ( + "is_staff", + models.BooleanField( + default=False, + help_text="Designates whether the user can log into this admin site.", + verbose_name="staff status", + ), + ), + ( + "is_active", + models.BooleanField( + default=True, + help_text="Designates whether this user should be treated as active. Unselect this instead of deleting accounts.", + verbose_name="active", + ), + ), + ( + "date_joined", + models.DateTimeField( + default=django.utils.timezone.now, verbose_name="date joined" + ), + ), + ( + "groups", + models.ManyToManyField( + blank=True, + help_text="The groups this user belongs to. A user will get all permissions granted to each of their groups.", + related_name="user_set", + related_query_name="user", + to="auth.group", + verbose_name="groups", + ), + ), + ( + "user_permissions", + models.ManyToManyField( + blank=True, + help_text="Specific permissions for this user.", + related_name="user_set", + related_query_name="user", + to="auth.permission", + verbose_name="user permissions", + ), + ), + ], + options={ + "verbose_name": "user", + "verbose_name_plural": "users", + "abstract": False, + }, + managers=[ + ("objects", django.contrib.auth.models.UserManager()), + ], + ), + ] diff --git a/account/migrations/__init__.py b/account/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/account/templates/account/login.html b/account/templates/account/login.html index 5fc5313..03e1b73 100644 --- a/account/templates/account/login.html +++ b/account/templates/account/login.html @@ -16,5 +16,17 @@ + {#
#} + {# {% csrf_token %}#} + {#
#} + {# #} + {# #} + {#
#} + {#
#} + {# #} + {# #} + {#
#} + {# #} + {#
#} {% endblock %} diff --git a/account/views.py b/account/views.py index 6e1a9c4..43eb29e 100644 --- a/account/views.py +++ b/account/views.py @@ -1,28 +1,30 @@ from django.conf import settings -from django.contrib.auth import authenticate, login, logout +from django.contrib.auth import login, logout from django.contrib.auth.decorators import login_required from django.http import HttpRequest, HttpResponse, JsonResponse from django.shortcuts import redirect, render +from . import forms + 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) + form = forms.LoginForm(req, req.POST) + + if not form.is_valid(): + return render(req, "account/login.html", dict(form=form)) + + user = form.get_user() + 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") + + form = forms.LoginForm(req) + return render(req, "account/login.html", dict(form=form)) + return HttpResponse(status=405) @@ -35,6 +37,7 @@ def auth_logout(req: HttpRequest) -> HttpResponse: 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/templates/facturio/invoice.html b/templates/facturio/invoice.html index 12413f2..aba5456 100644 --- a/templates/facturio/invoice.html +++ b/templates/facturio/invoice.html @@ -1,189 +1,192 @@ - - - + + + Faktura - - -
-

Faktura 2023-0001

-
+ + +
+

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
  • +
  • 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
  • +
  • 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

- +
+

Detaily faktury

+
- + - + - + - + -
# Jednotka Popis položky Cena za MJ Celkem
1 ks Položka 1 50,00 Kč 50,00 Kč
+ -
+

Celkem: 100,00 Kč

-
-
+ + - - + +