notify new opening to students
This commit is contained in:
parent
fa737c5978
commit
756dd5ae61
|
@ -109,12 +109,13 @@ def updateDeadline(request, id, email, user_type):
|
|||
def updateOfferAccepted(request, id, email, user_type):
|
||||
try:
|
||||
data = request.data
|
||||
print(data)
|
||||
opening = get_object_or_404(Placement, pk=data[OPENING_ID])
|
||||
opening.offer_accepted = True if data[OFFER_ACCEPTED] == True else False
|
||||
print(opening.offer_accepted)
|
||||
opening.changed_by = get_object_or_404(User, id=id)
|
||||
opening.save()
|
||||
if not opening.offer_accepted:
|
||||
opening.offer_accepted = True
|
||||
opening.changed_by = get_object_or_404(User, id=id)
|
||||
opening.save()
|
||||
print('offer accepted sending email to students')
|
||||
send_opening_notifications(opening.id)
|
||||
return Response({'action': "Update Offer Accepted", 'message': "Offer Accepted Updated"},
|
||||
status=status.HTTP_200_OK)
|
||||
except Http404:
|
||||
|
@ -173,6 +174,7 @@ def deleteAdditionalInfo(request, id, email, user_type):
|
|||
return Response({'action': "Delete Additional Info", 'message': "Something went wrong"},
|
||||
status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@isAuthorized([ADMIN])
|
||||
@precheck([OPENING_ID, FIELD])
|
||||
|
@ -200,7 +202,6 @@ def addAdditionalInfo(request, id, email, user_type):
|
|||
status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
@isAuthorized([ADMIN])
|
||||
@precheck([OPENING_ID])
|
||||
|
@ -229,7 +230,7 @@ def submitApplication(request, id, email, user_type):
|
|||
data = request.data
|
||||
student = get_object_or_404(Student, pk=data[STUDENT_ID])
|
||||
opening = get_object_or_404(Placement, pk=data[OPENING_ID])
|
||||
student_user = get_object_or_404(User, id = student.id)
|
||||
student_user = get_object_or_404(User, id=student.id)
|
||||
if data[APPLICATION_ID] == "":
|
||||
application = PlacementApplication()
|
||||
application.id = generateRandomString()
|
||||
|
|
|
@ -276,11 +276,12 @@ def verifyEmail(request):
|
|||
data = {
|
||||
"designation": opening.designation,
|
||||
"opening_type": PLACEMENT,
|
||||
"opening_link": PLACEMENT_OPENING_URL.format(id=opening.id), # Some Changes here too
|
||||
"company_name": opening.company_name,
|
||||
}
|
||||
print(data)
|
||||
print(attachment_jnf_respone)
|
||||
json_data = json.dumps(data, default=str)
|
||||
sendEmail(opening.email, COMPANY_OPENING_SUBMITTED_TEMPLATE_SUBJECT.format(id=opening.id), json_data,
|
||||
sendEmail(opening.email, COMPANY_OPENING_SUBMITTED_TEMPLATE_SUBJECT.format(id=opening.id), data,
|
||||
COMPANY_OPENING_SUBMITTED_TEMPLATE, attachment_jnf_respone)
|
||||
|
||||
return Response({'action': "Verify Email", 'message': "Email Verified Successfully"},
|
||||
|
|
|
@ -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 = "http://localhost:3000/student/dashboard/placements/{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/"
|
||||
|
@ -134,13 +134,14 @@ EXCLUDE_IN_PDF = ['id', 'is_company_details_pdf', 'offer_accepted', 'is_descript
|
|||
'email_verified', 'created_at']
|
||||
SPECIAL_FORMAT_IN_PDF = ['website', 'company_details_pdf_names', 'description_pdf_names',
|
||||
'compensation_details_pdf_names',
|
||||
'selection_procedure_pdf_names']
|
||||
'selection_procedure_details_pdf_names']
|
||||
|
||||
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_STATUS_TEMPLATE_SUBJECT = 'Application Status - {company_name} - {id}'
|
||||
STUDENT_APPLICATION_SUBMITTED_TEMPLATE_SUBJECT = 'CDC - Application Submitted - {company_name}'
|
||||
STUDENT_APPLICATION_UPDATED_TEMPLATE_SUBJECT = 'CDC - Application Updated - {company_name}'
|
||||
COMPANY_EMAIl_VERIFICATION_TEMPLATE_SUBJECT = 'Email Verification - Career Development Cell, IIT Dharwad'
|
||||
NOTIFY_STUDENTS_OPENING_TEMPLATE_SUBJECT = 'Placement Opportunity at {company_name}'
|
||||
|
||||
STUDENT_APPLICATION_SUBMITTED_TEMPLATE = 'student_application_submitted.html'
|
||||
COMPANY_OPENING_SUBMITTED_TEMPLATE = 'company_opening_submitted.html'
|
||||
|
@ -149,6 +150,7 @@ STUDENT_APPLICATION_STATUS_NOT_SELECTED_TEMPLATE = 'student_application_status_n
|
|||
STUDENT_APPLICATION_UPDATED_TEMPLATE = 'student_application_updated.html'
|
||||
COMPANY_EMAIL_VERIFICATION_TEMPLATE = 'company_email_verification.html'
|
||||
COMPANY_JNF_RESPONSE_TEMPLATE = 'company_jnf_response.html'
|
||||
NOTIFY_STUDENTS_OPENING_TEMPLATE = 'notify_students_new_opening.html'
|
||||
|
||||
APPLICATION_CSV_COL_NAMES = ['Applied At', 'Roll No.', 'Name', 'Email', 'Phone Number', 'Branch', 'Batch', 'CPI',
|
||||
'Resume', 'Selected', ]
|
||||
|
|
|
@ -71,7 +71,12 @@ def getDashboard(request, id, email, user_type):
|
|||
allowed_branch__contains=[studentDetails.branch],
|
||||
deadline_datetime__gte=datetime.datetime.now(),
|
||||
offer_accepted=True, email_verified=True).order_by('deadline_datetime')
|
||||
placementsdata = PlacementSerializerForStudent(placements, many=True).data
|
||||
print(placements)
|
||||
filtered_placements = placement_eligibility_filters(studentDetails, placements)
|
||||
print(filtered_placements)
|
||||
|
||||
placementsdata = PlacementSerializerForStudent(filtered_placements, many=True).data
|
||||
|
||||
placementApplications = PlacementApplication.objects.filter(student_id=id)
|
||||
placementApplications = PlacementApplicationSerializer(placementApplications, many=True).data
|
||||
return Response(
|
||||
|
|
|
@ -27,7 +27,7 @@ from rest_framework import status
|
|||
from rest_framework.response import Response
|
||||
|
||||
from .constants import *
|
||||
from .models import User, PrePlacementOffer, PlacementApplication, Placement
|
||||
from .models import User, PrePlacementOffer, PlacementApplication, Placement, Student
|
||||
|
||||
logger = logging.getLogger('db')
|
||||
|
||||
|
@ -138,7 +138,7 @@ def saveFile(file, location):
|
|||
return file_name
|
||||
|
||||
|
||||
@background_task.background(schedule=5)
|
||||
@background_task.background(schedule=2)
|
||||
def sendEmail(email_to, subject, data, template, attachment_jnf_response=None):
|
||||
try:
|
||||
if not isinstance(data, dict):
|
||||
|
@ -169,15 +169,13 @@ def PlacementApplicationConditions(student, placement):
|
|||
selected_companies = PlacementApplication.objects.filter(student=student, selected=True)
|
||||
selected_companies_PSU = [i for i in selected_companies if i.placement.tier == 'psu']
|
||||
PPO = PrePlacementOffer.objects.filter(student=student, accepted=True)
|
||||
# find lenght of PPO
|
||||
print(PPO)
|
||||
print(len(PPO), "ere")
|
||||
# find length of PPO
|
||||
if len(selected_companies) + len(PPO) >= MAX_OFFERS_PER_STUDENT:
|
||||
raise PermissionError("Max Applications Reached for the Season")
|
||||
|
||||
if len(selected_companies_PSU) > 0:
|
||||
raise PermissionError('Selected for PSU Can\'t apply anymore')
|
||||
|
||||
print(placement, 'placement')
|
||||
if placement.tier == 'psu':
|
||||
return True, "Conditions Satisfied"
|
||||
|
||||
|
@ -287,7 +285,7 @@ def opening_description_table_html(opening):
|
|||
if key == 'website':
|
||||
details[key] = {"details": details[key], "type": ["link"]}
|
||||
else:
|
||||
details[key] = {"details": details[key]["details"], "type": ["list", "link"],
|
||||
details[key] = {"details": [item[16:] for item in details[key]["details"]], "type": ["list", "link"],
|
||||
"link": PDF_FILES_SERVING_ENDPOINT + opening.id + "/"}
|
||||
new_key = key.replace('_', ' ')
|
||||
if new_key.endswith(' names'):
|
||||
|
@ -301,3 +299,47 @@ def opening_description_table_html(opening):
|
|||
"imgpath": imagepath
|
||||
}
|
||||
return render_to_string(COMPANY_JNF_RESPONSE_TEMPLATE, data)
|
||||
|
||||
|
||||
def placement_eligibility_filters(student, placements):
|
||||
try:
|
||||
filtered_placements = []
|
||||
for placement in placements.iterator():
|
||||
|
||||
if PlacementApplicationConditions(student, placement)[0]:
|
||||
filtered_placements.append(placement)
|
||||
|
||||
return filtered_placements
|
||||
except:
|
||||
logger.warning("Utils - placement_eligibility_filters: " + str(sys.exc_info()))
|
||||
return placements
|
||||
|
||||
|
||||
@background_task.background(schedule=2)
|
||||
def send_opening_notifications(placement_id):
|
||||
try:
|
||||
placement = get_object_or_404(Placement, id=placement_id)
|
||||
students = Student.objects.all()
|
||||
for student in students.iterator():
|
||||
if PlacementApplicationConditions(student, placement)[0]:
|
||||
try:
|
||||
student_user = get_object_or_404(User, id=student.id)
|
||||
subject = NOTIFY_STUDENTS_OPENING_TEMPLATE_SUBJECT.format(company_name=placement.company_name)
|
||||
data = {
|
||||
"company_name": placement.company_name,
|
||||
"opening_type": 'Placement',
|
||||
"designation": placement.designation,
|
||||
"deadline": placement.deadline_datetime.strftime("%Y-%m-%d %H:%M:%S"),
|
||||
"link": PLACEMENT_OPENING_URL.format(id=placement.id)
|
||||
}
|
||||
sendEmail(student_user.email, subject, data, NOTIFY_STUDENTS_OPENING_TEMPLATE)
|
||||
except Http404:
|
||||
logger.warning('Utils - send_opening_notifications: user not found : ' + student.id)
|
||||
except Exception as e:
|
||||
logger.warning('Utils - send_opening_notifications: For Loop' + str(e))
|
||||
|
||||
|
||||
except:
|
||||
logger.warning('Utils - send_opening_notifications: ' + str(sys.exc_info()))
|
||||
return False
|
||||
|
||||
|
|
|
@ -65,8 +65,7 @@
|
|||
<p style="margin:0 0 12px 0;font-size:16px;line-height:24px;font-family: 'Roboto', sans-serif;">
|
||||
We have received your <b>{{ opening_type }}</b> notification for a
|
||||
<b>{{ designation }}</b> offer at <b>
|
||||
{{ company_name }}</b>. Click <a href="{{ opening_link }}">here</a> to view your
|
||||
notification.
|
||||
{{ company_name }}</b>.
|
||||
</p>
|
||||
<p style="margin:0 0 12px 0;font-size:16px;line-height:24px;font-family: 'Roboto', sans-serif;">
|
||||
We will keep you informed with the updates. If you have any queries, please
|
||||
|
|
|
@ -50,12 +50,12 @@
|
|||
<p style="text-indent: 4ch; margin:0 0 12px 0;font-size:16px;line-height:24px;font-family: 'Roboto', sans-serif;">
|
||||
CDC is excited to announce that <b>{{ company_name }}</b> is interested in
|
||||
recruiting <b>{{ designation }}</b> from IIT Dharwad.
|
||||
More details can be found in the CDC-webportal.
|
||||
More details can be found in the CDC Web Portal.
|
||||
</p>
|
||||
|
||||
<p style="margin:0 0 12px 0;font-size:16px;line-height:24px;font-family: 'Roboto', sans-serif;">
|
||||
Interested students can apply before <b>{{ deadline }}</b> in the <a
|
||||
href="{{ link }}">CDC-webportal</a>.
|
||||
href="{{ link }}">CDC-Web Portal</a>.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
2
dev.env
2
dev.env
|
@ -1,7 +1,7 @@
|
|||
HOSTING_URL=http://localhost:8000/
|
||||
DEBUG=True
|
||||
EMAIL=saisurya3127@gmail.com
|
||||
EMAIL_PASSWORD=lvryxwieedpervtv
|
||||
EMAIL_PASSWORD=deirkdgolaopottv
|
||||
SECRET_KEY=%2e!&f6(ib^690y48z=)&w6fczhwukzzp@3y*^*7u+7%4s-mie
|
||||
EMAIL_VERIFICATION_SECRET_KEY=b'<\xa3\xaf&(*|\x0e\xbces\x07P\xf7\xd6\xa9sf\x19$\x96\xb7\x90\x8b\x88\x84\x0e\x191\xde,M\x90\x17(\xf7\nG\x13"\x8d$\x9f&\xb0\xcd\xa4\xaf\xa9\x1b\x15\x02B\x8a\xaf\xff\x0c\x1e\xd5\xb3\x06\xb8\xa6\x9bQ\xa0TR\xe8\x98\x9ae\xe0n}\xcc/[\xdaFz\x18\xfeX\xaf\xbd\xd0\x88\xeal\xe3\xd2\xe3\xb8\x8c\x199{\xf3<\xb0\xc5\xd0\xe7*Rv\xda\xbb \x1d\x85~\xff%>\x1e\xb8\xa7\xbf\xbc\xb2\x06\x86X\xc3\x9f\x13<\x9fd\xea\xb5"\\5&\x01\xa4\x7f=\xa0\x1b\x8bO\x01h\xe8\xfd\x1f\xfe\xba\xbeg\\\xc2\xcb\xc3\xd1~\xff\xd5/9d\xa8\xa7x{\x16\xdb\\\xbb\x08\rI\xcd\x9e7\x8c~\x0f\x1d\x81rXZD\xf0\xf7\x87K\x8f\xfb,\xf4\xf0\xa5\x9e\xde^\xca\xae\x80|9b\x9b\xaaE"\xba\xfb\xdf\x80\xb1\x99\x83e[\xf8\xce&Rq\x99\xdb}\xeeO\xd5\x18\x8d\x0bv\xe7\xab\xf9\xb9{\xb5u\xce\xcf\x90\xa6HE\xc5\x92p\x00\x158\xdf\x1d'
|
||||
DB_NAME=cdc
|
||||
|
|
Loading…
Reference in New Issue