init commit

This commit is contained in:
2025-11-08 19:52:13 +01:00
parent eb3ef908a0
commit 174af90eb4
332 changed files with 63397 additions and 0 deletions

0
accounts/__init__.py Normal file
View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

3
accounts/admin.py Normal file
View File

@@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

6
accounts/apps.py Normal file
View File

@@ -0,0 +1,6 @@
from django.apps import AppConfig
class AccountsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'accounts'

11
accounts/forms.py Normal file
View File

@@ -0,0 +1,11 @@
from django import forms
class UserRegistrationForm(forms.Form):
username = forms.CharField()
email = forms.EmailField()
password = forms.CharField()
class UserLoginForm(forms.Form):
username = forms.CharField()
password = forms.CharField()

View File

7
accounts/models.py Normal file
View File

@@ -0,0 +1,7 @@
from django.db import models
# Create your models here.

3
accounts/tests.py Normal file
View File

@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

8
accounts/urls.py Normal file
View File

@@ -0,0 +1,8 @@
from django.urls import path
from . import views
urlpatterns = [
path('register/', views.user_register, name='user_register'),
path('login/', views.user_login, name='user_login'),
path('logout/', views.user_logout, name='user_logout')
]

43
accounts/views.py Normal file
View File

@@ -0,0 +1,43 @@
from django.shortcuts import render, redirect
from django.contrib.auth.models import User
from .forms import UserRegistrationForm, UserLoginForm
from django.contrib import messages
from django.contrib.auth import authenticate, login, logout
# Create your views here.
def user_register(request):
if request.method == 'POST':
form = UserRegistrationForm(request.POST)
if form.is_valid():
cd = form.cleaned_data
User.objects.create_user(cd['username'], cd['email'], cd['password'])
messages.success(request, 'user created successfully')
return redirect('home')
else:
form = UserRegistrationForm()
return render(request, 'register.html', {'form' : form})
def user_login(request):
if request.method == 'POST':
form = UserLoginForm(request.POST)
if form.is_valid():
cd = form.cleaned_data
user = authenticate(request, username=cd['username'], password=cd['password'])
if user is not None:
login(request, user)
messages.success(request, 'logged in successfully')
return redirect('home')
else:
messages.error(request, 'username or password is wrong')
else:
form = UserLoginForm()
return render(request, 'login.html', {'form': form})
def user_logout(request):
logout(request)
messages.success(request, 'logged out successfully')
return redirect('home')