Skip to content

Commit

Permalink
backend creation
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruv2185 committed Feb 24, 2024
1 parent 1c87004 commit c91f5bf
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 91 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.1.5 on 2024-02-23 01:12

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('globals', '0003_auto_20240220_0200'),
]

operations = [
migrations.AlterField(
model_name='extrainfo',
name='user_status',
field=models.CharField(choices=[('NEW', 'NEW'), ('PRESENT', 'PRESENT')], default='PRESENT', max_length=50),
),
]
5 changes: 3 additions & 2 deletions FusionIIIT/applications/hr2/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.contrib import admin

from .models import Employee,EmpConfidentialDetails,ForeignService,EmpDependents,EmpAppraisalForm,WorkAssignemnt, LTCform
from .models import Employee, EmpConfidentialDetails, ForeignService, EmpDependents, EmpAppraisalForm, WorkAssignemnt, LTCform, CPDAAdvanceform

# Register your models here.

Expand All @@ -10,4 +10,5 @@
admin.site.register(ForeignService)
admin.site.register(EmpAppraisalForm)
admin.site.register(WorkAssignemnt)
admin.site.register(LTCform)
admin.site.register(LTCform)
admin.site.register(CPDAAdvanceform)
199 changes: 112 additions & 87 deletions FusionIIIT/applications/hr2/form_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,205 +10,230 @@
from applications.filetracking.sdk.methods import *
from applications.globals.models import Designation, HoldsDesignation


class LTC(APIView):
serializer_class = LTC_serializer
permission_classes = (AllowAny, )

def post(self, request):
user_info = request.data[0]
serializer = self.serializer_class(data = request.data[1])
serializer = self.serializer_class(data=request.data[1])
if serializer.is_valid():
serializer.save()
file_id = create_file(uploader = user_info['uploader_name'], uploader_designation = user_info['uploader_designation'], receiver = "21BCS140", receiver_designation="hradmin", src_module="HR", src_object_id= str(serializer.data['id']), file_extra_JSON= {"type": "LTC"}, attached_file= None)
return Response(serializer.data, status= status.HTTP_200_OK)
file_id = create_file(uploader=user_info['uploader_name'], uploader_designation=user_info['uploader_designation'], receiver="21BCS140",
receiver_designation="hradmin", src_module="HR", src_object_id=str(serializer.data['id']), file_extra_JSON={"type": "LTC"}, attached_file=None)
return Response(serializer.data, status=status.HTTP_200_OK)
else:
return Response(serializer.errors, status= status.HTTP_400_BAD_REQUEST)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)

def get(self, request, *args, **kwargs):
pk = request.query_params.get("name")
print(pk)
try:
forms = LTCform.objects.get(name = pk)
serializer = self.serializer_class(forms, many = False)
try:
forms = LTCform.objects.get(name=pk)
serializer = self.serializer_class(forms, many=False)
except MultipleObjectsReturned:
forms = LTCform.objects.filter(name = pk)
serializer = self.serializer_class(forms, many = True)
return Response(serializer.data, status = status.HTTP_200_OK)

forms = LTCform.objects.filter(name=pk)
serializer = self.serializer_class(forms, many=True)
except LTCform.DoesNotExist:
return Response(status=status.HTTP_404_NOT_FOUND)
return Response(serializer.data, status=status.HTTP_200_OK)

def put(self, request, *args, **kwargs):
pk = request.query_params.get("id")
print(pk)
form = LTCform.objects.get(id = pk)
form = LTCform.objects.get(id=pk)
print(form)
serializer = self.serializer_class(form, data = request.data)
serializer = self.serializer_class(form, 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_200_OK)
else:
return Response(serializer.errors, status = status.HTTP_400_BAD_REQUEST)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)


class FormManagement(APIView):
permission_classes = (AllowAny, )

def get(self, request, *args, **kwargs):
username = request.query_params.get("username")
designation = request.query_params.get("designation")
inbox = view_inbox(username = username, designation = designation, src_module = "HR")
return Response(inbox, status = status.HTTP_200_OK)

inbox = view_inbox(username=username,
designation=designation, src_module="HR")
return Response(inbox, status=status.HTTP_200_OK)

def post(self, request, *args, **kwargs):
username = request.data['receiver']
receiver_value = User.objects.get(username=username)
receiver_value_designation= HoldsDesignation.objects.filter(user=receiver_value)
receiver_value_designation = HoldsDesignation.objects.filter(
user=receiver_value)
lis = list(receiver_value_designation)
obj=lis[0].designation
forward_file(file_id = request.data['file_id'], receiver = request.data['receiver'], receiver_designation = obj.name, remarks = request.data['remarks'], file_extra_JSON = request.data['file_extra_JSON'])
return Response(status = status.HTTP_200_OK)
obj = lis[0].designation
forward_file(file_id=request.data['file_id'], receiver=request.data['receiver'], receiver_designation=obj.name,
remarks=request.data['remarks'], file_extra_JSON=request.data['file_extra_JSON'])
return Response(status=status.HTTP_200_OK)


class CPDAAdvance(APIView):
serializer_class = CPDAAdvance_serializer
permission_classes = (AllowAny, )

def post(self, request):
user_info = request.data[0]
serializer = self.serializer_class(data = request.data[1])
print(request.data[1])
user_info = request.data[1]
serializer = self.serializer_class(data=request.data[0])
if serializer.is_valid():
serializer.save()
file_id = create_file(uploader = user_info['uploader_name'], uploader_designation = user_info['uploader_designation'], receiver = "vkjain", receiver_designation="CSE HOD", src_module="HR", src_object_id= str(serializer.data['id']), file_extra_JSON= {"type": "CPDAAdvance"}, attached_file= None)
return Response(serializer.data, status= status.HTTP_200_OK)
file_id = create_file(uploader=user_info['uploader_name'], uploader_designation=user_info['uploader_designation'], receiver="21BCS077",
receiver_designation="student", src_module="HR", src_object_id=str(serializer.data['id']), file_extra_JSON={"type": "CPDAAdvance"}, attached_file=None)
return Response(serializer.data, status=status.HTTP_200_OK)
else:
return Response(serializer.errors, status= status.HTTP_400_BAD_REQUEST)
print(serializer.errors)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)

def get(self, request, *args, **kwargs):
pk = request.query_params.get("name")
pk = request.query_params.get("id")
print(pk)
try:
forms = CPDAAdvanceform.objects.get(name = pk)
serializer = self.serializer_class(forms, many = False)
try:
forms = CPDAAdvanceform.objects.get(id=pk)
serializer = self.serializer_class(forms, many=False)
except MultipleObjectsReturned:
forms = CPDAAdvanceform.objects.filter(name = pk)
serializer = self.serializer_class(forms, many = True)
return Response(serializer.data, status = status.HTTP_200_OK)
forms = CPDAAdvanceform.objects.filter(id=pk)
serializer = self.serializer_class(forms, many=True)
return Response(serializer.data, status=status.HTTP_200_OK)

def put(self, request, *args, **kwargs):
pk = request.query_params.get("id")
print(pk)
form = CPDAAdvanceform.objects.get(id = pk)
form = CPDAAdvanceform.objects.get(id=pk)
print(form)
serializer = self.serializer_class(form, data = request.data)
serializer = self.serializer_class(form, 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_200_OK)
else:
return Response(serializer.errors, status = status.HTTP_400_BAD_REQUEST)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)


class CPDAReimbursement(APIView):
serializer_class = CPDAReimbursement_serializer
permission_classes = (AllowAny, )

def post(self, request):
user_info = request.data[0]
serializer = self.serializer_class(data = request.data[1])
serializer = self.serializer_class(data=request.data[1])
if serializer.is_valid():
serializer.save()
file_id = create_file(uploader = user_info['uploader_name'], uploader_designation = user_info['uploader_designation'], receiver = "vkjain", receiver_designation="CSE HOD", src_module="HR", src_object_id= str(serializer.data['id']), file_extra_JSON= {"type": "CPDAReimbursement"}, attached_file= None)
return Response(serializer.data, status= status.HTTP_200_OK)
file_id = create_file(uploader=user_info['uploader_name'], uploader_designation=user_info['uploader_designation'], receiver="vkjain",
receiver_designation="CSE HOD", src_module="HR", src_object_id=str(serializer.data['id']), file_extra_JSON={"type": "CPDAReimbursement"}, attached_file=None)
return Response(serializer.data, status=status.HTTP_200_OK)
else:
return Response(serializer.errors, status= status.HTTP_400_BAD_REQUEST)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)

def get(self, request, *args, **kwargs):
pk = request.query_params.get("name")
print(pk)
try:
forms = CPDAReimbursementform.objects.get(name = pk)
serializer = self.serializer_class(forms, many = False)
try:
forms = CPDAReimbursementform.objects.get(name=pk)
serializer = self.serializer_class(forms, many=False)
except MultipleObjectsReturned:
forms = CPDAReimbursementform.objects.filter(name = pk)
serializer = self.serializer_class(forms, many = True)
return Response(serializer.data, status = status.HTTP_200_OK)
forms = CPDAReimbursementform.objects.filter(name=pk)
serializer = self.serializer_class(forms, many=True)
return Response(serializer.data, status=status.HTTP_200_OK)

def put(self, request, *args, **kwargs):
pk = request.query_params.get("id")
print(pk)
form = CPDAReimbursementform.objects.get(id = pk)
form = CPDAReimbursementform.objects.get(id=pk)
print(form)
serializer = self.serializer_class(form, data = request.data)
serializer = self.serializer_class(form, 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_200_OK)
else:
return Response(serializer.errors, status = status.HTTP_400_BAD_REQUEST)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)


class Leave(APIView):
serializer_class = Leave_serializer
permission_classes = (AllowAny, )

def post(self, request):
user_info = request.data[0]
serializer = self.serializer_class(data = request.data[1])
serializer = self.serializer_class(data=request.data[1])
if serializer.is_valid():
serializer.save()
file_id = create_file(uploader = user_info['uploader_name'], uploader_designation = user_info['uploader_designation'], receiver = "vkjain", receiver_designation="CSE HOD", src_module="HR", src_object_id= str(serializer.data['id']), file_extra_JSON= {"type": "Leave"}, attached_file= None)
return Response(serializer.data, status= status.HTTP_200_OK)
file_id = create_file(uploader=user_info['uploader_name'], uploader_designation=user_info['uploader_designation'], receiver="vkjain",
receiver_designation="CSE HOD", src_module="HR", src_object_id=str(serializer.data['id']), file_extra_JSON={"type": "Leave"}, attached_file=None)
return Response(serializer.data, status=status.HTTP_200_OK)
else:
return Response(serializer.errors, status= status.HTTP_400_BAD_REQUEST)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)

def get(self, request, *args, **kwargs):
pk = request.query_params.get("name")
print(pk)
try:
forms = Leaveform.objects.get(name = pk)
serializer = self.serializer_class(forms, many = False)
try:
forms = Leaveform.objects.get(name=pk)
serializer = self.serializer_class(forms, many=False)
except MultipleObjectsReturned:
forms = Leaveform.objects.filter(name = pk)
serializer = self.serializer_class(forms, many = True)
return Response(serializer.data, status = status.HTTP_200_OK)
forms = Leaveform.objects.filter(name=pk)
serializer = self.serializer_class(forms, many=True)
return Response(serializer.data, status=status.HTTP_200_OK)

def put(self, request, *args, **kwargs):
pk = request.query_params.get("id")
print(pk)
form = Leaveform.objects.get(id = pk)
form = Leaveform.objects.get(id=pk)
print(form)
serializer = self.serializer_class(form, data = request.data)
serializer = self.serializer_class(form, 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_200_OK)
else:
return Response(serializer.errors, status = status.HTTP_400_BAD_REQUEST)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)


class Appraisal(APIView):
serializer_class = Appraisal_serializer
permission_classes = (AllowAny, )

def post(self, request):
user_info = request.data[0]
serializer = self.serializer_class(data = request.data[1])
serializer = self.serializer_class(data=request.data[1])
if serializer.is_valid():
serializer.save()
file_id = create_file(uploader = user_info['uploader_name'], uploader_designation = user_info['uploader_designation'], receiver = "vkjain", receiver_designation="CSE HOD", src_module="HR", src_object_id= str(serializer.data['id']), file_extra_JSON= {"type": "Appraisal"}, attached_file= None)
return Response(serializer.data, status= status.HTTP_200_OK)
file_id = create_file(uploader=user_info['uploader_name'], uploader_designation=user_info['uploader_designation'], receiver="vkjain",
receiver_designation="CSE HOD", src_module="HR", src_object_id=str(serializer.data['id']), file_extra_JSON={"type": "Appraisal"}, attached_file=None)
return Response(serializer.data, status=status.HTTP_200_OK)
else:
return Response(serializer.errors, status= status.HTTP_400_BAD_REQUEST)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)

def get(self, request, *args, **kwargs):
pk = request.query_params.get("name")
print(pk)
try:
forms = Appraisalform.objects.get(name = pk)
serializer = self.serializer_class(forms, many = False)
try:
forms = Appraisalform.objects.get(name=pk)
serializer = self.serializer_class(forms, many=False)
except MultipleObjectsReturned:
forms = Appraisalform.objects.filter(name = pk)
serializer = self.serializer_class(forms, many = True)
return Response(serializer.data, status = status.HTTP_200_OK)
forms = Appraisalform.objects.filter(name=pk)
serializer = self.serializer_class(forms, many=True)
return Response(serializer.data, status=status.HTTP_200_OK)

def put(self, request, *args, **kwargs):
pk = request.query_params.get("id")
print(pk)
form = Appraisalform.objects.get(id = pk)
form = Appraisalform.objects.get(id=pk)
print(form)
serializer = self.serializer_class(form, data = request.data)
serializer = self.serializer_class(form, 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_200_OK)
else:
return Response(serializer.errors, status = status.HTTP_400_BAD_REQUEST)

return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)


class AssignerReviewer(APIView):
def post(self, request, *args, **kwargs):
forward_file(file_id = request.data['file_id'], receiver = "21BCS140", receiver_designation = 'hradmin', remarks = request.data['remarks'], file_extra_JSON = request.data['file_extra_JSON'])
return Response(status = status.HTTP_200_OK)
forward_file(file_id=request.data['file_id'], receiver="21BCS140", receiver_designation='hradmin',
remarks=request.data['remarks'], file_extra_JSON=request.data['file_extra_JSON'])
return Response(status=status.HTTP_200_OK)
5 changes: 3 additions & 2 deletions FusionIIIT/applications/hr2/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
app_name = 'hr2'

urlpatterns = [
url('ltc/', form_views.LTC.as_view(), name = 'LTC_form'),
url('formManagement/', form_views.FormManagement.as_view(), name = 'formManagement'),
url('ltc/', form_views.LTC.as_view(), name='LTC_form'),
url('formManagement/', form_views.FormManagement.as_view(), name='formManagement'),
url('cpdaadv/', form_views.CPDAAdvance.as_view(), name='CPDAAdvance_form'),
# url(r'^$', views.service_book, name='hr2'),
# url(r'^hradmin/$', views.hr_admin, name='hradmin'),
# url(r'^edit/(?P<id>\d+)/$', views.edit_employee_details,
Expand Down
Binary file added fusionlab_backup_New.sql
Binary file not shown.

0 comments on commit c91f5bf

Please sign in to comment.