Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
5c61a54
GAD-5: Fix responsiveness (#1125)
Lawful2002 Feb 23, 2023
9a4fc4d
Merge branch 'main' into gad-5
akshatnema Mar 15, 2023
b295d7f
Merge branch 'main' into gad-5
akshatnema Mar 15, 2023
72e34e7
Merge branch 'main' into gad-5
akshatnema Mar 18, 2023
721ee82
Merge branch 'main' into gad-5
akshatnema Mar 19, 2023
91ef4e9
Merge branch 'main' into gad-5
akshatnema Mar 23, 2023
da49572
Merge branch 'main' into gad-5
akshatnema Mar 26, 2023
468b866
fix requirements and docker-compose
Aragorn-64 Jan 22, 2024
bed09cc
fix docker compose and dependencies
theoden42 Jan 23, 2024
d136718
fix merge conflicts
theoden42 Jan 23, 2024
10a5fec
add sdk and api folder structure
theoden42 Jan 23, 2024
b60770f
add sdk methods and fix some urls
theoden42 Jan 23, 2024
fe98b1d
update models for API
Aragorn-64 Jan 23, 2024
f6c5284
add urls for api
Aragorn-64 Jan 23, 2024
8ee2f6e
merge urls in api
Aragorn-64 Jan 23, 2024
d6917b8
Merge remote-tracking branch 'upstream/main'
Aragorn-64 Jan 23, 2024
726e6f1
add methods for viewing file, inbox, outbox, getting designation with…
theoden42 Jan 27, 2024
0bd4cb4
fix serializers and fix file attachment functionality in forward_file
theoden42 Jan 28, 2024
b36972c
sync with upstream
Aragorn-64 Jan 30, 2024
1631e25
add views and fix urls
theoden42 Jan 30, 2024
201185d
create file
Aragorn-64 Jan 30, 2024
18cdf15
Merge branch 'main' of https://github.com/theoden42/Fusion
Aragorn-64 Jan 30, 2024
a3c1d63
create file change
Aragorn-64 Jan 30, 2024
ef9105e
fix create_file, without upload_file feature
Aragorn-64 Jan 30, 2024
87dc61a
fix sdk forward_file : accept remarks
Aragorn-64 Jan 30, 2024
5ad97a7
add view_history in sdk
Aragorn-64 Jan 30, 2024
07f7d04
add blueprint for draft and archive methods to sdk
Aragorn-64 Feb 6, 2024
54845b1
fix FileHeaderSerializer to include id
Aragorn-64 Feb 6, 2024
30afd49
fix empty file upload error
Aragorn-64 Feb 6, 2024
55e8a74
fix inbox outbox methods to return unique ids
Aragorn-64 Feb 6, 2024
6ead47d
fix complete_flag to is_read
Aragorn-64 Feb 6, 2024
40815fd
fix inbox outbox methods to not show archived
Aragorn-64 Feb 6, 2024
d4bf291
add view_archived method to sdk
Aragorn-64 Feb 6, 2024
aea33d8
add archive_file method to sdk
Aragorn-64 Feb 6, 2024
66706c7
fix inbox and outbox output and add support for attachments
theoden42 Feb 12, 2024
ab0489d
add draft methods to sdk
Aragorn-64 Feb 12, 2024
423a2f9
fix default values of named params
Aragorn-64 Feb 12, 2024
cf2bbd5
fix merge conflicts
theoden42 Feb 12, 2024
c60098f
fix css for filetracking.html
Aragorn-64 Feb 15, 2024
1d27054
fix fts serializer.py
Aragorn-64 Feb 15, 2024
eff3142
add dept adding method to sdk
Aragorn-64 Feb 15, 2024
6eb1284
add helper methods to sdk
Aragorn-64 Feb 17, 2024
25f7174
fix inbox based on SDK
Aragorn-64 Feb 17, 2024
49f4a41
remove track from TabMenu
Aragorn-64 Feb 17, 2024
6d908b2
fix outbox using SDK
Aragorn-64 Feb 17, 2024
736ea3b
fix archive view for SDK
Aragorn-64 Feb 17, 2024
21c32d3
fix Drafts based on SDK
Aragorn-64 Feb 17, 2024
c4a66ba
fix the view file functionality in the web app
theoden42 Feb 18, 2024
086cb3c
fix frontend
Aragorn-64 Feb 18, 2024
ce5b4f3
fix .gitignore to untrack migrations
Aragorn-64 Feb 18, 2024
b07ea3f
fix 1. order of files in inbox and outbox 2. order of files is mantai…
theoden42 Feb 19, 2024
402c8c4
fix login required on viewing file
theoden42 Feb 19, 2024
5c6ab07
fix create_file method so that subject and description are also accepted
theoden42 Feb 19, 2024
a4e01b3
add rest api for create file and view file
theoden42 Mar 3, 2024
3760068
add rest api for create, view and delete file
aish0749 Mar 3, 2024
a06d437
add rest api for inbox, outbox, history view
aish0749 Mar 3, 2024
2ab199e
add rest api for draft view, forward file
aish0749 Mar 4, 2024
e824b66
Merge remote-tracking branch 'upstream/gad-4'
theoden42 Mar 5, 2024
79ef20d
prevent student access of the filetracking module
theoden42 Mar 5, 2024
c3f14b7
add dropdown filtering based on reciever username and update notallow…
theoden42 Mar 5, 2024
a97f482
add option to unarchive files
theoden42 Mar 7, 2024
b0109b8
fix template for filetrackingnotallowed page
theoden42 Mar 7, 2024
586775a
fix attachments view in the history of the file
theoden42 Mar 7, 2024
b3c8f54
make the fields in draft view editable
theoden42 Mar 7, 2024
0dfdd3f
update the views
aish0749 Mar 10, 2024
2018781
Merge pull request #1 from aish0749/main
theoden42 Mar 10, 2024
47af12c
GAD -5 Dashboard Changes (#1325)
BlackHAWK2001 Mar 11, 2024
ed642ee
dashboard and usercard updated (#1329)
Arpittak Mar 12, 2024
d40e94d
Fixing ui bugs (#1335)
SukulSarve Mar 17, 2024
acf82f8
merge updated changes in dashboard into the filetracking module.
theoden42 Mar 19, 2024
7f33e90
fix file sending and forwarding template to include designation autom…
theoden42 Mar 19, 2024
2f8813c
fix forward file view to include designations automatically
theoden42 Mar 19, 2024
ef2de07
add redirect on designation change
Aragorn-64 Mar 19, 2024
e570edb
Merge branch 'gad-5'
Aragorn-64 Mar 19, 2024
9ba2b85
add redirect to dropdown designation to views
Aragorn-64 Mar 19, 2024
1fe6907
add redirect on designation change
Aragorn-64 Mar 19, 2024
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
5 changes: 5 additions & 0 deletions FusionIIIT/Fusion/context_processors.py
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'),
}
48 changes: 48 additions & 0 deletions FusionIIIT/Fusion/middleware/custom_middleware.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# 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=[]

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
2 changes: 2 additions & 0 deletions FusionIIIT/Fusion/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'Fusion.middleware.custom_middleware.user_logged_in_middleware',
]

ROOT_URLCONF = 'Fusion.urls'
Expand All @@ -178,6 +179,7 @@
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'Fusion.context_processors.global_vars',
],
},
},
Expand Down
166 changes: 123 additions & 43 deletions FusionIIIT/applications/filetracking/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from .sdk.methods import *
from .decorators import *


@login_required(login_url="/accounts/login/")
@user_is_student
def filetracking(request):
Expand All @@ -39,7 +40,7 @@ def filetracking(request):
holdsdesignations - The HoldsDesignation object.
context - Holds data needed to make necessary changes in the template.
"""
print(request.POST)

if request.method == "POST":
try:
if 'save' in request.POST:
Expand Down Expand Up @@ -132,35 +133,37 @@ def filetracking(request):
extrainfo = ExtraInfo.objects.select_related('user', 'department').all()
holdsdesignations = HoldsDesignation.objects.select_related(
'user', 'working', 'designation').all()
designations = get_designation(request.user)

designation_name = request.session.get('currentDesignationSelected', 'default_value')
username = request.user
designation_id = get_HoldsDesignation_obj(
username, designation_name).id

context = {
'file': file,
'extrainfo': extrainfo,
'holdsdesignations': holdsdesignations,
'designations': designations,
'designation_name': designation_name,
'designation_id': designation_id
}
return render(request, 'filetracking/composefile.html', context)


@login_required(login_url="/accounts/login")
def draft_design(request):
"""
This function redirects the user to the drafts page of designation selected in dropdown
@param:
request - trivial.
"""
The function is used to get the designation of the user and renders it on draft template.

@param:
request - trivial.

@variables:
dropdown_design = request.session.get(
'currentDesignationSelected', 'default_value')
username = request.user
dropdown_HoldsDesignation_obj = get_HoldsDesignation_obj(
username, dropdown_design)


context - Holds data needed to make necessary changes in the template.
"""
designation = get_designation(request.user)
context = {
'designation': designation,
}
return render(request, 'filetracking/draft_design.html', context)
return redirect('/filetracking/drafts/' + str(dropdown_HoldsDesignation_obj.id))


@login_required(login_url="/accounts/login")
Expand All @@ -178,6 +181,8 @@ def drafts_view(request, id):





"""
user_HoldsDesignation_obj = HoldsDesignation.objects.select_related(
'user', 'working', 'designation').get(pk=id)
Expand All @@ -196,9 +201,28 @@ def drafts_view(request, id):

draft_files = add_uploader_department_to_files_list(draft_files)

user_HoldsDesignation_obj = HoldsDesignation.objects.select_related(
'user', 'working', 'designation').get(pk=id)
s = str(user_HoldsDesignation_obj).split(" - ")
designation = s[1]
draft_files = view_drafts(
username=user_HoldsDesignation_obj.user,
designation=user_HoldsDesignation_obj.designation,
src_module='filetracking'
)

# Correct upload_date type
for f in draft_files:
f['upload_date'] = parse_datetime(f['upload_date'])
f['uploader'] = get_extra_info_object_from_id(f['uploader'])

draft_files = add_uploader_department_to_files_list(draft_files)

context = {
'draft_files': draft_files,
'designations': designation,
'draft_files': draft_files,
'designations': designation,
}
return render(request, 'filetracking/drafts.html', context)

Expand All @@ -216,15 +240,38 @@ def outbox_view(request, id):
id - user id

@variables:
outward_files - File objects filtered by current_id i.e, present working user.
outward_files - File objects filtered by current_id i.e, present working user.
context - Holds data needed to make necessary changes in the template.


"""
user_HoldsDesignation_obj = HoldsDesignation.objects.select_related(
'user', 'working', 'designation').get(pk=id)
s = str(user_HoldsDesignation_obj).split(" - ")
designation = s[1]

outward_files = view_outbox(username=user_HoldsDesignation_obj.user,
designation=user_HoldsDesignation_obj.designation,
src_module='filetracking')

for f in outward_files:
last_forw_tracking = get_last_forw_tracking_for_user(file_id=f['id'],
username=user_HoldsDesignation_obj.user,
designation=user_HoldsDesignation_obj.designation)
f['sent_to_user'] = last_forw_tracking.receiver_id
f['sent_to_design'] = last_forw_tracking.receive_design
f['last_sent_date'] = last_forw_tracking.forward_date

f['upload_date'] = parse_datetime(f['upload_date'])
f['uploader'] = get_extra_info_object_from_id(f['uploader'])

outward_files = add_uploader_department_to_files_list(outward_files)
user_HoldsDesignation_obj = HoldsDesignation.objects.select_related(
'user', 'working', 'designation').get(pk=id)
s = str(user_HoldsDesignation_obj).split(" - ")
designation = s[1]

outward_files = view_outbox(username=user_HoldsDesignation_obj.user,
designation=user_HoldsDesignation_obj.designation,
src_module='filetracking')
Expand All @@ -246,6 +293,8 @@ def outbox_view(request, id):

'out_files': outward_files,
'viewer_designation': designation,
'out_files': outward_files,
'viewer_designation': designation,
}
return render(request, 'filetracking/outbox.html', context)

Expand All @@ -259,8 +308,10 @@ def inbox_view(request, id):
@param:
request - trivial.
id - HoldsDesignation object id
id - HoldsDesignation object id

@variables:
inward_files - File object with additional sent by information
inward_files - File object with additional sent by information
context - Holds data needed to make necessary changes in the template.

Expand Down Expand Up @@ -289,51 +340,74 @@ def inbox_view(request, id):
inward_files = add_uploader_department_to_files_list(inward_files)


user_HoldsDesignation_obj = HoldsDesignation.objects.select_related(
'user', 'working', 'designation').get(pk=id)
s = str(user_HoldsDesignation_obj).split(" - ")
designation = s[1]
inward_files = view_inbox(
username=user_HoldsDesignation_obj.user,
designation=user_HoldsDesignation_obj.designation,
src_module='filetracking'
)

# correct upload_date type and add recieve_date
for f in inward_files:
f['upload_date'] = parse_datetime(f['upload_date'])

last_recv_tracking = get_last_recv_tracking_for_user(file_id=f['id'],
username=user_HoldsDesignation_obj.user,
designation=user_HoldsDesignation_obj.designation)
f['receive_date'] = last_recv_tracking.receive_date
f['uploader'] = get_extra_info_object_from_id(f['uploader'])

inward_files = add_uploader_department_to_files_list(inward_files)


context = {

'in_file': inward_files,
'designations': designation,
'in_file': inward_files,
'designations': designation,
}
return render(request, 'filetracking/inbox.html', context)
return render(request, 'filetracking/inbox.html', context)


@login_required(login_url="/accounts/login")
def outward(request):
"""
This function fetches the different designations of the user and renders it on outward template
This function redirects the user to the outbox page of designation selected in dropdown
@param:
request - trivial.
"""

@variables:
context - Holds the different designation data of the user
dropdown_design = request.session.get(
'currentDesignationSelected', 'default_value')
username = request.user
dropdown_HoldsDesignation_obj = get_HoldsDesignation_obj(
username, dropdown_design)

return redirect('/filetracking/outbox/' + str(dropdown_HoldsDesignation_obj.id))

"""
designation = get_designation(request.user)

context = {
'designation': designation,
}
return render(request, 'filetracking/outward.html', context)


@login_required(login_url="/accounts/login")
def inward(request):
"""
This function fetches the different designations of the user and renders it on inward template


"""
This function redirects the user to the inbox page of designation selected in dropdown
@param:
request - trivial.

@variables:
context - Holds the different designation data of the user
"""
designation = get_designation(request.user)
context = {

'designation': designation,
}
return render(request, 'filetracking/inward.html', context)
dropdown_design = request.session.get(
'currentDesignationSelected', 'default_value')
username = request.user
dropdown_HoldsDesignation_obj = get_HoldsDesignation_obj(
username, dropdown_design)

return redirect('/filetracking/inbox/' + str(dropdown_HoldsDesignation_obj.id))


@login_required(login_url = "/accounts/login")
Expand Down Expand Up @@ -527,13 +601,19 @@ def forward(request, id):

@login_required(login_url="/accounts/login")
def archive_design(request):
designation = HoldsDesignation.objects.select_related(
'user', 'working', 'designation').filter(user=request.user)
"""
This function redirects the user to the archive page of designation selected in dropdown
@param:
request - trivial.
"""

context = {
'designation': designation,
}
return render(request, 'filetracking/archive_design.html', context)
dropdown_design = request.session.get(
'currentDesignationSelected', 'default_value')
username = request.user
dropdown_HoldsDesignation_obj = get_HoldsDesignation_obj(
username, dropdown_design)

return redirect('/filetracking/archive/' + str(dropdown_HoldsDesignation_obj.id))


@login_required(login_url="/accounts/login")
Expand Down
3 changes: 2 additions & 1 deletion FusionIIIT/applications/globals/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
# Endpoint to reset all passwords in DEV environment
url(r'^resetallpass/$', views.reset_all_pass, name='resetallpass'),
# API urls
url(r'^api/', include('applications.globals.api.urls'))
url(r'^api/', include('applications.globals.api.urls')),
url(r'^update_global_variable/$', views.update_global_variable, name='update_global_var'),
]
Loading