From fa737c5978a2d2230646daacb624ddc7ec52253d Mon Sep 17 00:00:00 2001 From: Abhishek28112002 <72252789+Abhishek28112002@users.noreply.github.com> Date: Thu, 28 Jul 2022 14:37:41 +0530 Subject: [PATCH] Email notification from applications edits (#125) * updater * send email when application is created/edited by admin * send email when application is created/edited by admin * fixed: email not sending when application is edit - indexed id for student. * changing subject * minor change Co-authored-by: karthikmurakonda Co-authored-by: Gowtham Sai <66207607+gowtham3105@users.noreply.github.com> --- CDC_Backend/APIs/adminViews.py | 19 ++- CDC_Backend/APIs/constants.py | 2 + CDC_Backend/APIs/models.py | 2 +- .../student_application_updated.html | 124 ++++++++++++++++++ README.md | 8 +- 5 files changed, 151 insertions(+), 4 deletions(-) create mode 100644 CDC_Backend/templates/student_application_updated.html diff --git a/CDC_Backend/APIs/adminViews.py b/CDC_Backend/APIs/adminViews.py index da935d9..cb28744 100644 --- a/CDC_Backend/APIs/adminViews.py +++ b/CDC_Backend/APIs/adminViews.py @@ -229,7 +229,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) if data[APPLICATION_ID] == "": application = PlacementApplication() application.id = generateRandomString() @@ -246,8 +246,16 @@ def submitApplication(request, id, email, user_type): else: additional_info[i] = data[ADDITIONAL_INFO][i] application.additional_info = json.dumps(additional_info) + data = { + "name": student.name, + "company_name": opening.company_name, + "application_type": "Placement", + "additional_info": dict(json.loads(application.additional_info)), + } + subject = STUDENT_APPLICATION_SUBMITTED_TEMPLATE_SUBJECT.format(company_name=opening.company_name) application.changed_by = get_object_or_404(User, id=id) application.save() + sendEmail(student_user.email, subject, data, STUDENT_APPLICATION_SUBMITTED_TEMPLATE) return Response({'action': "Add Student Application", 'message': "Application added"}, status=status.HTTP_200_OK) else: @@ -266,8 +274,17 @@ def submitApplication(request, id, email, user_type): additional_info[i] = data[ADDITIONAL_INFO][i] application.additional_info = json.dumps(additional_info) + data = { + "name": student.name, + "company_name": opening.company_name, + "application_type": "Placement", + "resume": application.resume[16:], + "additional_info_items": dict(json.loads(application.additional_info)), + } + subject = STUDENT_APPLICATION_UPDATED_TEMPLATE_SUBJECT.format(company_name=opening.company_name) application.changed_by = get_object_or_404(User, id=id) application.save() + sendEmail(student_user.email, subject, data, STUDENT_APPLICATION_UPDATED_TEMPLATE) return Response({'action': "Add Student Application", 'message': "Application updated"}, status=status.HTTP_200_OK) else: diff --git a/CDC_Backend/APIs/constants.py b/CDC_Backend/APIs/constants.py index 75a23b6..359d283 100644 --- a/CDC_Backend/APIs/constants.py +++ b/CDC_Backend/APIs/constants.py @@ -139,12 +139,14 @@ SPECIAL_FORMAT_IN_PDF = ['website', 'company_details_pdf_names', 'description_pd 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}' +STUDENT_APPLICATION_UPDATED_TEMPLATE_SUBJECT = 'CDC - Application Updated - {company_name}' COMPANY_EMAIl_VERIFICATION_TEMPLATE_SUBJECT = 'Email Verification - Career Development Cell, IIT Dharwad' STUDENT_APPLICATION_SUBMITTED_TEMPLATE = 'student_application_submitted.html' COMPANY_OPENING_SUBMITTED_TEMPLATE = 'company_opening_submitted.html' STUDENT_APPLICATION_STATUS_SELECTED_TEMPLATE = 'student_application_status_selected.html' STUDENT_APPLICATION_STATUS_NOT_SELECTED_TEMPLATE = 'student_application_status_not_selected.html' +STUDENT_APPLICATION_UPDATED_TEMPLATE = 'student_application_updated.html' COMPANY_EMAIL_VERIFICATION_TEMPLATE = 'company_email_verification.html' COMPANY_JNF_RESPONSE_TEMPLATE = 'company_jnf_response.html' diff --git a/CDC_Backend/APIs/models.py b/CDC_Backend/APIs/models.py index d013140..8580029 100644 --- a/CDC_Backend/APIs/models.py +++ b/CDC_Backend/APIs/models.py @@ -11,7 +11,7 @@ from .constants import * class User(models.Model): email = models.EmailField(primary_key=True, blank=False, max_length=JNF_TEXT_MAX_CHARACTER_COUNT) - id = models.CharField(blank=False, max_length=25) + id = models.CharField(blank=False, max_length=25, db_index=True) user_type = ArrayField(models.CharField(blank=False, max_length=10), size=4, default=list, blank=False) last_login_time = models.DateTimeField(default=timezone.now) history = HistoricalRecords() diff --git a/CDC_Backend/templates/student_application_updated.html b/CDC_Backend/templates/student_application_updated.html new file mode 100644 index 0000000..2cb0246 --- /dev/null +++ b/CDC_Backend/templates/student_application_updated.html @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + +
+ +
+ + + + + + + +
+

Hello, {{ name }}

+

+ We have received some update in your application for a {{ application_type }} offer at + + {{ company_name }}. + + + + + +
resume:{{ resume }}
+ + {% if additional_info_items %} + We received these additional details +
+ +

+ {% for i,j in additional_info_items.items %} + +

+ + + + {% endfor %} +
{{ i }}:{{ j }}
+ {% endif %} + +

+

+

+ We will keep you informed with the updates. 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 diff --git a/README.md b/README.md index 83ac1d8..a4495bb 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ python# CDC - Backend 4. Install the dependencies
`pip install -r requirements.txt ` 5. Ensure that you have the PostgreSQL installed on your machine and is running on PORT **5432**
-6. Make sure to give the correct database credentials in [settings.py](./CDC_Backend/CDC_Backend/settings.py) +6. Make sure to give the correct database credentials in [settings.py](./CDC_Backend/CDC_Backend/settings.py)(https://www.youtube.com/watch?v=bE9h6aAky4s&t=193s) ### Running the Application @@ -28,7 +28,11 @@ python# CDC - Backend 2. Run `python manage.py createsuperuser` to create a user to access the admin panel. 3. Set up the Username and Password 4. You can log in and change the database values anytime. - + + # Error + 1.make sure that your machine time and google time are same ,if not go to setting of date and time and sync this + 2.make sure u have used same id for both student and Admin that is your iitfh roll_no + 3. same client link in .env of frontend or constants.py of bakcend ### Deploying 1. Add the hosted domain name in `ALLOWED_HOSTS` in [settings.py](./CDC_Backend/CDC_Backend/settings.py)