mirror of
https://github.com/kristoferssolo/FOSSDB.git
synced 2026-02-04 14:52:11 +00:00
Created user registration form
This commit is contained in:
0
FOSSDB_web/apps/account/__init__.py
Normal file
0
FOSSDB_web/apps/account/__init__.py
Normal file
3
FOSSDB_web/apps/account/admin.py
Normal file
3
FOSSDB_web/apps/account/admin.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
6
FOSSDB_web/apps/account/apps.py
Normal file
6
FOSSDB_web/apps/account/apps.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class AccountConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "account"
|
||||
11
FOSSDB_web/apps/account/forms.py
Normal file
11
FOSSDB_web/apps/account/forms.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from django import forms
|
||||
from django.contrib.auth.forms import UserCreationForm
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
|
||||
class RegisterForm(UserCreationForm):
|
||||
email = forms.EmailField(required=True)
|
||||
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ["username", "email", "password1", "password2"]
|
||||
3
FOSSDB_web/apps/account/tests.py
Normal file
3
FOSSDB_web/apps/account/tests.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
9
FOSSDB_web/apps/account/urls.py
Normal file
9
FOSSDB_web/apps/account/urls.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from django.urls import path
|
||||
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path("", views.sign_up, name="singup"),
|
||||
path("signup", views.sign_up, name="signup"),
|
||||
path("login", views.login_, name="login"),
|
||||
]
|
||||
20
FOSSDB_web/apps/account/views.py
Normal file
20
FOSSDB_web/apps/account/views.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from django.contrib.auth import login
|
||||
from django.shortcuts import redirect, render
|
||||
|
||||
from .forms import RegisterForm
|
||||
|
||||
|
||||
def sign_up(request):
|
||||
if request.method == "POST":
|
||||
form = RegisterForm(request.POST)
|
||||
if form.is_valid():
|
||||
user = form.save()
|
||||
login(request, user)
|
||||
return redirect("/")
|
||||
else:
|
||||
form = RegisterForm()
|
||||
return render(request, "registration/sign_up.html", {"form": form})
|
||||
|
||||
|
||||
def login_(request):
|
||||
return render(request, "registration/login.html")
|
||||
Reference in New Issue
Block a user