Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull from dev #2

Merged
merged 2 commits into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'))