Modified APIs
This commit is contained in:
parent
d99c8ab5d9
commit
95fd24a776
|
@ -8,10 +8,7 @@ from django.utils.safestring import SafeText
|
||||||
from .models import *
|
from .models import *
|
||||||
|
|
||||||
admin.site.register(User)
|
admin.site.register(User)
|
||||||
# admin.site.register(Student)
|
|
||||||
admin.site.register(Admin)
|
admin.site.register(Admin)
|
||||||
# admin.site.register(Placement)
|
|
||||||
admin.site.register(PlacementApplication)
|
|
||||||
admin.site.register(PrePlacementOffer)
|
admin.site.register(PrePlacementOffer)
|
||||||
|
|
||||||
admin.site.site_header = "CDC Recruitment Portal"
|
admin.site.site_header = "CDC Recruitment Portal"
|
||||||
|
@ -38,4 +35,17 @@ class Placement(admin.ModelAdmin):
|
||||||
list_filter = ('tier',)
|
list_filter = ('tier',)
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(PlacementApplication)
|
||||||
|
class PlacementApplication(admin.ModelAdmin):
|
||||||
|
list_display = ('id', 'Placement', 'Student', 'selected')
|
||||||
|
search_fields = ('id',)
|
||||||
|
ordering = ('id',)
|
||||||
|
list_filter = ('selected',)
|
||||||
|
|
||||||
|
def Placement(self, obj):
|
||||||
|
return model_admin_url(obj.placement)
|
||||||
|
|
||||||
|
def Student(self, obj):
|
||||||
|
return model_admin_url(obj.student)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -53,13 +53,15 @@ def markStatus(request, id, email, user_type):
|
||||||
def getDashboard(request, id, email, user_type):
|
def getDashboard(request, id, email, user_type):
|
||||||
try:
|
try:
|
||||||
placements = Placement.objects.all().order_by('-created_at')
|
placements = Placement.objects.all().order_by('-created_at')
|
||||||
ongoing = placements.filter(deadline_datetime__gt=datetime.now())
|
ongoing = placements.filter(deadline_datetime__gt=datetime.now(), offer_accepted__isnull=False)
|
||||||
previous = placements.exclude(deadline_datetime__gt=datetime.now())
|
previous = placements.exclude(deadline_datetime__gt=datetime.now()).filter(offer_accepted__isnull=False)
|
||||||
|
new = placements.filter(offer_accepted__isnull=True)
|
||||||
ongoing = PlacementSerializerForAdmin(ongoing, many=True).data
|
ongoing = PlacementSerializerForAdmin(ongoing, many=True).data
|
||||||
previous = PlacementSerializerForAdmin(previous, many=True).data
|
previous = PlacementSerializerForAdmin(previous, many=True).data
|
||||||
|
new = PlacementSerializerForAdmin(new, many=True).data
|
||||||
|
|
||||||
return Response(
|
return Response(
|
||||||
{'action': "Get Dashboard - Admin", 'message': "Data Found", "ongoing": ongoing, "previous": previous},
|
{'action': "Get Dashboard - Admin", 'message': "Data Found", "ongoing": ongoing, "previous": previous, "new": new},
|
||||||
status=status.HTTP_200_OK)
|
status=status.HTTP_200_OK)
|
||||||
except Http404:
|
except Http404:
|
||||||
return Response({'action': "Get Dashboard - Admin", 'message': 'Student Not Found'},
|
return Response({'action': "Get Dashboard - Admin", 'message': 'Student Not Found'},
|
||||||
|
|
|
@ -193,6 +193,8 @@ def addPlacement(request):
|
||||||
# Check if tentative_no_of_offers is integer
|
# Check if tentative_no_of_offers is integer
|
||||||
if data[TENTATIVE_NO_OF_OFFERS].isdigit():
|
if data[TENTATIVE_NO_OF_OFFERS].isdigit():
|
||||||
opening.tentative_no_of_offers = int(data[TENTATIVE_NO_OF_OFFERS])
|
opening.tentative_no_of_offers = int(data[TENTATIVE_NO_OF_OFFERS])
|
||||||
|
elif data[TENTATIVE_NO_OF_OFFERS] == 'null':
|
||||||
|
opening.tentative_no_of_offers = None
|
||||||
else:
|
else:
|
||||||
raise ValueError('Tentative No Of Offers must be an integer')
|
raise ValueError('Tentative No Of Offers must be an integer')
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,9 @@ class Student(models.Model):
|
||||||
resumes = ArrayField(models.CharField(null=True, default=None, max_length=100), size=10, default=list, blank=True)
|
resumes = ArrayField(models.CharField(null=True, default=None, max_length=100), size=10, default=list, blank=True)
|
||||||
cpi = models.DecimalField(decimal_places=2, max_digits=4)
|
cpi = models.DecimalField(decimal_places=2, max_digits=4)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return str(self.roll_no)
|
||||||
|
|
||||||
|
|
||||||
class Admin(models.Model):
|
class Admin(models.Model):
|
||||||
id = models.CharField(blank=False, max_length=15, primary_key=True)
|
id = models.CharField(blank=False, max_length=15, primary_key=True)
|
||||||
|
@ -81,7 +84,7 @@ class Placement(models.Model):
|
||||||
size=TOTAL_BRANCHES,
|
size=TOTAL_BRANCHES,
|
||||||
default=list
|
default=list
|
||||||
)
|
)
|
||||||
tentative_no_of_offers = models.IntegerField(blank=False, default=1)
|
tentative_no_of_offers = models.IntegerField(blank=False, default=None, null=True)
|
||||||
other_requirements = models.CharField(blank=True, max_length=200, default="")
|
other_requirements = models.CharField(blank=True, max_length=200, default="")
|
||||||
additional_info = ArrayField(models.CharField(blank=True, max_length=200), size=15, default=list, blank=True)
|
additional_info = ArrayField(models.CharField(blank=True, max_length=200), size=15, default=list, blank=True)
|
||||||
email_verified = models.BooleanField(blank=False, default=False)
|
email_verified = models.BooleanField(blank=False, default=False)
|
||||||
|
@ -96,6 +99,9 @@ class Placement(models.Model):
|
||||||
|
|
||||||
return super(Placement, self).save(*args, **kwargs)
|
return super(Placement, self).save(*args, **kwargs)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.company_name + " - " + self.id
|
||||||
|
|
||||||
class PlacementApplication(models.Model):
|
class PlacementApplication(models.Model):
|
||||||
id = models.CharField(blank=False, primary_key=True, max_length=15)
|
id = models.CharField(blank=False, primary_key=True, max_length=15)
|
||||||
placement = models.ForeignKey(Placement, blank=False, on_delete=models.RESTRICT, default=None, null=True)
|
placement = models.ForeignKey(Placement, blank=False, on_delete=models.RESTRICT, default=None, null=True)
|
||||||
|
@ -116,6 +122,9 @@ class PlacementApplication(models.Model):
|
||||||
verbose_name_plural = "Placement Applications"
|
verbose_name_plural = "Placement Applications"
|
||||||
unique_together = ('placement_id', 'student_id')
|
unique_together = ('placement_id', 'student_id')
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.placement.company_name + " - " + self.student.name
|
||||||
|
|
||||||
|
|
||||||
class PrePlacementOffer(models.Model):
|
class PrePlacementOffer(models.Model):
|
||||||
id = models.AutoField(primary_key=True)
|
id = models.AutoField(primary_key=True)
|
||||||
|
|
|
@ -154,8 +154,11 @@ class PlacementApplicationSerializer(serializers.ModelSerializer):
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def get_resume_link(self, obj):
|
def get_resume_link(self, obj):
|
||||||
link = LINK_TO_STORAGE_RESUME + urllib.parse.quote_plus(obj.id + "/" + obj.resume)
|
ele = {}
|
||||||
return link
|
ele['link'] = LINK_TO_STORAGE_RESUME + urllib.parse.quote_plus(obj.id + "/" + obj.resume)
|
||||||
|
ele['name'] = obj.resume
|
||||||
|
return ele
|
||||||
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = PlacementApplication
|
model = PlacementApplication
|
||||||
|
|
|
@ -44,7 +44,7 @@ def addResume(request, id, email, user_type):
|
||||||
files = request.FILES
|
files = request.FILES
|
||||||
|
|
||||||
file = files['file']
|
file = files['file']
|
||||||
destination_path = STORAGE_DESTINATION_RESUMES + id + "/"
|
destination_path = STORAGE_DESTINATION_RESUMES + str(student.roll_no) + "/"
|
||||||
file_name = saveFile(file, destination_path)
|
file_name = saveFile(file, destination_path)
|
||||||
student.resumes.append(file_name)
|
student.resumes.append(file_name)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
|
import re
|
||||||
import string
|
import string
|
||||||
import sys
|
import sys
|
||||||
from os import path, remove
|
from os import path, remove
|
||||||
|
@ -113,8 +114,10 @@ def saveFile(file, location):
|
||||||
prefix = generateRandomString()
|
prefix = generateRandomString()
|
||||||
file_name = prefix + "_" + file.name
|
file_name = prefix + "_" + file.name
|
||||||
|
|
||||||
|
file_name = re.sub(r'[\\/:*?"<>|]', '_', file_name)
|
||||||
|
|
||||||
if not path.isdir(location):
|
if not path.isdir(location):
|
||||||
os.mkdir(location)
|
os.makedirs(location)
|
||||||
|
|
||||||
destination_path = location + str(file_name)
|
destination_path = location + str(file_name)
|
||||||
if path.exists(destination_path):
|
if path.exists(destination_path):
|
||||||
|
@ -123,7 +126,6 @@ def saveFile(file, location):
|
||||||
with open(destination_path, 'wb+') as destination:
|
with open(destination_path, 'wb+') as destination:
|
||||||
for chunk in file.chunks():
|
for chunk in file.chunks():
|
||||||
destination.write(chunk)
|
destination.write(chunk)
|
||||||
|
|
||||||
return file_name
|
return file_name
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -83,23 +83,23 @@ WSGI_APPLICATION = 'CDC_Backend.wsgi.application'
|
||||||
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
|
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
|
||||||
|
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
|
||||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
|
||||||
'NAME': os.environ.get("DB_NAME"),
|
|
||||||
'USER': os.environ.get("DB_USER"),
|
|
||||||
'PASSWORD': os.environ.get("DB_PASSWORD"),
|
|
||||||
'HOST': os.environ.get("DB_HOST"),
|
|
||||||
'PORT': os.environ.get("DB_PORT"),
|
|
||||||
},
|
|
||||||
|
|
||||||
# 'default': {
|
# 'default': {
|
||||||
# 'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
# 'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||||
# 'NAME': 'd84i5cbjig5rrf',
|
# 'NAME': os.environ.get("DB_NAME"),
|
||||||
# 'USER': 'hbkullcdjbxuwh',
|
# 'USER': os.environ.get("DB_USER"),
|
||||||
# 'PASSWORD': '45d990da00e2cc96d7d4e2e5e308d4b07a387883f70c40e090a6252175cb634e',
|
# 'PASSWORD': os.environ.get("DB_PASSWORD"),
|
||||||
# 'HOST': 'ec2-54-163-97-228.compute-1.amazonaws.com',
|
# 'HOST': os.environ.get("DB_HOST"),
|
||||||
# 'PORT': '5432',
|
# 'PORT': os.environ.get("DB_PORT"),
|
||||||
# }
|
# },
|
||||||
|
|
||||||
|
'default': {
|
||||||
|
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||||
|
'NAME': 'd84i5cbjig5rrf',
|
||||||
|
'USER': 'hbkullcdjbxuwh',
|
||||||
|
'PASSWORD': '45d990da00e2cc96d7d4e2e5e308d4b07a387883f70c40e090a6252175cb634e',
|
||||||
|
'HOST': 'ec2-54-163-97-228.compute-1.amazonaws.com',
|
||||||
|
'PORT': '5432',
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Password validation
|
# Password validation
|
||||||
|
|
Loading…
Reference in New Issue