Skip to content

Commit

Permalink
Refactor admin status check in common_data view
Browse files Browse the repository at this point in the history
- Move admin status check to the top of the function
- Modify renewal message logic to consider admin status earlier
- Remove redundant admin status check later in the function
  • Loading branch information
NagiPragalathan committed Feb 10, 2025
1 parent 05b2249 commit 6f5c059
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Binary file modified base/views/__pycache__/common.cpython-312.pyc
Binary file not shown.
5 changes: 3 additions & 2 deletions base/views/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ def add_city(request):

def common_data(request):
context = {}
is_admin = request.user.is_superuser or request.user.is_staff

if request.user.is_authenticated:
current_user = request.user
usr_name = current_user.username
Expand Down Expand Up @@ -253,7 +255,7 @@ def common_data(request):

print(current_date, renewal_date)

if current_date > renewal_date:
if (current_date > renewal_date) or is_admin:
renewal_message = 1 # Indicates expired renewal
days_left_for_renewal = (renewal_date - current_date).days # Negative value for expired
else:
Expand Down Expand Up @@ -284,7 +286,6 @@ def common_data(request):

print(renewal_message, days_left_for_renewal)

is_admin = request.user.is_superuser or request.user.is_staff

context.update({
'usr_profile': profile,
Expand Down

0 comments on commit 6f5c059

Please sign in to comment.