Besser aussehendes Register-Form und answer.html richtig eingebunden

This commit is contained in:
ben8
2025-02-17 18:10:22 +01:00
parent 680bd2c823
commit 3adaba94b8
11 changed files with 92 additions and 25 deletions

View File

@@ -1,8 +1,22 @@
from django import forms
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from django import forms
class RegisterForm(UserCreationForm):
class Meta:
model=User
fields = ['username','password1','password2']
fields = ['username','password1','password2']
username = forms.CharField(
widget=forms.TextInput(attrs={'placeholder': 'BENUTZERNAME'})
)
password1 = forms.CharField(
widget=forms.PasswordInput(attrs={'placeholder': 'PASSWORT'})
)
password2 = forms.CharField(
widget=forms.PasswordInput(attrs={'placeholder': 'PASSWORT WIEDERHOLEN'})
)

View File

@@ -6,6 +6,17 @@
<div class="p-4 m-2 border-blue-600 border-2 rounded-xl shadow-md">
<h2 class="text-2xl text-center p-4 font-black">Anmeldung</h2>
<form class="space-y-4" method="post">
{% if form.errors %}
<div class="text-red-600 font-black overflow-x-auto break-words text-center">
<ul>
{% for field, errors in form.errors.items %}
{% for error in errors %}
<li>{{ error }}</li>
{% endfor %}
{% endfor %}
</ul>
</div>
{% endif %}
{% csrf_token %}
<div class="">
<input class="p-3 rounded-full bg-gray-200 focus:scale-105 transition duration-200 font-black" type="text" name="username" id="username" required placeholder="BENUTZERNAME">

View File

@@ -1,14 +1,52 @@
{% extends 'accounts/base.html' %}
{% block title %}Registrierung{% endblock %}
{% block content %}
<header>
<h2>Registrierung</h2>
</header>
<div class="login-container">
<form method="POST" novalidate>
{% csrf_token %}
<h2>Sign Up</h2>
{{ form.as_p }}
<input type="submit" value="Register" />
</form>
{% endblock %}
<div class="grid place-content-center h-120">
<div class=" p-4 m-2 border-blue-600 border-2 rounded-xl shadow-md">
<h2 class="text-2xl text-center p-4 font-black">Registrieren</h2>
<form class=" space-y-4" method="post">
{% if form.errors %}
<div class="text-red-600 font-black overflow-hidden">
<ul>
{% for field, errors in form.errors.items %}
{% for error in errors %}
<li>{{ error }}</li>
{% endfor %}
{% endfor %}
</ul>
</div>
{% endif %}
{% csrf_token %}
<div class="register">
{{ form.username }}
</div>
<div class="register">
{{ form.password1 }}
</div>
<div class="register">
{{ form.password2 }}
</div>
<button class="w-full p-3 rounded-full bg-blue-600 text-white font-black hover:scale-105 transition duration-200" type="submit" class="login-button">Registrieren</button>
</form>
<button class="text-center text-sm w-full mt-2 font-light text-blue-600"><a href="{% url 'accounts:login' %}" class="register_link">Bereits ein Konto?</a></button>
</div>
</div>
{% endblock %}

View File

@@ -2,20 +2,21 @@
{% load static %}
{% block title %}Antwort{% endblock %}
{% block content %}
<link rel="stylesheet" href="{% static 'homepage/t-style.css' %}">
{% if <Bedingung> %} <!-- TODO Bedingung festlegen: Quiztyp unterscheiden -->
<!-- TODO Bedingung festlegen: Quiztyp unterscheiden % if <Bedingung> % -->
{% if user.is_authenticated %}
<button class="overflow-x-auto text-[clamp(0.3rem,5vw,1rem)] break-words border-4 border-gray-500 text-2xl font-black m-0.75 bg-red-500 rounded-sm shadow-[0_2px_2px_rgba(0,0,0,0.1)] text-center text-white">1</button>
<button class="overflow-x-auto text-[clamp(0.3rem,5vw,1rem)] break-words border-4 border-gray-500 text-2xl font-black m-0.75 bg-indigo-500 rounded-sm shadow-[0_2px_2px_rgba(0,0,0,0.1)] text-center text-white">2</button>
<button class="overflow-x-auto text-[clamp(0.3rem,5vw,1rem)] break-words border-4 border-gray-500 text-2xl font-black m-0.75 bg-yellow-500 rounded-sm shadow-[0_2px_2px_rgba(0,0,0,0.1)] text-center text-white">3</button>
<button class="overflow-x-auto text-[clamp(0.3rem,5vw,1rem)] break-words border-4 border-gray-500 text-2xl font-black m-0.75 bg-green-500 rounded-sm shadow-[0_2px_2px_rgba(0,0,0,0.1)] text-center text-white">4</button>
<!-- TODO wieder einfügen, wenn Bedingung gestetzt -->
{% else %}
<button class="overflow-x-auto text-[clamp(0.3rem,5vw,1rem)] break-words border-4 border-gray-500 text-2xl font-black m-0.75 bg-yellow-500 rounded-sm shadow-[0_2px_2px_rgba(0,0,0,0.1)] text-center text-white">3</button>
<button class="overflow-x-auto text-[clamp(0.3rem,5vw,1rem)] break-words border-4 border-gray-500 text-2xl font-black m-0.75 bg-green-500 rounded-sm shadow-[0_2px_2px_rgba(0,0,0,0.1)] text-center text-white">4</button>
<button class="overflow-x-auto text-[clamp(0.3rem,5vw,1rem)] break-words border-4 border-gray-500 text-2xl font-black m-0.75 bg-green-500 rounded-sm shadow-[0_2px_2px_rgba(0,0,0,0.1)] text-center text-white">wahr</button>
<button class="overflow-x-auto text-[clamp(0.3rem,5vw,1rem)] break-words border-4 border-gray-500 text-2xl font-black m-0.75 bg-red-500 rounded-sm shadow-[0_2px_2px_rgba(0,0,0,0.1)] text-center text-white">falsch</button>
{% endif %}
<!--TODO wieder einfügen, wenn Bedingung gestetzt plus -->
{% endif %}
{% endblock %}

View File

@@ -1,3 +1,4 @@
{% load static %}
<!doctype html>
<html>
<head>

View File

@@ -8,6 +8,6 @@ app_name = 'components' # Namensraum zum verhindern von Konflikten zwischen Apps
#
urlpatterns = [
path('play/<int:pk>', views.play, name='play'),
path('<int:pk>', views.play, name='play'),
]

View File

@@ -1,5 +1,5 @@
from django.shortcuts import render
# Create your views here.
def play(request):
return render(request, 'components/answer.html')
def play(request,pk): #
return render(request, 'components/answer.html', {"pk": pk}) #

View File

@@ -32,6 +32,7 @@ ALLOWED_HOSTS = ['127.0.0.1', 'localhost', '*']
INSTALLED_APPS = [
'homepage.apps.HomepageConfig',
'components.apps.ComponentsConfig',
'accounts.apps.AccountsConfig',
'django.contrib.admin',
'django.contrib.auth',

View File

@@ -6,4 +6,5 @@ nav div ul.qp-nav-list li {
a.qp-a-button {
@apply p-6 rounded-md font-extrabold hover:scale-105 transition duration-300 shadow-md;
}
}
.register input{@apply p-3 rounded-full bg-gray-200 focus:scale-105 transition duration-200 font-black;}

File diff suppressed because one or more lines are too long