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

Gad 3 complaint management #1545

Open
wants to merge 46 commits into
base: gad-3-final
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
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
daab40e
Minor changes
nidhibarapatre Mar 4, 2024
92faf40
Implementation of FTS and completion of the redirect functionality
nidhibarapatre 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
3f43b27
Change in model of supervisor
nidhibarapatre Mar 6, 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
d50d0e6
Complition of redirect functionality and pagination
nidhibarapatre Mar 8, 2024
bf8f36c
Fixation of a error
nidhibarapatre Mar 8, 2024
0dfdd3f
update the views
aish0749 Mar 10, 2024
2018781
Merge pull request #1 from aish0749/main
theoden42 Mar 10, 2024
e6afdd7
Completion of module
nidhibarapatre Mar 11, 2024
59d8868
Merge remote-tracking branch 'upstream2/gad-5' into gad-3
nidhibarapatre Mar 18, 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
9ea22d7
Integrated dashborad
nidhibarapatre Mar 20, 2024
7a16993
creating new branch
nidhibarapatre Mar 20, 2024
feebe01
Merge remote-tracking branch 'upstream3/gad-3' into new-gad3
nidhibarapatre Mar 20, 2024
a54deb1
disallowing migrations
nidhibarapatre Mar 20, 2024
61a875a
removing migration files
nidhibarapatre Mar 21, 2024
56918b4
resolved errors
nidhibarapatre Mar 26, 2024
725edc9
Merge remote-tracking branch 'upstream3/gad-3' into gad_-3
nidhibarapatre Mar 26, 2024
808b4cf
support file uploading and other minor fixes
arminpatel Apr 2, 2024
c0e4d4c
Merge remote-tracking branch 'upstream3/gad-3' into gad-3-complaint
nidhibarapatre Apr 2, 2024
21f4411
change docker and req
arminpatel Apr 2, 2024
4032140
Merge branch 'main' of https://github.com/theoden42/Fusion into gad-3…
arminpatel Apr 2, 2024
2a8dd80
resolved error
nidhibarapatre Apr 2, 2024
fb22dbb
Merge remote-tracking branch 'upstream3/gad-3' into gad--3-complaint
nidhibarapatre Apr 2, 2024
2677ecf
fts implementation in api and bug fixes
arminpatel Apr 14, 2024
a8c631f
Merge branch 'gad-3' of https://github.com/FusionIIIT/Fusion into gad…
arminpatel Apr 14, 2024
e41c09d
change requirements.txt
arminpatel Apr 14, 2024
a0ddb2d
add user_type enum
arminpatel Apr 14, 2024
eb8dbc5
Merge pull request #1454 from arminpatel/gad-3-test
Priyansh61 Apr 15, 2024
7555628
minor changes
nidhibarapatre Apr 19, 2024
30429b7
Merge remote-tracking branch 'upstream3/gad-3' into gad3--complaint
nidhibarapatre Apr 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
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ node_modules/
FusionIIIT/static/
package-lock.json


docker-entrypoint.sh


Expand All @@ -86,4 +85,3 @@ postgres_data
!media/Administrator/academic_procedures/sample_student_profile.xlsx

migrations/

Empty file.
Empty file.
Empty file.
15 changes: 14 additions & 1 deletion FusionIIIT/applications/complaint_system/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,25 @@ class CaretakerSerializers(serializers.ModelSerializer):
class Meta:
model = Caretaker
fields=('__all__')
depth=2

def to_representation(self, instance):
response = super().to_representation(instance)
# get caretaker complaints and filter by status = 0
complaints = StudentComplain.objects.filter(location = instance.area, status = 0)
response['complaints'] = StudentComplainSerializers(complaints, many=True).data
return response

class SupervisorSerializers(serializers.ModelSerializer):
class Meta:
model=Supervisor
fields=('__all__')

def to_representation(self, instance):
response = super().to_representation(instance)
response['name'] = instance.sup_id.user.first_name + ' ' + instance.sup_id.user.last_name
return response

class ExtraInfoSerializers(serializers.ModelSerializer):
class Meta:
model=ExtraInfo
Expand All @@ -34,4 +47,4 @@ class Meta:
class UserSerializers(serializers.ModelSerializer):
class Meta:
model=User
fields=('__all__')
fields=('__all__')
1 change: 1 addition & 0 deletions FusionIIIT/applications/complaint_system/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@
url(r'^removesupervisor/(?P<s_id>[0-9]+)',views.edit_supervisor_api,name='supervisor-delete-api'),
url(r'^updatesupervisor/(?P<s_id>[0-9]+)',views.edit_supervisor_api,name='supervisor-put-api'),

url(r'^forward', views.forward_complaint_api, name='forward-complaint-api'),
]
73 changes: 56 additions & 17 deletions FusionIIIT/applications/complaint_system/api/views.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from django.contrib.auth import get_user_model
from django.contrib.auth.decorators import login_required
from applications.globals.models import (HoldsDesignation,Designation)
from django.shortcuts import get_object_or_404
from django.forms.models import model_to_dict
from django.shortcuts import get_object_or_404
from rest_framework.permissions import IsAuthenticated
from rest_framework.authentication import TokenAuthentication
from rest_framework import status
Expand All @@ -11,6 +10,7 @@
from rest_framework.response import Response
from applications.globals.models import User,ExtraInfo
from applications.complaint_system.models import Caretaker, StudentComplain, Supervisor, Workers
from applications.complaint_system.models import USER_TYPE
from . import serializers


Expand Down Expand Up @@ -43,19 +43,34 @@ def complaint_details_api(request,detailcomp_id1):
def student_complain_api(request):
user = get_object_or_404(User,username = request.user.username)
user = ExtraInfo.objects.all().filter(user = user).first()
if user.user_type == 'student':
complain = StudentComplain.objects.filter(complainer = user)
elif user.user_type == 'staff':
staff = ExtraInfo.objects.get(id=user.id)
staff = Caretaker.objects.get(staff_id=staff)
complain = StudentComplain.objects.filter(location = staff.area)
elif user.user_type == 'faculty':
faculty = ExtraInfo.objects.get(id=user.id)
faculty = Supervisor.objects.get(sup_id=faculty)
complain = StudentComplain.objects.filter(location = faculty.area)
complains = serializers.StudentComplainSerializers(complain,many=True).data

user_type = USER_TYPE.student
extra_info_id = ExtraInfo.objects.get(id=user.id)
caretaker = Caretaker.objects.filter(staff_id=extra_info_id)
supervisor = Supervisor.objects.filter(sup_id=extra_info_id)
if caretaker.exists():
complaints = StudentComplain.get_complaints_by_user(user, USER_TYPE.caretaker)
user_type = USER_TYPE.caretaker
elif supervisor.exists():
complaints = StudentComplain.get_complaints_by_user(user, USER_TYPE.supervisor)
user_type = USER_TYPE.supervisor
else:
complaints = StudentComplain.get_complaints_by_user(user, USER_TYPE.student)

complaints = serializers.StudentComplainSerializers(complaints,many=True).data

if user_type == USER_TYPE.caretaker or user_type == USER_TYPE.supervisor:
for complaint in complaints:
last_forwarded = StudentComplain.get_complaint_owner(complaint['id'])
if last_forwarded.username != request.user.username:
complaint['last_forwarded'] = {
'name': last_forwarded.first_name + ' ' + last_forwarded.last_name,
'username': last_forwarded.username,
}

resp = {
'student_complain' : complains,
'student_complain' : complaints,
'user_type': user_type,
}
return Response(data=resp,status=status.HTTP_200_OK)

Expand All @@ -66,6 +81,7 @@ def create_complain_api(request):
serializer = serializers.StudentComplainSerializers(data=request.data)
if serializer.is_valid():
serializer.save()
StudentComplain.create_file_for_complaint(serializer.instance)
return Response(serializer.data, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)

Expand All @@ -84,7 +100,7 @@ def edit_complain_api(request,c_id):
serializer = serializers.StudentComplainSerializers(complain,data=request.data)
if serializer.is_valid():
serializer.save()
return Response(serializer.data,status=status.HTTP_200_OK)
return Response(serializer.data,status=status.HTTP_201_CREATED)
return Response(serializer.errors,status=status.HTTP_400_BAD_REQUEST)

@api_view(['GET','POST'])
Expand Down Expand Up @@ -141,9 +157,16 @@ def edit_worker_api(request,w_id):
@permission_classes([IsAuthenticated])
@authentication_classes([TokenAuthentication])
def caretaker_api(request):

if request.method == 'GET':
caretaker = Caretaker.objects.all()
caretakers = None
user = get_object_or_404(User,username = request.user.username)
user = ExtraInfo.objects.get(user = user)
extra_info_id = ExtraInfo.objects.get(id=user.id)
supervisor = Supervisor.objects.filter(sup_id=extra_info_id)
if supervisor.exists():
caretaker = Caretaker.objects.filter(area = supervisor.first().area)
else:
caretaker = Caretaker.objects.all()
caretakers = serializers.CaretakerSerializers(caretaker,many=True).data
resp = {
'caretakers' : caretakers,
Expand Down Expand Up @@ -231,3 +254,19 @@ def edit_supervisor_api(request,s_id):
return Response(serializer.data,status=status.HTTP_200_OK)
return Response(serializer.errors,status=status.HTTP_400_BAD_REQUEST)


@api_view(['POST'])
@permission_classes([IsAuthenticated])
@authentication_classes([TokenAuthentication])
def forward_complaint_api(request):
user = get_object_or_404(User, username=request.user.username)
user = ExtraInfo.objects.get(user=user)
supervisor = Supervisor.objects.filter(sup_id=user)
caretaker = Caretaker.objects.filter(staff_id=user)

if supervisor.exists() or caretaker.exists():
forward_supervisor = Supervisor.objects.get(id=request.data['forward_id'])
StudentComplain.forward_complaint(forward_supervisor.sup_id, request.data['complaint_id'])
return Response({'message':'Complaint forwarded'},status=status.HTTP_200_OK)
else:
return Response({'message':'Logged in user does not have permission'},status=status.HTTP_403_FORBIDDEN)
Empty file.
86 changes: 81 additions & 5 deletions FusionIIIT/applications/complaint_system/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@
from django.db import models
from django.utils import timezone

from applications.globals.models import ExtraInfo
from applications.globals.models import ExtraInfo, HoldsDesignation
from applications.filetracking.sdk import methods as fts
from applications.filetracking.models import File
from django.contrib.auth.models import User

from enum import Enum

# Class definations:


class Constants:
AREA = (
('hall-1', 'hall-1'),
AREA = ( ('hall-1', 'hall-1'),
('hall-3', 'hall-3'),
('hall-4', 'hall-4'),
('library', 'CC1'),
('computer center', 'CC2'),
('computer center', 'CC'),
('core_lab', 'core_lab'),
('LHTC', 'LHTC'),
('NR2', 'NR2'),
Expand All @@ -35,6 +38,10 @@ class Constants:
('other', 'other'),
)

class USER_TYPE(Enum):
student = 'student'
caretaker = 'caretaker'
supervisor = 'supervisor'

class Caretaker(models.Model):
staff_id = models.ForeignKey(ExtraInfo, on_delete=models.CASCADE)
Expand Down Expand Up @@ -88,6 +95,75 @@ class StudentComplain(models.Model):
def __str__(self):
return str(self.complainer.user.username)

@staticmethod
def get_complaints_by_user(user: ExtraInfo, role: str):
"""
user: ExtraInfo
role: student, caretaker or supervisor
"""
if role == 'student':
return StudentComplain.objects.filter(complainer=user)
elif role == 'caretaker' or role == 'supervisor':
designation = HoldsDesignation.objects.get(user=user.user).designation.name
complaints = fts.view_inbox(
username=user.user.username,
designation=designation,
src_module='complaint'
)
complaint_queryset = StudentComplain.objects.none()
for complaint in complaints:
complaint_queryset |= StudentComplain.objects.filter(id=complaint['src_object_id'])

return complaint_queryset


@staticmethod
def create_file_for_complaint(complaint):
"""
complaint: StudentComplain
"""

caretaker = Caretaker.objects.get(area=complaint.location)
caretaker_designation = HoldsDesignation.objects.get(user=caretaker.staff_id.user).designation.name

fts.create_file(
uploader=complaint.complainer.user.username,
uploader_designation='student',
receiver=caretaker.staff_id.user.username,
receiver_designation=caretaker_designation,
src_module='complaint',
src_object_id=complaint.id
)

return complaint

@staticmethod
def forward_complaint(user: ExtraInfo, complaint_id: int):
"""
user: ExtraInfo
complaint_id: int
"""
file = File.objects.get(src_object_id=complaint_id, src_module='complaint')
user_designation = HoldsDesignation.objects.get(user=user.user)
try:
fts.forward_file(
file_id=file.id,
receiver=user.user.username,
receiver_designation=user_designation.designation.name,
file_extra_JSON={},
)
return True, 'Complaint forwarded successfully'
except Exception as e:
return False, str(e)


# owner refers to whom it was last forwarded not the complainer
@staticmethod
def get_complaint_owner(complaint_id: int) -> User:
file = File.objects.get(src_object_id=complaint_id, src_module='complaint')
owner_id = fts.get_current_file_owner(file.id)
return User.objects.get(username=owner_id)


class Supervisor(models.Model):
sup_id = models.ForeignKey(ExtraInfo, on_delete=models.CASCADE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ $(document).ready(function(){
var complaint_type = $('input[name="complaint_type"]').val() ;
var details =$('input[name="details"]').val() ;
var myfile = $('input[name="myfile"]').val();
if(specific_location=="" || Location=="" || details=="" || complaint_type=="")
if(complaint_type=="" || Location=="" || details=="" || specific_location=="")
{
alert("Please fill all the details!");
return;
Expand Down
21 changes: 12 additions & 9 deletions FusionIIIT/applications/complaint_system/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,37 @@
# url(r'^user/check_complaint/$', views.save_comp),

# caretaker
url(r'^caretaker/lodge/$', views.caretakerlodge),
# url(r'^caretaker/lodge/$', views.caretakerlodge),
url(r'^caretaker/$', views.caretaker, name='caretaker'),
url(r'^caretaker/feedback/(?P<feedcomp_id>[0-9]+)/$', views.feedback_care),
url(r'^caretaker/pending/(?P<cid>[0-9]+)/$', views.resolvepending),
url(r'^caretaker/detail2/(?P<detailcomp_id1>[0-9]+)/$', views.detail),
url(r'^caretaker/search_complaint$', views.search_complaint),
url(r'^caretaker/(?P<complaint_id>[0-9]+)/feedback/$', views.submitfeedbackcaretaker),


# supervisor
url(r'^supervisor/lodge/$', views.supervisorlodge),
# url(r'^supervisor/lodge/$', views.supervisorlodge),
url(r'^supervisor/$', views.supervisor),
url(r'^supervisor/feedback/(?P<feedcomp_id>[0-9]+)/$', views.feedback_super),
url(r'^supervisor/caretaker_id_know_more/(?P<caretaker_id>[0-9]+)/$', views.caretaker_id_know_more),
# url(r'^supervisor/caretaker_id_know_more/(?P<caretaker_id>[0-9]+)/$', views.caretaker_id_know_more),
# url(r'^supervisor/caretaker_id_know_more/(?P<caretaker_id>[0-9]+)/complaint_reassign_super/(?P<iid>[0-9]+)/$', views.complaint_reassign_super, name = 'complaint_reassign_super'),
url(r'^supervisor/detail/(?P<detailcomp_id1>[0-9]+)/$', views.detail3, name = 'detail3'),
url(r'^supervisor/pending/(?P<cid>[0-9]+)/$', views.resolvependingsuper),
url(r'^supervisor/(?P<complaint_id>[0-9]+)/$', views.submitfeedbacksuper),








# CRUD task
url(r'^caretaker/worker_id_know_more/(?P<work_id>[0-9]+)/removew/$', views.removew),
url(r'^caretaker/(?P<comp_id1>[0-9]+)/$', views.assign_worker,name='assign_worker'),
url(r'^caretaker/deletecomplaint/(?P<comp_id1>[0-9]+)/$', views.deletecomplaint),
url(r'^caretaker/(?P<comp_id1>[0-9]+)/$', views.redirect,name='assign_worker'),
# url(r'^caretaker/deletecomplaint/(?P<comp_id1>[0-9]+)/$', views.deletecomplaint),
# url(r'^caretaker/(?P<comp_id>[0-9]+)/$', views.assign_worker),
url(r'^caretaker/(?P<complaint_id>[0-9]+)/(?P<status>[0-9]+)/$', views.changestatus),
url(r'^supervisor/(?P<complaint_id>[0-9]+)/(?P<status>[0-9]+)/$', views.changestatussuper),
# url(r'^caretaker/(?P<complaint_id>[0-9]+)/(?P<status>[0-9]+)/$', views.changestatus),
# url(r'^supervisor/(?P<complaint_id>[0-9]+)/(?P<status>[0-9]+)/$', views.changestatussuper),

url(r'^api/',include('applications.complaint_system.api.urls'))

Expand Down
Loading
Loading