sending emails to eligible students only and setting proper deadline. (#143)

This commit is contained in:
Gowtham Sai 2022-09-13 01:03:22 +05:30 committed by GitHub
parent 290639c032
commit 9529f45062
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 38 deletions

View File

@ -51,7 +51,6 @@ class Student(models.Model):
self.changed_by = None
class Admin(models.Model):
id = models.CharField(blank=False, max_length=15, primary_key=True)
name = models.CharField(blank=False, max_length=JNF_TEXT_MAX_CHARACTER_COUNT)
@ -71,7 +70,8 @@ class Admin(models.Model):
def two_day_after_today():
return timezone.now() + timezone.timedelta(days=2)
# round off to nearest day
return timezone.now().replace(hour=0, minute=0, second=0, microsecond=0) + timezone.timedelta(days=2)
class Placement(models.Model):
@ -146,6 +146,7 @@ class Placement(models.Model):
updated_at = models.DateTimeField(blank=False, default=None, null=True)
changed_by = models.ForeignKey(User, on_delete=models.CASCADE, blank=True, null=True)
history = HistoricalRecords(user_model=User)
def format(self):
if self.company_name is not None:
self.company_name = self.company_name.strip()[:JNF_SMALLTEXT_MAX_CHARACTER_COUNT]
@ -187,7 +188,8 @@ class Placement(models.Model):
if self.other_requirements is not None:
self.other_requirements = self.other_requirements.strip()[:JNF_TEXTAREA_MAX_CHARACTER_COUNT]
if self.additional_info is not None:
self.additional_info = [info.strip()[:JNF_TEXTMEDIUM_MAX_CHARACTER_COUNT] for info in list(self.additional_info)]
self.additional_info = [info.strip()[:JNF_TEXTMEDIUM_MAX_CHARACTER_COUNT] for info in
list(self.additional_info)]
@property
def _history_user(self):

View File

@ -272,7 +272,7 @@ def opening_description_table_html(opening):
details = model_to_dict(opening, fields=[field.name for field in Placement._meta.fields],
exclude=EXCLUDE_IN_PDF)
# check typing of opening is query dict
else: #if isinstance(opening, QueryDict):
else: # if isinstance(opening, QueryDict):
details = opening
keys = list(details.keys())
newdetails = {}
@ -318,10 +318,13 @@ def send_opening_notifications(placement_id):
placement = get_object_or_404(Placement, id=placement_id)
students = Student.objects.all()
for student in students.iterator():
if student.branch in placement.allowed_branch:
if student.degree == 'bTech' or placement.rs_eligible is True:
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)
subject = NOTIFY_STUDENTS_OPENING_TEMPLATE_SUBJECT.format(
company_name=placement.company_name)
data = {
"company_name": placement.company_name,
"opening_type": 'Placement',
@ -335,11 +338,11 @@ def send_opening_notifications(placement_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
def exception_email(opening):
opening = opening.dict()
data = {
@ -348,7 +351,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'
attachment_jnf_respone = {
"name": name,
"html": pdfhtml,
@ -357,6 +360,7 @@ def exception_email(opening):
sendEmail(CDC_MAIl_ADDRESS, COMPANY_OPENING_ERROR_TEMPLATE.format(company_name=opening["company_name"]), data,
COMPANY_OPENING_SUBMITTED_TEMPLATE, attachment_jnf_respone)
def store_all_files(request):
files = request.FILES
data = request.data