-
Notifications
You must be signed in to change notification settings - Fork 983
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'ac-final' of github.com:FusionIIIT/Fusion into ac-7
- Loading branch information
Showing
574 changed files
with
42,378 additions
and
10,351 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -72,3 +72,7 @@ node_modules/ | |
|
||
FusionIIIT/static/ | ||
package-lock.json | ||
|
||
|
||
.DS_Store | ||
|
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,5 @@ | ||
def global_vars(request): | ||
return { | ||
'global_var': request.session.get('currentDesignationSelected', 'default_value'), | ||
'global_var2': request.session.get('allDesignations', 'default_value2'), | ||
} |
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,50 @@ | ||
# custom_middleware.py | ||
from django.contrib.auth.signals import user_logged_in | ||
from django.dispatch import receiver | ||
from applications.globals.models import (ExtraInfo, Feedback, HoldsDesignation, | ||
Issue, IssueImage, DepartmentInfo) | ||
from django.shortcuts import get_object_or_404, redirect, render | ||
|
||
def user_logged_in_middleware(get_response): | ||
@receiver(user_logged_in) | ||
def user_logged_in_handler(sender, user, request, **kwargs): | ||
if 'function_executed' not in request.session: | ||
# Run the function only if the flag is not set | ||
# Assuming user is a model with the desired data field, retrieve the data | ||
# For example, if your User model has a field named 'custom_field', you can access it like: | ||
if user.is_authenticated: | ||
desig = list(HoldsDesignation.objects.select_related('user','working','designation').all().filter(working = request.user).values_list('designation')) | ||
print(desig) | ||
b = [i for sub in desig for i in sub] | ||
design = HoldsDesignation.objects.select_related('user','designation').filter(working=request.user) | ||
|
||
designation=[] | ||
if str(user.extrainfo.user_type) == "student": | ||
designation.append(str(user.extrainfo.user_type)) | ||
|
||
|
||
for i in design: | ||
if str(i.designation) != str(user.extrainfo.user_type): | ||
print('-------') | ||
print(i.designation) | ||
print(user.extrainfo.user_type) | ||
print('') | ||
designation.append(str(i.designation)) | ||
|
||
for i in designation: | ||
print(i) | ||
|
||
request.session['currentDesignationSelected'] = designation[0] | ||
request.session['allDesignations'] = designation | ||
print("logged iN") | ||
|
||
# Set the flag in the session to indicate that the function has bee+n executed | ||
request.session['function_executed'] = True | ||
|
||
def middleware(request): | ||
if request.user.is_authenticated: | ||
user_logged_in_handler(request.user, request.user, request) | ||
response = get_response(request) | ||
return response | ||
|
||
return middleware |
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
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
Oops, something went wrong.