diff --git a/README.md b/README.md index d254d88..da69074 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Pokud používáme PyCharm přesuneme se na bod 3. > 'DIRS': [], >>>>>> **'DIRS': [BASE_DIR / "templates"],** 8. vytvoříme si složku **templates** a uvnitř složky templates vytvoříme složku **registration** -9. ve složce registration vytvoříme soubor **login.html** (celá cesta je templates/registration/login.html) +9. ve složce registration vytvoříme soubor **login.html** (celá cesta je *templates/registration/login.html*) ```html diff --git a/accounts/__init__.py b/accounts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/accounts/admin.py b/accounts/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/accounts/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/accounts/apps.py b/accounts/apps.py new file mode 100644 index 0000000..3e3c765 --- /dev/null +++ b/accounts/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class AccountsConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'accounts' diff --git a/accounts/migrations/__init__.py b/accounts/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/accounts/models.py b/accounts/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/accounts/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/accounts/tests.py b/accounts/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/accounts/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/accounts/urls.py b/accounts/urls.py new file mode 100644 index 0000000..77ac54a --- /dev/null +++ b/accounts/urls.py @@ -0,0 +1,7 @@ +from django.urls import path + +from .views import regView + +urlpatterns = [ + path("reg/", regView.as_view(),name="reg") +] \ No newline at end of file diff --git a/accounts/views.py b/accounts/views.py new file mode 100644 index 0000000..515131d --- /dev/null +++ b/accounts/views.py @@ -0,0 +1,9 @@ +from django.shortcuts import render +from django.contrib.auth.forms import UserCreationForm +from django.urls import reverse_lazy +from django.views import generic + +class regView(generic.CreateView): + form_class = UserCreationForm + success_url = reverse_lazy("login") + template_name = "registration/reg.html" diff --git a/loginproject/settings.py b/loginproject/settings.py index 34041d9..37cec8e 100644 --- a/loginproject/settings.py +++ b/loginproject/settings.py @@ -20,7 +20,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'django-insecure-k$*jfxlrl0125n^*-548g5-a!+i@e6l2)#2gfyv^!0xi0-(*96' +SECRET_KEY = 'django-insecure-(__uc&%9#ymprsk0(9c9ykmkvc+%%wvm3*$bvz!oo+2a-3cb6r' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True @@ -37,6 +37,7 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'accounts', ] MIDDLEWARE = [ @@ -125,4 +126,7 @@ STATIC_URL = '/static/' DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' LOGIN_REDIRECT_URL = "/" -LOGOUT_REDIRECT_URL = "/" \ No newline at end of file +LOGOUT_REDIRECT_URL = "/" + +EMAIL_BACKEND = "django.core.mail.backends.filebased.EmailBackend" +EMAIL_FILE_PATH = BASE_DIR / "sent_email" \ No newline at end of file diff --git a/loginproject/urls.py b/loginproject/urls.py index 50edc1c..1908dd1 100644 --- a/loginproject/urls.py +++ b/loginproject/urls.py @@ -19,6 +19,7 @@ from django.views.generic.base import TemplateView urlpatterns = [ path('admin/', admin.site.urls), + path("ucet/", include("accounts.urls")), path("ucet/", include("django.contrib.auth.urls")), path("",TemplateView.as_view(template_name="home.html"), name="home") ] diff --git a/templates/home.html b/templates/home.html index e8bddb6..9c8476d 100644 --- a/templates/home.html +++ b/templates/home.html @@ -5,16 +5,18 @@ Title -

Login systém

+

Login system

+ {% if user.is_authenticated %} -
Ahoj, {{ user.username}}
- Odhlásit +
ahoj, {{ user.username }}
+Logout {% else %} -

Nejsi přihlášený

- Prihlasit +

Nejsi přihlášený

+Login +Registrace +RESET PW {% endif %} - \ No newline at end of file diff --git a/templates/registration/login.html b/templates/registration/login.html index 832b344..94ce222 100644 --- a/templates/registration/login.html +++ b/templates/registration/login.html @@ -5,12 +5,12 @@ Login -

Login

+

Login

{% csrf_token %} - {{form.as_p}} - + {{ form.as_p }} +
- +Home \ No newline at end of file diff --git a/templates/registration/password_reset_form.html b/templates/registration/password_reset_form.html new file mode 100644 index 0000000..b524f65 --- /dev/null +++ b/templates/registration/password_reset_form.html @@ -0,0 +1,15 @@ + + + + + PW reset + + +

PW reset - form

+
+ {% csrf_token %} + {{ form.as_p }} + +
+ + \ No newline at end of file diff --git a/templates/registration/reg.html b/templates/registration/reg.html new file mode 100644 index 0000000..a90ae07 --- /dev/null +++ b/templates/registration/reg.html @@ -0,0 +1,16 @@ + + + + + Registration + + +

Registration

+
+ {% csrf_token %} + {{ form.as_p }} + +
+Home + + \ No newline at end of file