diff --git a/CDC_Backend/APIs/admin.py b/CDC_Backend/APIs/admin.py
index 3f5bb08..e2a87c3 100644
--- a/CDC_Backend/APIs/admin.py
+++ b/CDC_Backend/APIs/admin.py
@@ -1,17 +1,14 @@
from django.contrib import admin
-from .models import *
-from django.contrib import admin
from django.contrib.admin.templatetags.admin_urls import admin_urlname
from django.shortcuts import resolve_url
from django.utils.html import format_html
from django.utils.safestring import SafeText
+
from .models import *
admin.site.register(User)
admin.site.register(Admin)
-
-
admin.site.site_header = "CDC Recruitment Portal"
@@ -22,10 +19,21 @@ def model_admin_url(obj, name=None) -> str:
@admin.register(Student)
class Student(admin.ModelAdmin):
- list_display = ("roll_no", "name", "batch", "branch", "phone_number")
- search_fields = ("roll_no", "name","phone_number")
+ list_display = ("roll_no", "name", "batch", "branch", "phone_number", 'can_apply')
+ search_fields = ("roll_no", "name", "phone_number")
ordering = ("roll_no", "name", "batch", "branch", "phone_number")
list_filter = ("batch", "branch")
+ actions = ['mark_can_apply_as_no', 'mark_can_apply_as_yes']
+
+ @admin.action(description="Deregister students")
+ def mark_can_apply_as_no(self, request, queryset):
+ queryset.update(can_apply=False)
+ self.message_user(request, "Deregistered the users")
+
+ @admin.action(description="Register students")
+ def mark_can_apply_as_yes(self, request, queryset):
+ queryset.update(can_apply=True)
+ self.message_user(request, "Registered the users")
@admin.register(Placement)
@@ -52,11 +60,10 @@ class PlacementApplication(admin.ModelAdmin):
@admin.register(PrePlacementOffer)
class PrePlacementOffer(admin.ModelAdmin):
- list_display = ('company', 'Student', 'accepted')
+ list_display = ('company', 'Student', 'accepted')
search_fields = ('company',)
ordering = ('company',)
list_filter = ('accepted',)
def Student(self, obj):
return model_admin_url(obj.student)
-
diff --git a/CDC_Backend/APIs/adminUrls.py b/CDC_Backend/APIs/adminUrls.py
index d99c3e6..71d0073 100644
--- a/CDC_Backend/APIs/adminUrls.py
+++ b/CDC_Backend/APIs/adminUrls.py
@@ -1,6 +1,6 @@
from django.urls import path
-from . import adminViews
+from . import adminViews
urlpatterns = [
path('markStatus/', adminViews.markStatus, name="Mark Status"),
diff --git a/CDC_Backend/APIs/adminViews.py b/CDC_Backend/APIs/adminViews.py
index 4aeae91..e01d26e 100644
--- a/CDC_Backend/APIs/adminViews.py
+++ b/CDC_Backend/APIs/adminViews.py
@@ -1,5 +1,4 @@
import csv
-import json
from rest_framework.decorators import api_view
@@ -306,6 +305,7 @@ def generateCSV(request, id, email, user_type):
return Response({'action': "Create csv", 'message': "Error Occurred"},
status=status.HTTP_400_BAD_REQUEST)
+
@api_view(['POST'])
@isAuthorized(allowed_users=[ADMIN])
@precheck(required_data=[COMPANY_NAME, COMPENSATION_GROSS, OFFER_ACCEPTED, STUDENT_ID, DESIGNATION, TIER])
diff --git a/CDC_Backend/APIs/companyUrls.py b/CDC_Backend/APIs/companyUrls.py
index 525a585..4db1c55 100644
--- a/CDC_Backend/APIs/companyUrls.py
+++ b/CDC_Backend/APIs/companyUrls.py
@@ -1,6 +1,6 @@
from django.urls import path
-from . import companyViews
+from . import companyViews
urlpatterns = [
path('addPlacement/', companyViews.addPlacement, name="Add Placement"),
diff --git a/CDC_Backend/APIs/companyViews.py b/CDC_Backend/APIs/companyViews.py
index 503b6d3..6d4d041 100644
--- a/CDC_Backend/APIs/companyViews.py
+++ b/CDC_Backend/APIs/companyViews.py
@@ -1,7 +1,5 @@
from rest_framework.decorators import api_view
-from django.forms.models import model_to_dict
-from .models import *
from .utils import *
logger = logging.getLogger('db')
diff --git a/CDC_Backend/APIs/constants.py b/CDC_Backend/APIs/constants.py
index 33a9952..1a3b813 100644
--- a/CDC_Backend/APIs/constants.py
+++ b/CDC_Backend/APIs/constants.py
@@ -39,7 +39,7 @@ TOTAL_BATCHES = 4 # Total No of Batches
CLIENT_ID = "956830229554-290mirc16pdhd5j7ph7v7ukibo4t1qcp.apps.googleusercontent.com" # Google Login Client ID
# To be Configured Properly
-PLACEMENT_OPENING_URL = "https://www.googleapis.com/auth/adwords/{id}" # On frontend, this is the URL to be opened
+PLACEMENT_OPENING_URL = "https://www.googleapis.com/auth/adwords/{id}" # On frontend, this is the URL to be opened
LINK_TO_STORAGE_COMPANY_ATTACHMENT = "http://localhost/storage/Company_Attachments/"
LINK_TO_STORAGE_RESUME = "http://localhost/storage/Resumes/"
LINK_TO_APPLICATIONS_CSV = "http://localhost/storage/Application_CSV/"
@@ -54,8 +54,7 @@ TIER = 'tier'
# To be Configured Properly
FOURTH_YEAR = '2019'
MAX_OFFERS_PER_STUDENT = 2
-EMAIL_VERIFICATION_TOKEN_TTL = 48 # in hours
-
+EMAIL_VERIFICATION_TOKEN_TTL = 48 # in hours
STORAGE_DESTINATION_RESUMES = "./Storage/Resumes/"
STORAGE_DESTINATION_COMPANY_ATTACHMENTS = './Storage/Company_Attachments/'
@@ -88,7 +87,6 @@ STATE = 'state'
COUNTRY = 'country'
PINCODE = 'pincode'
-
DESIGNATION = 'designation'
DESCRIPTION = 'description'
DESCRIPTION_PDF = 'description_pdf'
@@ -123,7 +121,6 @@ STUDENT_LIST = "student_list"
STUDENT_ID = "student_id"
STUDENT_SELECTED = "student_selected"
-
COMPANY_OPENING_SUBMITTED_TEMPLATE_SUBJECT = "Notification Submitted - {id} - Career Development Cell, IIT Dharwad"
STUDENT_APPLICATION_STATUS_TEMPLATE_SUBJECT = 'Application Status : {company_name} - {id}'
STUDENT_APPLICATION_SUBMITTED_TEMPLATE_SUBJECT = 'CDC - Application Submitted - {company_name}'
@@ -139,4 +136,4 @@ COMPANY_JNF_RESPONSE_TEMPLATE = 'company_jnf_response.html'
APPLICATION_CSV_COL_NAMES = ['Applied At', 'Roll No.', 'Name', 'Email', 'Phone Number', 'Branch', 'Batch', 'CPI',
'Resume', 'Selected', ]
-PDF_FILES_SERVING_ENDPOINT = 'http://localhost:5500/CDC_Backend/Storage/Company_Attachments/' # TODO: Change this to actual URL
+PDF_FILES_SERVING_ENDPOINT = 'http://localhost:5500/CDC_Backend/Storage/Company_Attachments/' # TODO: Change this to actual URL
diff --git a/CDC_Backend/APIs/models.py b/CDC_Backend/APIs/models.py
index 5ab67ff..8857cf8 100644
--- a/CDC_Backend/APIs/models.py
+++ b/CDC_Backend/APIs/models.py
@@ -1,15 +1,18 @@
from django.contrib.postgres.fields import ArrayField
from django.db import models
from django.utils import timezone
-from .constants import *
-# from .utils import *
+from .constants import *
+
+
+# from .utils import *
class User(models.Model):
email = models.CharField(primary_key=True, blank=False, max_length=50)
id = models.CharField(blank=False, max_length=25)
user_type = ArrayField(models.CharField(blank=False, max_length=10), size=4, default=list, blank=False)
+ last_login_time = models.DateTimeField(default=timezone.now)
class Student(models.Model):
@@ -21,7 +24,7 @@ class Student(models.Model):
phone_number = models.PositiveBigIntegerField(blank=True, default=None, null=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)
- can_apply = models.BooleanField(default=True)
+ can_apply = models.BooleanField(default=True, verbose_name='Registered')
def __str__(self):
return str(self.roll_no)
@@ -45,7 +48,8 @@ class Placement(models.Model):
nature_of_business = models.CharField(blank=False, max_length=50, default="")
website = models.CharField(blank=True, max_length=50)
company_details = models.CharField(max_length=500, default=None, null=True)
- company_details_pdf_names = ArrayField(models.CharField(null=True, default=None, max_length=100), size=5, default=list, blank=True)
+ company_details_pdf_names = ArrayField(models.CharField(null=True, default=None, max_length=100), size=5,
+ default=list, blank=True)
is_company_details_pdf = models.BooleanField(blank=False, default=False)
contact_person_name = models.CharField(blank=False, max_length=50)
phone_number = models.PositiveBigIntegerField(blank=False)
@@ -53,24 +57,28 @@ class Placement(models.Model):
city = models.CharField(blank=False, max_length=100, default="")
state = models.CharField(blank=False, max_length=100, default="")
country = models.CharField(blank=False, max_length=100, default="")
- pin_code = models.IntegerField(blank=False, default=None,null=True)
+ pin_code = models.IntegerField(blank=False, default=None, null=True)
city_type = models.CharField(blank=False, max_length=15, choices=OFFER_CITY_TYPE)
# Job Details
designation = models.CharField(blank=False, max_length=50, default=None, null=True)
description = models.CharField(blank=False, max_length=500, default=None, null=True)
- description_pdf_names = ArrayField(models.CharField(null=True, default=None, max_length=100), size=5, default=list, blank=True)
+ description_pdf_names = ArrayField(models.CharField(null=True, default=None, max_length=100), size=5, default=list,
+ blank=True)
is_description_pdf = models.BooleanField(blank=False, default=False)
- compensation_CTC = models.IntegerField(blank=False, default=None, null=True ) # Job - Per Year
+ compensation_CTC = models.IntegerField(blank=False, default=None, null=True) # Job - Per Year
compensation_gross = models.IntegerField(blank=False, default=None, null=True)
compensation_take_home = models.IntegerField(blank=False, default=None, null=True)
compensation_bonus = models.IntegerField(blank=True, default=None, null=True)
compensation_details = models.CharField(blank=True, max_length=500, default=None, null=True)
- compensation_details_pdf_names = ArrayField(models.CharField(null=True, default=None, max_length=100), size=5, default=list, blank=True)
+ compensation_details_pdf_names = ArrayField(models.CharField(null=True, default=None, max_length=100), size=5,
+ default=list, blank=True)
is_compensation_details_pdf = models.BooleanField(blank=False, default=False)
bond_details = models.CharField(blank=True, max_length=500)
- selection_procedure_rounds = ArrayField(models.CharField(null=True, default=None, max_length=100), size=10, default=list, blank=True)
+ selection_procedure_rounds = ArrayField(models.CharField(null=True, default=None, max_length=100), size=10,
+ default=list, blank=True)
selection_procedure_details = models.CharField(blank=True, max_length=500)
- selection_procedure_details_pdf_names = ArrayField(models.CharField(null=True, default=None, max_length=100), size=5, default=list, blank=True)
+ selection_procedure_details_pdf_names = ArrayField(models.CharField(null=True, default=None, max_length=100),
+ size=5, default=list, blank=True)
is_selection_procedure_details_pdf = models.BooleanField(blank=False, default=False)
tier = models.CharField(blank=False, choices=TIERS, max_length=10, default=None, null=True)
tentative_date_of_joining = models.DateField(blank=False, verbose_name="Tentative Date", default=timezone.now)
@@ -103,6 +111,7 @@ class Placement(models.Model):
def __str__(self):
return self.company_name + " - " + self.id
+
class PlacementApplication(models.Model):
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)
diff --git a/CDC_Backend/APIs/serializers.py b/CDC_Backend/APIs/serializers.py
index b0296a2..82af184 100644
--- a/CDC_Backend/APIs/serializers.py
+++ b/CDC_Backend/APIs/serializers.py
@@ -1,6 +1,7 @@
import urllib
from rest_framework import serializers
+
from .models import *
@@ -95,7 +96,7 @@ class PlacementSerializerForStudent(serializers.ModelSerializer):
exclude = [CONTACT_PERSON_NAME, PHONE_NUMBER, EMAIL, COMPANY_DETAILS_PDF_NAMES, DESCRIPTION_PDF_NAMES,
COMPENSATION_DETAILS_PDF_NAMES, SELECTION_PROCEDURE_DETAILS_PDF_NAMES, OFFER_ACCEPTED,
EMAIL_VERIFIED,
- ]
+ ]
depth = 1
diff --git a/CDC_Backend/APIs/studentUrls.py b/CDC_Backend/APIs/studentUrls.py
index 1d6d76a..f532849 100644
--- a/CDC_Backend/APIs/studentUrls.py
+++ b/CDC_Backend/APIs/studentUrls.py
@@ -1,6 +1,6 @@
-from django.urls import path, include
-from . import studentViews
+from django.urls import path
+from . import studentViews
urlpatterns = [
path('login/', studentViews.login, name="Login"),
diff --git a/CDC_Backend/APIs/studentViews.py b/CDC_Backend/APIs/studentViews.py
index ed8f4f1..daf4221 100644
--- a/CDC_Backend/APIs/studentViews.py
+++ b/CDC_Backend/APIs/studentViews.py
@@ -1,8 +1,3 @@
-import json
-# from datetime import datetime
-import datetime
-import traceback
-
from rest_framework.decorators import api_view
from .serializers import *
@@ -75,7 +70,7 @@ def getDashboard(request, id, email, user_type):
placements = Placement.objects.filter(allowed_batch__contains=[studentDetails.batch],
allowed_branch__contains=[studentDetails.branch],
deadline_datetime__gte=datetime.datetime.now(),
- offer_accepted=True, email_verified=True).order_by('deadline_datetime')
+ offer_accepted=True, email_verified=True).order_by('deadline_datetime')
placementsdata = PlacementSerializerForStudent(placements, many=True).data
placementApplications = PlacementApplication.objects.filter(student_id=id)
placementApplications = PlacementApplicationSerializer(placementApplications, many=True).data
diff --git a/CDC_Backend/APIs/tests.py b/CDC_Backend/APIs/tests.py
index 7ce503c..a39b155 100644
--- a/CDC_Backend/APIs/tests.py
+++ b/CDC_Backend/APIs/tests.py
@@ -1,3 +1 @@
-from django.test import TestCase
-
# Create your tests here.
diff --git a/CDC_Backend/APIs/urls.py b/CDC_Backend/APIs/urls.py
index bdb06c8..36f929e 100644
--- a/CDC_Backend/APIs/urls.py
+++ b/CDC_Backend/APIs/urls.py
@@ -1,4 +1,5 @@
from django.urls import path, include
+
from . import studentViews, studentUrls, companyUrls, adminUrls
urlpatterns = [
diff --git a/CDC_Backend/APIs/utils.py b/CDC_Backend/APIs/utils.py
index 6ffbc9f..d98f045 100644
--- a/CDC_Backend/APIs/utils.py
+++ b/CDC_Backend/APIs/utils.py
@@ -1,4 +1,5 @@
import datetime
+import json
import logging
import os
import random
@@ -7,9 +8,11 @@ import string
import sys
import traceback
from os import path, remove
-import json
+
import background_task
import jwt
+import pdfkit
+import requests as rq
from django.conf import settings
from django.core.mail import EmailMultiAlternatives
from django.forms.models import model_to_dict
@@ -21,8 +24,6 @@ from google.auth.transport import requests
from google.oauth2 import id_token
from rest_framework import status
from rest_framework.response import Response
-import requests as rq
-import pdfkit
from .constants import *
from .models import User, PrePlacementOffer, PlacementApplication, Placement
@@ -78,7 +79,8 @@ def isAuthorized(allowed_users=None):
print(email)
user = get_object_or_404(User, email=email)
if user:
-
+ user.last_login_time = datetime.datetime.now()
+ user.save()
if len(set(user.user_type).intersection(set(allowed_users))) or allowed_users == '*':
return view_func(request, user.id, user.email, user.user_type, *args, **kwargs)
else:
@@ -150,7 +152,8 @@ def sendEmail(email_to, subject, data, template, attachment_jnf_respone=None):
msg.attach_alternative(html_content, "text/html")
if attachment_jnf_respone:
logger.info(attachment_jnf_respone)
- pdf = pdfkit.from_string(attachment_jnf_respone['html'], False,options={"--enable-local-file-access": "",'--dpi':'96'})
+ pdf = pdfkit.from_string(attachment_jnf_respone['html'], False,
+ options={"--enable-local-file-access": "", '--dpi': '96'})
msg.attach(attachment_jnf_respone['name'], pdf, 'application/pdf')
msg.send()
return True
@@ -248,6 +251,7 @@ def generateOneTimeVerificationLink(email, opening_id, opening_type):
logger.warning("Utils - generateOneTimeVerificationLink: " + str(sys.exc_info()))
return False, "_"
+
def verify_recaptcha(request):
try:
print(settings.RECAPTCHA_SECRET_KEY)
@@ -269,19 +273,25 @@ def verify_recaptcha(request):
logger.warning("Utils - verify_recaptcha: " + str(sys.exc_info()))
return False, "_"
+
def opening_description_table_html(opening):
- details = model_to_dict(opening, fields = [field.name for field in Placement._meta.fields], exclude = ['id','is_company_details_pdf','offer_accepted','is_description_pdf','is_compensation_details_pdf','is_selection_procedure_details_pdf','email_verified'])
+ details = model_to_dict(opening, fields=[field.name for field in Placement._meta.fields],
+ exclude=['id', 'is_company_details_pdf', 'offer_accepted', 'is_description_pdf',
+ 'is_compensation_details_pdf', 'is_selection_procedure_details_pdf',
+ 'email_verified'])
keys = list(details.keys())
newdetails = {}
for key in keys:
if isinstance(details[key], list):
details[key] = {"details": details[key], "type": ["list"]}
- if key in ['website','company_details_pdf_names','description_pdf_names','compensation_details_pdf_names','selection_procedure_pdf_names']:
+ if key in ['website', 'company_details_pdf_names', 'description_pdf_names', 'compensation_details_pdf_names',
+ 'selection_procedure_pdf_names']:
if key == 'website':
details[key] = {"details": details[key], "type": ["link"]}
else:
- details[key] = {"details": details[key]["details"], "type": ["list","link"], "link": PDF_FILES_SERVING_ENDPOINT+opening.id+"/"}
- new_key = key.replace('_',' ')
+ details[key] = {"details": details[key]["details"], "type": ["list", "link"],
+ "link": PDF_FILES_SERVING_ENDPOINT + opening.id + "/"}
+ new_key = key.replace('_', ' ')
if key.endswith(' names'):
new_key = key[:-6]
new_key = new_key.capitalize()
@@ -289,7 +299,7 @@ def opening_description_table_html(opening):
imagepath = os.path.abspath('./templates/image.png')
print(imagepath)
data = {
- "data": newdetails,
- "imgpath": imagepath
+ "data": newdetails,
+ "imgpath": imagepath
}
- return render_to_string(COMPANY_JNF_RESPONSE_TEMPLATE, data)
\ No newline at end of file
+ return render_to_string(COMPANY_JNF_RESPONSE_TEMPLATE, data)
diff --git a/CDC_Backend/CDC_Backend/settings.py b/CDC_Backend/CDC_Backend/settings.py
index 9a09b88..4c24f27 100644
--- a/CDC_Backend/CDC_Backend/settings.py
+++ b/CDC_Backend/CDC_Backend/settings.py
@@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/2.2/ref/settings/
"""
import os
+
from dotenv import load_dotenv
load_dotenv("../dev.env")
diff --git a/CDC_Backend/README.md b/CDC_Backend/README.md
index 6a041f0..30c06d8 100644
--- a/CDC_Backend/README.md
+++ b/CDC_Backend/README.md
@@ -158,7 +158,6 @@ Request_Body:
> Only users with `student` role can access this Api.
-
### Response
Response is a Json with these fields
@@ -565,8 +564,6 @@ Request_Body:
}
```
-
-
> Headers
> Authorization: "Bearer {tokenID}"
@@ -728,7 +725,6 @@ Response is a Json with these fields
- ongoing: Gives us the list of placements that are accepting applications.
- previous: Gives us the list of placements that stopped accepting applications.
-
### Status Codes
The possible responses for this api request are as follows
diff --git a/CDC_Backend/client_secret_956830229554-290mirc16pdhd5j7ph7v7ukibo4t1qcp.apps.googleusercontent.com (2).json b/CDC_Backend/client_secret_956830229554-290mirc16pdhd5j7ph7v7ukibo4t1qcp.apps.googleusercontent.com (2).json
index 42f9eb6..51b5c1c 100644
--- a/CDC_Backend/client_secret_956830229554-290mirc16pdhd5j7ph7v7ukibo4t1qcp.apps.googleusercontent.com (2).json
+++ b/CDC_Backend/client_secret_956830229554-290mirc16pdhd5j7ph7v7ukibo4t1qcp.apps.googleusercontent.com (2).json
@@ -6,7 +6,11 @@
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_secret": "ZzvcweJylL1IDLUnYOi1ws2W",
- "redirect_uris": ["https://www.getpostman.com/oauth2/callback"],
- "javascript_origins": ["http://localhost:3000"]
+ "redirect_uris": [
+ "https://www.getpostman.com/oauth2/callback"
+ ],
+ "javascript_origins": [
+ "http://localhost:3000"
+ ]
}
}
diff --git a/CDC_Backend/templates/company_email_verification.html b/CDC_Backend/templates/company_email_verification.html
index e3f480a..e4b6b19 100644
--- a/CDC_Backend/templates/company_email_verification.html
+++ b/CDC_Backend/templates/company_email_verification.html
@@ -32,7 +32,8 @@
style="width:602px;border-collapse:collapse;border:1px solid #334878;border-spacing:0;text-align:left;">
- We have received your Job Notification. Kindly verify your email by clicking here. + We have received your Job Notification. Kindly verify your email by clicking here.
- {{ key }} - | -
- {% if 'list' in value.type %}
-
- {% for item in value.details %}
- |
-
In case of any descripency regarding above details, please contact cdc@iitdh.ac.in -
++ {{ key }} + | +
+ {% if 'list' in value.type %}
+
+ {% for item in value.details %}
+ |
+
In case of any descripency regarding above details, please contact cdc@iitdh.ac.in + +