-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement industry and classification models with dropdown support
- Add Industry and Classification models to base/models.py - Update MainProfile model to use foreign key relationships - Modify add_profile view to support industry and classification dropdowns - Update URLs to include industry and classification CRUD routes - Add middleware for login required pages - Implement download user data functionality
- Loading branch information
1 parent
9cc940a
commit 96d424e
Showing
34 changed files
with
1,443 additions
and
50 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from django.shortcuts import redirect | ||
from django.urls import reverse | ||
|
||
class LoginRequiredMiddleware: | ||
def __init__(self, get_response): | ||
self.get_response = get_response | ||
|
||
def __call__(self, request): | ||
expected_paths = [ | ||
reverse('login'), | ||
reverse('index'), | ||
reverse('contact_form'), | ||
] | ||
# Check if the user is not authenticated and the request is not for the login page | ||
if not request.user.is_authenticated and request.path not in expected_paths: | ||
return redirect('login') # Redirect to the login page | ||
# Continue processing the request | ||
response = self.get_response(request) | ||
return response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
from django.shortcuts import render, get_object_or_404, redirect | ||
from django.contrib.auth.decorators import login_required | ||
from base.models import Industry, Classification | ||
|
||
# Industry CRUD operations | ||
@login_required | ||
def industry_list(request): | ||
industries = Industry.objects.all().order_by('name') | ||
return render(request, 'base_profile/industry_list.html', {'industries': industries}) | ||
|
||
@login_required | ||
def industry_detail(request, pk): | ||
industry = get_object_or_404(Industry, pk=pk) | ||
return render(request, 'base_profile/industry_detail.html', {'industry': industry}) | ||
|
||
@login_required | ||
def industry_create(request): | ||
if request.method == 'POST': | ||
name = request.POST.get('name') | ||
description = request.POST.get('description') | ||
Industry.objects.create(name=name, description=description) | ||
return redirect('industry_list') | ||
return render(request, 'base_profile/industry_form.html') | ||
|
||
@login_required | ||
def industry_update(request, pk): | ||
industry = get_object_or_404(Industry, pk=pk) | ||
if request.method == 'POST': | ||
industry.name = request.POST.get('name') | ||
industry.description = request.POST.get('description') | ||
industry.save() | ||
return redirect('industry_list') | ||
return render(request, 'base_profile/industry_form.html', {'industry': industry}) | ||
|
||
@login_required | ||
def industry_delete(request, pk): | ||
industry = get_object_or_404(Industry, pk=pk) | ||
if request.method == 'POST': | ||
industry.delete() | ||
return redirect('industry_list') | ||
return render(request, 'base_profile/industry_confirm_delete.html', {'industry': industry}) | ||
|
||
# Classification CRUD operations | ||
@login_required | ||
def classification_list(request): | ||
classifications = Classification.objects.all().order_by('name') | ||
return render(request, 'base_profile/classification_list.html', {'classifications': classifications}) | ||
|
||
@login_required | ||
def classification_detail(request, pk): | ||
classification = get_object_or_404(Classification, pk=pk) | ||
return render(request, 'base_profile/classification_detail.html', {'classification': classification}) | ||
|
||
@login_required | ||
def classification_create(request): | ||
if request.method == 'POST': | ||
name = request.POST.get('name') | ||
description = request.POST.get('description') | ||
Classification.objects.create(name=name, description=description) | ||
return redirect('classification_list') | ||
return render(request, 'base_profile/classification_form.html') | ||
|
||
@login_required | ||
def classification_update(request, pk): | ||
classification = get_object_or_404(Classification, pk=pk) | ||
if request.method == 'POST': | ||
classification.name = request.POST.get('name') | ||
classification.description = request.POST.get('description') | ||
classification.save() | ||
return redirect('classification_list') | ||
return render(request, 'base_profile/classification_form.html', {'classification': classification}) | ||
|
||
@login_required | ||
def classification_delete(request, pk): | ||
classification = get_object_or_404(Classification, pk=pk) | ||
if request.method == 'POST': | ||
classification.delete() | ||
return redirect('classification_list') | ||
return render(request, 'base_profile/classification_confirm_delete.html', {'classification': classification}) |
Oops, something went wrong.