feat: add signup form
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
# Django project
|
||||
/media/
|
||||
/static/
|
||||
*.sqlite3
|
||||
|
||||
# Python and others
|
||||
__pycache__
|
||||
*.pyc
|
||||
.DS_Store
|
||||
*.swp
|
||||
/venv/
|
||||
/tmp/
|
||||
/.vagrant/
|
||||
/Vagrantfile.local
|
||||
node_modules/
|
||||
/npm-debug.log
|
||||
/.idea/
|
||||
.vscode
|
||||
coverage
|
||||
.python-version
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
env/
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
13
kursy/forms.py
Normal file
13
kursy/forms.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from django import forms
|
||||
|
||||
|
||||
class SignUpForm(forms.Form):
|
||||
first_name = forms.CharField(max_length=60, required=True, label="First Name")
|
||||
last_name = forms.CharField(max_length=60, required=True, label="Last Name")
|
||||
|
||||
def signup(self, request, user):
|
||||
user.first_name = self.cleaned_data["first_name"]
|
||||
user.last_name = self.cleaned_data["last_name"]
|
||||
user.save()
|
||||
|
||||
return user
|
||||
58
kursy/locale/en/LC_MESSAGES/django.po
Normal file
58
kursy/locale/en/LC_MESSAGES/django.po
Normal file
@@ -0,0 +1,58 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2026-03-09 13:07+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
#: kursy/templates/allauth/layouts/base.html:19
|
||||
msgid "Messages:"
|
||||
msgstr ""
|
||||
|
||||
#: kursy/templates/allauth/layouts/base.html:33
|
||||
msgid "Change Email"
|
||||
msgstr ""
|
||||
|
||||
#: kursy/templates/allauth/layouts/base.html:39
|
||||
msgid "Change Password"
|
||||
msgstr ""
|
||||
|
||||
#: kursy/templates/allauth/layouts/base.html:45
|
||||
msgid "Account Connections"
|
||||
msgstr ""
|
||||
|
||||
#: kursy/templates/allauth/layouts/base.html:51
|
||||
msgid "Two-Factor Authentication"
|
||||
msgstr ""
|
||||
|
||||
#: kursy/templates/allauth/layouts/base.html:57
|
||||
msgid "Sessions"
|
||||
msgstr ""
|
||||
|
||||
#: kursy/templates/allauth/layouts/base.html:63
|
||||
msgid "Sign Out"
|
||||
msgstr ""
|
||||
|
||||
#: kursy/templates/allauth/layouts/base.html:70
|
||||
msgid "Sign In"
|
||||
msgstr ""
|
||||
|
||||
#: kursy/templates/allauth/layouts/base.html:76
|
||||
msgid "Sign Up"
|
||||
msgstr ""
|
||||
|
||||
#: kursy/templates/header.html:6
|
||||
msgid "Home"
|
||||
msgstr ""
|
||||
@@ -49,6 +49,8 @@ INSTALLED_APPS = [
|
||||
"allauth",
|
||||
"allauth.account",
|
||||
"allauth.socialaccount",
|
||||
"tailwind",
|
||||
"theme",
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
@@ -61,6 +63,7 @@ MIDDLEWARE = [
|
||||
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
||||
"wagtail.contrib.redirects.middleware.RedirectMiddleware",
|
||||
"allauth.account.middleware.AccountMiddleware",
|
||||
"django.middleware.locale.LocaleMiddleware",
|
||||
]
|
||||
|
||||
ROOT_URLCONF = "kursy.urls"
|
||||
@@ -90,6 +93,18 @@ AUTHENTICATION_BACKENDS = [
|
||||
"allauth.account.auth_backends.AuthenticationBackend",
|
||||
]
|
||||
|
||||
ACCOUNT_SIGNUP_FIELDS = [
|
||||
"first_name*",
|
||||
"last_name*",
|
||||
"email*",
|
||||
"password1*",
|
||||
"password2*",
|
||||
]
|
||||
ACCOUNT_SIGNUP_FORM_CLASS = "kursy.forms.SignUpForm"
|
||||
|
||||
ACCOUNT_LOGIN_METHODS = ["email", "username"]
|
||||
|
||||
|
||||
WSGI_APPLICATION = "kursy.wsgi.application"
|
||||
|
||||
|
||||
@@ -126,7 +141,7 @@ AUTH_PASSWORD_VALIDATORS = [
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/6.0/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = "en-us"
|
||||
LANGUAGE_CODE = "pl"
|
||||
|
||||
TIME_ZONE = "UTC"
|
||||
|
||||
@@ -134,6 +149,11 @@ USE_I18N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
LANGUAGES = [
|
||||
("pl", "Polski"),
|
||||
("en", "English"),
|
||||
]
|
||||
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/6.0/howto/static-files/
|
||||
@@ -201,3 +221,5 @@ WAGTAILDOCS_EXTENSIONS = [
|
||||
"xlsx",
|
||||
"zip",
|
||||
]
|
||||
|
||||
TAILWIND_APP_NAME = "theme"
|
||||
|
||||
@@ -4,7 +4,7 @@ from .base import *
|
||||
DEBUG = True
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = "django-insecure-0(k&l$e$c)(9g4h$6@7t8&p$)hkv4ev_8oyqwjqtqddykrbx^j"
|
||||
SECRET_KEY = "django-insecure-ik$z5b@u(6*35)7_#xejlfezm#kg9+2fxotuz-zwlk^bv7^#32"
|
||||
|
||||
# SECURITY WARNING: define the correct hosts in production!
|
||||
ALLOWED_HOSTS = ["*"]
|
||||
|
||||
11
kursy/templates/429.html
Normal file
11
kursy/templates/429.html
Normal file
@@ -0,0 +1,11 @@
|
||||
{% extends "allauth/layouts/entrance.html" %}
|
||||
{% load allauth %}
|
||||
{% block head_title %}
|
||||
Too Many Requests
|
||||
{% endblock head_title %}
|
||||
{% block content %}
|
||||
{% element h1 %}
|
||||
Too Many Requests
|
||||
{% endelement %}
|
||||
<p>You are sending too many requests.</p>
|
||||
{% endblock content %}
|
||||
@@ -1,4 +1,4 @@
|
||||
{% load static wagtailcore_tags wagtailuserbar %}
|
||||
{% load static i18n wagtailcore_tags wagtailuserbar tailwind_tags %}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
{# Global stylesheets #}
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'css/kursy.css' %}">
|
||||
{% tailwind_css %}
|
||||
|
||||
{% block extra_css %}
|
||||
{# Override this in templates to add extra stylesheets #}
|
||||
@@ -32,6 +33,7 @@
|
||||
</head>
|
||||
|
||||
<body class="{% block body_class %}{% endblock %}">
|
||||
{% include "header.html" %}
|
||||
{% wagtailuserbar %}
|
||||
|
||||
{% block content %}{% endblock %}
|
||||
|
||||
15
kursy/templates/header.html
Normal file
15
kursy/templates/header.html
Normal file
@@ -0,0 +1,15 @@
|
||||
{% load i18n %}
|
||||
<header class="bg-blue-900 text-white shadow-md">
|
||||
<div class="container mx-auto flex items-center justify-between py-4 px-6">
|
||||
<a class="text-xl font-bold" href="/">Kursy</a>
|
||||
<nav class="space-x-4">
|
||||
<a href="#" class="hover:underline">{% trans "Home" %}</a>
|
||||
{% if user.is_authenticated %}
|
||||
<a href="{% url 'account_logout' %}" class="hover:underline">{% trans "Logout" %}</a>
|
||||
{% else %}
|
||||
<a href="{% url 'account_login' %}" class="hover:underline">{% trans "Login" %}</a>
|
||||
<a href="{% url 'account_signup' %}" class="hover:underline">{% trans "Sign Up" %}</a>
|
||||
{% endif %}
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
8
kursy/templates/profile.html
Normal file
8
kursy/templates/profile.html
Normal file
@@ -0,0 +1,8 @@
|
||||
{% extends "allauth/layouts/manage.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container mx-auto px-4 py-8">
|
||||
<h1 class="text-3xl font-bold mb-6">{% trans "Witaj, " %}{{ user.first_name }}!</h1>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -8,12 +8,16 @@ from wagtail.documents import urls as wagtaildocs_urls
|
||||
|
||||
from search import views as search_views
|
||||
|
||||
from .views import profile, signup
|
||||
|
||||
urlpatterns = [
|
||||
path("django-admin/", admin.site.urls),
|
||||
path("admin/", include(wagtailadmin_urls)),
|
||||
path("documents/", include(wagtaildocs_urls)),
|
||||
path("search/", search_views.search, name="search"),
|
||||
path("accounts/", include("allauth.urls")),
|
||||
path("accounts/profile/", profile, name="profile"),
|
||||
path("accounts/signup/", signup, name="signup"),
|
||||
]
|
||||
|
||||
|
||||
|
||||
21
kursy/views.py
Normal file
21
kursy/views.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.shortcuts import render, redirect
|
||||
|
||||
from .forms import SignUpForm
|
||||
|
||||
|
||||
def signup(request):
|
||||
if request.method == "POST":
|
||||
form = SignUpForm(request.POST)
|
||||
if form.is_valid():
|
||||
user = form.signup(request, form.save())
|
||||
return redirect("profile")
|
||||
else:
|
||||
form = SignUpForm()
|
||||
|
||||
return render(request, "signup.html", {"form": form})
|
||||
|
||||
|
||||
@login_required
|
||||
def profile(request):
|
||||
return render(request, "profile.html", {"user": request.user})
|
||||
Reference in New Issue
Block a user