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-1 HR Android API #1313

Open
wants to merge 5 commits into
base: gad-1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
405 changes: 0 additions & 405 deletions FusionIIIT/applications/academic_procedures/migrations/0001_initial.py

This file was deleted.

Empty file.
53 changes: 53 additions & 0 deletions FusionIIIT/applications/eis/migrations/0002_auto_20240217_1747.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Generated by Django 3.1.5 on 2024-02-17 17:47

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('eis', '0001_initial'),
]

operations = [
migrations.AlterField(
model_name='emp_achievement',
name='a_year',
field=models.IntegerField(blank=True, choices=[(1995, 1995), (1996, 1996), (1997, 1997), (1998, 1998), (1999, 1999), (2000, 2000), (2001, 2001), (2002, 2002), (2003, 2003), (2004, 2004), (2005, 2005), (2006, 2006), (2007, 2007), (2008, 2008), (2009, 2009), (2010, 2010), (2011, 2011), (2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016), (2017, 2017), (2018, 2018), (2019, 2019), (2020, 2020), (2021, 2021), (2022, 2022), (2023, 2023), (2024, 2024)], null=True, verbose_name='year'),
),
migrations.AlterField(
model_name='emp_confrence_organised',
name='k_year',
field=models.IntegerField(blank=True, choices=[(1995, 1995), (1996, 1996), (1997, 1997), (1998, 1998), (1999, 1999), (2000, 2000), (2001, 2001), (2002, 2002), (2003, 2003), (2004, 2004), (2005, 2005), (2006, 2006), (2007, 2007), (2008, 2008), (2009, 2009), (2010, 2010), (2011, 2011), (2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016), (2017, 2017), (2018, 2018), (2019, 2019), (2020, 2020), (2021, 2021), (2022, 2022), (2023, 2023), (2024, 2024)], null=True, verbose_name='year'),
),
migrations.AlterField(
model_name='emp_expert_lectures',
name='l_year',
field=models.IntegerField(blank=True, choices=[(1995, 1995), (1996, 1996), (1997, 1997), (1998, 1998), (1999, 1999), (2000, 2000), (2001, 2001), (2002, 2002), (2003, 2003), (2004, 2004), (2005, 2005), (2006, 2006), (2007, 2007), (2008, 2008), (2009, 2009), (2010, 2010), (2011, 2011), (2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016), (2017, 2017), (2018, 2018), (2019, 2019), (2020, 2020), (2021, 2021), (2022, 2022), (2023, 2023), (2024, 2024)], null=True, verbose_name='year'),
),
migrations.AlterField(
model_name='emp_keynote_address',
name='k_year',
field=models.IntegerField(blank=True, choices=[(1995, 1995), (1996, 1996), (1997, 1997), (1998, 1998), (1999, 1999), (2000, 2000), (2001, 2001), (2002, 2002), (2003, 2003), (2004, 2004), (2005, 2005), (2006, 2006), (2007, 2007), (2008, 2008), (2009, 2009), (2010, 2010), (2011, 2011), (2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016), (2017, 2017), (2018, 2018), (2019, 2019), (2020, 2020), (2021, 2021), (2022, 2022), (2023, 2023), (2024, 2024)], null=True, verbose_name='year'),
),
migrations.AlterField(
model_name='emp_mtechphd_thesis',
name='s_year',
field=models.IntegerField(blank=True, choices=[(1995, 1995), (1996, 1996), (1997, 1997), (1998, 1998), (1999, 1999), (2000, 2000), (2001, 2001), (2002, 2002), (2003, 2003), (2004, 2004), (2005, 2005), (2006, 2006), (2007, 2007), (2008, 2008), (2009, 2009), (2010, 2010), (2011, 2011), (2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016), (2017, 2017), (2018, 2018), (2019, 2019), (2020, 2020), (2021, 2021), (2022, 2022), (2023, 2023), (2024, 2024)], null=True, verbose_name='year'),
),
migrations.AlterField(
model_name='emp_patents',
name='p_year',
field=models.IntegerField(blank=True, choices=[(1995, 1995), (1996, 1996), (1997, 1997), (1998, 1998), (1999, 1999), (2000, 2000), (2001, 2001), (2002, 2002), (2003, 2003), (2004, 2004), (2005, 2005), (2006, 2006), (2007, 2007), (2008, 2008), (2009, 2009), (2010, 2010), (2011, 2011), (2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016), (2017, 2017), (2018, 2018), (2019, 2019), (2020, 2020), (2021, 2021), (2022, 2022), (2023, 2023), (2024, 2024)], null=True, verbose_name='year'),
),
migrations.AlterField(
model_name='emp_published_books',
name='pyear',
field=models.IntegerField(blank=True, choices=[(1995, 1995), (1996, 1996), (1997, 1997), (1998, 1998), (1999, 1999), (2000, 2000), (2001, 2001), (2002, 2002), (2003, 2003), (2004, 2004), (2005, 2005), (2006, 2006), (2007, 2007), (2008, 2008), (2009, 2009), (2010, 2010), (2011, 2011), (2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016), (2017, 2017), (2018, 2018), (2019, 2019), (2020, 2020), (2021, 2021), (2022, 2022), (2023, 2023), (2024, 2024)], null=True, verbose_name='year'),
),
migrations.AlterField(
model_name='emp_research_papers',
name='year',
field=models.CharField(blank=True, choices=[(1995, 1995), (1996, 1996), (1997, 1997), (1998, 1998), (1999, 1999), (2000, 2000), (2001, 2001), (2002, 2002), (2003, 2003), (2004, 2004), (2005, 2005), (2006, 2006), (2007, 2007), (2008, 2008), (2009, 2009), (2010, 2010), (2011, 2011), (2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016), (2017, 2017), (2018, 2018), (2019, 2019), (2020, 2020), (2021, 2021), (2022, 2022), (2023, 2023), (2024, 2024)], max_length=10, null=True),
),
]
24 changes: 24 additions & 0 deletions FusionIIIT/applications/filetracking/api/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from applications.filetracking.models import File, Tracking
from django.core.files import File as DjangoFile
from rest_framework import serializers


class FileSerializer(serializers.ModelSerializer):
class Meta:
model = File
fields = '__all__'


class TrackingSerializer(serializers.ModelSerializer):
class Meta:
model = Tracking
fields = '__all__'


class FileHeaderSerializer(serializers.ModelSerializer):
'''
This serializes everything except the attachments of a file and whether it is read or not
'''
class Meta:
model = File
exclude = ['upload_file', 'is_read']
22 changes: 22 additions & 0 deletions FusionIIIT/applications/filetracking/api/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from django.conf.urls import url
from .views import (
CreateFileView,
ViewFileView,
DeleteFileView,
ViewInboxView,
ViewOutboxView,
ViewHistoryView,
ForwardFileView,
GetDesignationsView,
)

urlpatterns = [
url(r'^file/$', CreateFileView.as_view(), name='create_file'),
url(r'^file/(?P<file_id>\d+)/$', ViewFileView.as_view(), name='view_file'),
url(r'^file/(?P<file_id>\d+)/$', DeleteFileView.as_view(), name='delete_file'),
url(r'^inbox/$', ViewInboxView.as_view(), name='view_inbox'),
url(r'^outbox/$', ViewOutboxView.as_view(), name='view_outbox'),
url(r'^history/(?P<file_id>\d+)/$', ViewHistoryView.as_view(), name='view_history'),
url(r'^file/(?P<file_id>\d+)/$', ForwardFileView.as_view(), name='forward_file'),
url(r'^designations/(?P<username>\w+)/$', GetDesignationsView.as_view(), name='get_designations'),
]
89 changes: 89 additions & 0 deletions FusionIIIT/applications/filetracking/api/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework import status, permissions
from rest_framework.authentication import TokenAuthentication
from ..sdk.methods import create_file, view_file, delete_file, view_inbox, view_outbox, view_history, forward_file, get_designations


class CreateFileView(APIView):
#authentication_classes = [TokenAuthentication]
#permission_classes = [permissions.IsAuthenticated]

def post(self, request, *args, **kwargs):
file_id = create_file(**request.data)
return Response({'file_id': file_id}, status=status.HTTP_201_CREATED)


class ViewFileView(APIView):
#authentication_classes = [TokenAuthentication]
#permission_classes = [permissions.IsAuthenticated]

def get(self, request, file_id, *args, **kwargs):
file_details = view_file(int(file_id))
return Response(file_details)


class DeleteFileView(APIView):
#authentication_classes = [TokenAuthentication]
#permission_classes = [permissions.IsAuthenticated]

def delete(self, request, file_id, *args, **kwargs):
success = delete_file(int(file_id))
if success:
return Response({'message': 'File deleted successfully'},
status=status.HTTP_204_NO_CONTENT)
else:
return Response({'error': 'File not found'},
status=status.HTTP_404_NOT_FOUND)


class ViewInboxView(APIView):
#authentication_classes = [TokenAuthentication]
#permission_classes = [permissions.IsAuthenticated]

def get(self, request, *args, **kwargs):
inbox_files = view_inbox(
request.user.username,
request.query_params.get('designation'),
request.query_params.get('src_module'))
return Response(inbox_files)


class ViewOutboxView(APIView):
#authentication_classes = [TokenAuthentication]
#permission_classes = [permissions.IsAuthenticated]

def get(self, request, *args, **kwargs):
outbox_files = view_outbox(
request.user.username,
request.query_params.get('designation'),
request.query_params.get('src_module'))
return Response(outbox_files)


class ViewHistoryView(APIView):
#authentication_classes = [TokenAuthentication]
#permission_classes = [permissions.IsAuthenticated]

def get(self, request, file_id, *args, **kwargs):
history = view_history(int(file_id))
return Response(history)


class ForwardFileView(APIView):
#authentication_classes = [TokenAuthentication]
#permission_classes = [permissions.IsAuthenticated]

def post(self, request, file_id, *args, **kwargs):
new_tracking_id = forward_file(int(file_id), **request.data)
return Response({'tracking_id': new_tracking_id},
status=status.HTTP_201_CREATED)


class GetDesignationsView(APIView):
#authentication_classes = [TokenAuthentication]
#permission_classes = [permissions.IsAuthenticated]

def get(self, request, username, *args, **kwargs):
user_designations = get_designations(username)
return Response({'designations': user_designations})
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 3.1.5 on 2024-01-30 14:35

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('filetracking', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='file',
name='file_extra_JSON',
field=models.JSONField(null=True),
),
migrations.AddField(
model_name='file',
name='src_module',
field=models.CharField(default='filetracking', max_length=100),
),
migrations.AddField(
model_name='file',
name='src_object_id',
field=models.CharField(max_length=100, null=True),
),
migrations.AddField(
model_name='tracking',
name='tracking_extra_JSON',
field=models.JSONField(null=True),
),
]
12 changes: 10 additions & 2 deletions FusionIIIT/applications/filetracking/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ class File(models.Model):
is_read = models.BooleanField(default = False)


# additions for API
src_module = models.CharField(max_length=100, default='filetracking')
src_object_id = models.CharField(max_length=100,null=True)
file_extra_JSON = models.JSONField(null=True)

class Meta:
db_table = 'File'

Expand All @@ -25,12 +30,12 @@ class Meta:

class Tracking(models.Model):
"""
This is File Tracing Table which contains the status of each indivisual file created by the user
This is File Tracing Table which contains the status of each individual file created by the user
"""
file_id = models.ForeignKey(File, on_delete=models.CASCADE, null=True)
current_id = models.ForeignKey(ExtraInfo, on_delete=models.CASCADE)
current_design = models.ForeignKey(HoldsDesignation, null=True, on_delete=models.CASCADE)
# receiver_id = models.ForeignKey(ExtraInfo, on_delete=models.CASCADE, related_name='receiver_id')
# receiver_id = models.ForeignKey(ExtraInfo, on_delete=models.CASCADE, related_name='receiver_id')
# receive_design = models.ForeignKey(HoldsDesignation, null=True, on_delete=models.CASCADE, related_name='rec_design')
receiver_id = models.ForeignKey(User,null = True, on_delete=models.CASCADE, related_name='receiver_id')
receive_design = models.ForeignKey(Designation, null=True, on_delete=models.CASCADE, related_name='rec_design')
Expand All @@ -41,5 +46,8 @@ class Tracking(models.Model):
upload_file = models.FileField(blank=True)
is_read = models.BooleanField(default = False)

# additions for API
tracking_extra_JSON = models.JSONField(null=True)

class Meta:
db_table = 'Tracking'
Loading