Skip to content

Commit

Permalink
Merge pull request #2 from Munaikh/dev
Browse files Browse the repository at this point in the history
Pull from dev
  • Loading branch information
Munaikh authored Mar 3, 2025
2 parents cf3756b + cf3e781 commit 66521a8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
9 changes: 7 additions & 2 deletions project_design/growth_app/templates/growth_app/register.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h2 class="mb-4">Register</h2>
<div class="card-body">
<form method="post">
{% csrf_token %}
<div class="form-group">
<div class="form-group">
<label for="id_username">Name</label>
{{ form.username }}
</div>
Expand All @@ -22,14 +22,19 @@ <h2 class="mb-4">Register</h2>
<div class="form-group">
<label for="id_password1">Password</label>
{{ form.password1 }}
</div>
</div>
<div class="form-group">
<label for="id_password2">Password</label>
{{ form.password2 }}
</div>
<div class="form-check mb-3">
<input type="checkbox" class="form-check-input" id="terms" required>
<label class="form-check-label" for="terms">
Label<br>
Description
</label>
</div>
{% comment %} {{ form }} {% endcomment %}
<button type="submit" class="btn btn-dark btn-block">Register</button>
</form>
</div>
Expand Down
2 changes: 1 addition & 1 deletion project_design/growth_app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# Authentication
path('signin/', views.signin_view, name='signin'),
path('register/', views.register_view, name='register'),
path('logout/', auth_views.LogoutView.as_view(), name='logout'),
path('logout/', views.user_logout, name='logout'),
path('forgot-password/', views.forgot_password, name='forgot_password'),

# User dashboard and settings
Expand Down
11 changes: 10 additions & 1 deletion project_design/growth_app/views.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from re import L
from django.shortcuts import render, redirect, get_object_or_404
from django.contrib.auth.decorators import login_required
from django.contrib.auth import login, authenticate
from django.contrib.auth import login, authenticate, logout
from django.contrib.auth.forms import AuthenticationForm
from django.http import JsonResponse
from django.contrib.auth.models import User
from django.urls import reverse
from .models import Business, SalesData, UserProfile

from .forms import (
RegistrationForm, BusinessForm, SalesDataForm,
UserProfileForm, PasswordChangeForm
Expand Down Expand Up @@ -41,6 +44,7 @@ def register_view(request):
"""User registration view."""
if request.method == 'POST':
form = RegistrationForm(request.POST)
print(form.data)
if form.is_valid():
user = form.save()
# Create a user profile
Expand Down Expand Up @@ -165,3 +169,8 @@ def get_sales_data(request, business_id):
'amounts': [float(item.amount) for item in sales_data]
}
return JsonResponse(data)

@login_required
def user_logout(request):
logout(request)
return redirect(reverse('landing_page'))

0 comments on commit 66521a8

Please sign in to comment.