2024-12-07 13:22:12 +00:00
|
|
|
import logging
|
|
|
|
|
|
|
|
|
2024-11-24 07:45:02 +00:00
|
|
|
from django.contrib import messages
|
|
|
|
from django.shortcuts import redirect, render
|
|
|
|
from django.http import HttpRequest, HttpResponse
|
|
|
|
|
2024-12-07 13:22:12 +00:00
|
|
|
from django import conf, forms
|
|
|
|
|
|
|
|
|
2024-11-24 07:45:02 +00:00
|
|
|
from .models import User
|
2024-12-07 13:22:12 +00:00
|
|
|
from .forms import RegisterForm
|
|
|
|
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
2024-11-23 12:28:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
def index(request):
|
2024-11-24 07:45:02 +00:00
|
|
|
# return HttpResponse("Hello, world. You're at the polls index.")
|
|
|
|
return render(request, 'index.html')
|
|
|
|
|
|
|
|
|
2024-12-07 21:30:55 +00:00
|
|
|
def dashboard(request):
|
|
|
|
return HttpResponse("Hello, world. You're at the polls index.")
|
|
|
|
|
|
|
|
|
2024-11-24 07:45:02 +00:00
|
|
|
def register(request: HttpRequest):
|
|
|
|
|
|
|
|
# if the form is not submitted yet, return the form
|
2024-12-07 13:22:12 +00:00
|
|
|
if request.method == 'POST':
|
|
|
|
form = RegisterForm(request.POST)
|
|
|
|
if form.is_valid():
|
|
|
|
form.save()
|
|
|
|
messages.success(request, 'Registration successful!')
|
|
|
|
return redirect('login')
|
|
|
|
else:
|
|
|
|
form = RegisterForm()
|
2024-11-24 07:45:02 +00:00
|
|
|
|
2024-12-07 13:22:12 +00:00
|
|
|
return render(request, 'register.html', {'form': form})
|