From 37615876d61c3f918f3a2ab151c1cc1b656dd8d6 Mon Sep 17 00:00:00 2001 From: uttamthummala Date: Tue, 3 Oct 2023 16:33:11 +0530 Subject: [PATCH] added addIssue endpoint and updated offeraccepted --- CDC_Backend/APIs/adminViews.py | 5 + CDC_Backend/APIs/constants.py | 9 +- CDC_Backend/APIs/models.py | 29 ++++- CDC_Backend/APIs/studentUrls.py | 18 +-- CDC_Backend/APIs/studentViews.py | 48 +++++++ CDC_Backend/APIs/utils.py | 8 +- .../templates/reps_issue_submitted.html | 117 +++++++++++++++++ .../templates/student_issue_submitted.html | 118 ++++++++++++++++++ 8 files changed, 339 insertions(+), 13 deletions(-) create mode 100644 CDC_Backend/templates/reps_issue_submitted.html create mode 100644 CDC_Backend/templates/student_issue_submitted.html diff --git a/CDC_Backend/APIs/adminViews.py b/CDC_Backend/APIs/adminViews.py index b806275..f56d1c5 100644 --- a/CDC_Backend/APIs/adminViews.py +++ b/CDC_Backend/APIs/adminViews.py @@ -149,12 +149,17 @@ def updateOfferAccepted(request, id, email, user_type): opening_type= data[OPENING_TYPE] else: opening_type= "Placement" + if DEADLINE_DATETIME in data: + deadline_datetime = datetime.datetime.strptime(data[DEADLINE_DATETIME], '%Y-%m-%d %H:%M:%S %z') + else: + deadline_datetime = datetime.datetime.now().replace(hour=0, minute=0, second=0, microsecond=0) + datetime.timedelta(days=2) if opening_type == "Internship": opening = get_object_or_404(Internship, pk=data[OPENING_ID]) else: opening = get_object_or_404(Placement, pk=data[OPENING_ID]) if opening.offer_accepted is None: opening.offer_accepted = offer_accepted == "true" + opening.deadline_datetime = deadline_datetime opening.changed_by = get_object_or_404(User, id=id) opening.save() if opening.offer_accepted: diff --git a/CDC_Backend/APIs/constants.py b/CDC_Backend/APIs/constants.py index 0c8e21a..8ebfcf1 100644 --- a/CDC_Backend/APIs/constants.py +++ b/CDC_Backend/APIs/constants.py @@ -73,6 +73,10 @@ CDC_REPS_EMAILS = [ "suvamay.jana@iitdh.ac.in", "ramesh.nayaka@iitdh.ac.in" ] +CDC_REPS_EMAILS_FOR_ISSUE=[ #add reps emails + "support.cdc@iitdh.ac.in" + "irontwist00@gmail.com" +] # To be Configured Properly CLIENT_ID = os.environ.get('GOOGLE_OAUTH_CLIENT_ID') # Google Login Client ID @@ -207,7 +211,9 @@ APPLICATION_CSV_COL_NAMES = ['Applied At', 'Roll No.', 'Name', 'Email', 'Phone N 'Resume', 'Selected', ] - +ISSUE_SUBMITTED_TEMPLATE_SUBJECT = 'CDC - Issue Submitted' +STUDENT_ISSUE_SUBMITTED_TEMPLATE = 'student_issue_submitted.html' +REPS_ISSUE_SUBMITTED_TEMPLATE = 'reps_issue_submitted.html' # Internships INTERNSHIP = 'Internship' INTERNSHIP_ID = 'internship_id' @@ -225,6 +231,7 @@ FACILITIES = 'facilities' OTHER_FACILITIES = 'other_facilities' STIPEND_DETAILS_PDF = 'compensation_details_pdf' STIPEND_DETAILS_PDF_NAMES = 'stipend_description_pdf_names' +INTERNSHIP_OPENING_URL = "https://cdc.iitdh.ac.in/portal/student/dashboard/internships/{id}" # On frontend, this is the URL to be opened SEASONS = ( 'Summer', diff --git a/CDC_Backend/APIs/models.py b/CDC_Backend/APIs/models.py index f5dbc57..9321cc6 100644 --- a/CDC_Backend/APIs/models.py +++ b/CDC_Backend/APIs/models.py @@ -478,4 +478,31 @@ class Contributor(models.Model): image = models.CharField(max_length=JNF_SMALLTEXT_MAX_CHARACTER_COUNT, blank=False, default="", null=True) def __str__(self): - return self.name \ No newline at end of file + return self.name + + +class Issues(models.Model): + id = models.AutoField(primary_key=True) + title = models.CharField(max_length=JNF_SMALLTEXT_MAX_CHARACTER_COUNT, blank=False, default="") + description = models.CharField(max_length=200, blank=False, default="") + opening=(models.ForeignKey(Placement, on_delete=models.CASCADE, blank=False) or models.ForeignKey(Internship, on_delete=models.CASCADE, blank=False)) + #status = models.CharField(max_length=JNF_SMALLTEXT_MAX_CHARACTER_COUNT, blank=False, default="") + student=models.ForeignKey(Student, on_delete=models.CASCADE, blank=False) + created_at = models.DateTimeField(blank=False, default=None, null=True) + updated_at = models.DateTimeField(blank=False, default=None, null=True) + changed_by = models.ForeignKey(User, on_delete=models.RESTRICT, blank=True, null=True) + history = HistoricalRecords(user_model=User) + + def save(self, *args, **kwargs): + ''' On save, add timestamps ''' + if not self.created_at: + self.created_at = timezone.now() + self.updated_at = timezone.now() + + return super(Issues, self).save(*args, **kwargs) + + def __str__(self): + return self.title + " - " + self.student.name + class Meta: + verbose_name_plural = "Issues" + \ No newline at end of file diff --git a/CDC_Backend/APIs/studentUrls.py b/CDC_Backend/APIs/studentUrls.py index 07c4710..e94ecf5 100644 --- a/CDC_Backend/APIs/studentUrls.py +++ b/CDC_Backend/APIs/studentUrls.py @@ -3,14 +3,14 @@ from django.urls import path from . import studentViews urlpatterns = [ - path('login/', studentViews.login, name="Login"), #done for intern - path('profile/', studentViews.studentProfile, name="Student Profile"), #done for intern - path('getDashboard/', studentViews.getDashboard, name="Dashboard"), # customised dashboard.. check are we checking registedred check allowed branch/batches filter in - path("addResume/", studentViews.addResume, name="Upload Resume"), #done for intern - path("deleteResume/", studentViews.deleteResume, name="Upload Resume"),#done for intern - path("submitApplication/", studentViews.submitApplication, name="Submit Application"), #done for intern - path("deleteApplication/", studentViews.deleteApplication, name="Delete Application"), #done for intern check for opening type data in headers + path('login/', studentViews.login, name="Login"), + path('profile/', studentViews.studentProfile, name="Student Profile"), + path('getDashboard/', studentViews.getDashboard, name="Dashboard"), + path("addResume/", studentViews.addResume, name="Upload Resume"), + path("deleteResume/", studentViews.deleteResume, name="Delete Resume"), + path("submitApplication/", studentViews.submitApplication, name="Submit Application"), + path("deleteApplication/", studentViews.deleteApplication, name="Delete Application"), path("getContributorStats/", studentViews.getContributorStats, name="Get Contributor Stats"), - path("studentAcceptOffer/", studentViews.studentAcceptOffer, name="Student Accept Offer"), #same as above check header + path("studentAcceptOffer/", studentViews.studentAcceptOffer, name="Student Accept Offer"), + path("addIssue/",studentViews.addIssue,name= "Add Issue") ] -#store all files.. \ No newline at end of file diff --git a/CDC_Backend/APIs/studentViews.py b/CDC_Backend/APIs/studentViews.py index a9fb2aa..2f7c7e1 100644 --- a/CDC_Backend/APIs/studentViews.py +++ b/CDC_Backend/APIs/studentViews.py @@ -346,4 +346,52 @@ def studentAcceptOffer(request, id, email, user_type): logger.warning("Accept Offer: " + str(sys.exc_info())) return Response({'action': "Accept Offer", 'message': "Something Went Wrong"}, + status=status.HTTP_400_BAD_REQUEST) + + +#view for addIssue + +@api_view(['POST']) +@isAuthorized(allowed_users=[STUDENT]) +@precheck(required_data=["Title","Description","opening_id"]) +def addIssue(request, id, email, user_type): + try: + data = request.data + student = get_object_or_404(Student, id=id) + issue = Issues() + issue.student = student + issue.title = data["Title"] + issue.description = data["Description"] + # issue.opening=get_object_or_404(Placement, id=data["opening_id"]) or get_object_or_404(Internship, id=data["opening_id"]) + try: + issue.opening=get_object_or_404(Placement, id=data["opening_id"]) + except: + try: + issue.opening=get_object_or_404(Internship, id=data["opening_id"]) + except: + return Response({'action': "Add Issue", 'message': "Opening Not Found"}, + status=status.HTTP_400_BAD_REQUEST) + issue.save() + subject=ISSUE_SUBMITTED_TEMPLATE_SUBJECT + data={ + "name":student.name, + "application_type":PLACEMENT if isinstance(issue.opening,Placement) else INTERNSHIP, + "company_name":issue.opening.company_name, + "additional_info":{ + "Title":issue.title, + "Description":issue.description + }, + "email":email + } + sendEmail(email, subject, data, STUDENT_ISSUE_SUBMITTED_TEMPLATE) + #send_mail_to reps + sendEmail(CDC_REPS_EMAILS_FOR_ISSUE,"Issue Raised",data,REPS_ISSUE_SUBMITTED_TEMPLATE) + return Response({'action': "Add Issue", 'message': "Issue Added"}, + status=status.HTTP_200_OK) + except Http404: + return Response({'action': "Add Issue", 'message': 'Student Not Found'}, + status=status.HTTP_404_NOT_FOUND) + except: + logger.warning("Add Issue: " + str(sys.exc_info())) + return Response({'action': "Add Issue", 'message': "Something Went Wrong"}, status=status.HTTP_400_BAD_REQUEST) \ No newline at end of file diff --git a/CDC_Backend/APIs/utils.py b/CDC_Backend/APIs/utils.py index cc9a773..60ea4da 100644 --- a/CDC_Backend/APIs/utils.py +++ b/CDC_Backend/APIs/utils.py @@ -428,7 +428,7 @@ def send_opening_notifications(opening_id, opening_type=PLACEMENT): "opening_type": "INTERNSHIP" if isinstance(opening, Internship) else "PLACEMENT", "designation": opening.designation, "deadline": deadline_datetime.strftime("%A, %-d %B %Y, %-I:%M %p"), - "link": PLACEMENT_OPENING_URL.format(id=opening.designation) + "link": PLACEMENT_OPENING_URL.format(id=opening.designation) if opening_type == PLACEMENT else INTERNSHIP_OPENING_URL.format(id=opening.designation), } emails.append(student_user.email) #sendEmail(student_user.email, subject, data, NOTIFY_STUDENTS_OPENING_TEMPLATE) @@ -451,7 +451,7 @@ def exception_email(opening): "company_name": opening["company_name"], } pdfhtml = opening_description_table_html(opening) - name = opening["company_name"] + '_jnf_response.pdf' + name = opening["company_name"] + '_jnf_response.pdf' if opening[OPENING_TYPE]!="INF" else opening["company_name"] + '_inf_response.pdf' attachment_jnf_respone = { "name": name, "html": pdfhtml, @@ -474,6 +474,10 @@ def store_all_files(request): for file in files.getlist(COMPENSATION_DETAILS_PDF): file_location = STORAGE_DESTINATION_COMPANY_ATTACHMENTS + "temp" + '/' saveFile(file, file_location) + #stipend details pdf for internships + for file in files.getlist(STIPEND_DETAILS_PDF): + file_location = STORAGE_DESTINATION_COMPANY_ATTACHMENTS + "temp" + '/' + saveFile(file, file_location) # selection procedure details pdf for file in files.getlist(SELECTION_PROCEDURE_DETAILS_PDF): file_location = STORAGE_DESTINATION_COMPANY_ATTACHMENTS + "temp" + '/' diff --git a/CDC_Backend/templates/reps_issue_submitted.html b/CDC_Backend/templates/reps_issue_submitted.html new file mode 100644 index 0000000..ac6ca1f --- /dev/null +++ b/CDC_Backend/templates/reps_issue_submitted.html @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + +
+ +
+ + + + + + + +
+

Hello, Folks

+

+ We have received a issue regarding a {{ application_type }} opening at + + {{ company_name }} From {{name}}. + {% if additional_info_items %} + We received these additional details +
+

+ + + + {% for i,j in additional_info.items %} + + + + + + {% endfor %} +
{{ i }}:{{ j }}
+ {% endif %} + +

+

+

+ please look into it and take necessary actions. + get in touch with the student at at {{ email }} + +

+
+ + + + +
+ + +
+
+
+ + + + + + + +
+

+ ® CDC,IIT Dharwad,2021
+

+
+
+
+ + \ No newline at end of file diff --git a/CDC_Backend/templates/student_issue_submitted.html b/CDC_Backend/templates/student_issue_submitted.html new file mode 100644 index 0000000..ef96862 --- /dev/null +++ b/CDC_Backend/templates/student_issue_submitted.html @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + +
+ +
+ + + + + + + +
+

Hello, {{ name }}

+

+ We have received your issue regarding a {{ application_type }} opening at + + {{ company_name }}. + {% if additional_info_items %} + We received these additional details +
+

+ + + + {% for i,j in additional_info.items %} + + + + + + {% endfor %} +
{{ i }}:{{ j }}
+ {% endif %} + +

+

+

+ We will get back to you if we find it legitimate. If you have any queries, please + feel to + write to + cdc.support@iitdh.ac.in +

+
+ + + + +
+ + +
+
+
+ + + + + + + +
+

+ ® CDC,IIT Dharwad,2021
+

+
+
+
+ + \ No newline at end of file