Commit 1b37611c authored by Laury Bueno's avatar Laury Bueno
Browse files

[Certification] Add DATA_FIM to certiifcate templates

parent bd07b9f7
......@@ -195,6 +195,7 @@ class CourseCertificationDetailView(DetailView):
# {HORAS} : str(certificate.course.course_load)
# {TURMA} : certificate.course_student.get_current_class().name)
# {DATA_INICIO} : certificate.course_student.start_date
# {DATA_FIM} : certificate.course_student.finish_date
if '{MODULO}' in context['cert_template'].text:
context['cert_template'].text = context['cert_template'].text.replace(
......@@ -208,20 +209,27 @@ class CourseCertificationDetailView(DetailView):
certificate.student.cpf,
)
# Prepare start date
# Prepare start and finish dates
start_date = '{0}/{1}/{2}'.format(
certificate.course_student.start_date.day,
certificate.course_student.start_date.month,
certificate.course_student.start_date.year
)
finish_date = '{0}/{1}/{2}'.format(
certificate.course_student.finish_date.day,
certificate.course_student.finish_date.month,
certificate.course_student.finish_date.year
)
context['cert_template'].text = context['cert_template'].text\
.replace('{NOME}', certificate.student.get_full_name())\
.replace('{CONTRATO}', context['cert_template'].workspace.name)\
.replace('{NUM_UNIDADES}', str(certificate.course_total_units))\
.replace('{HORAS}', str(certificate.course.course_load))\
.replace('{TURMA}', certificate.course_student.get_current_class().name)\
.replace('{DATA_INICIO}', start_date)
.replace('{DATA_INICIO}', start_date)\
.replace('{DATA_FIM}', finish_date)
url_name = resolve(self.request.path_info).url_name
......
......@@ -369,6 +369,18 @@ class CourseStudent(models.Model):
def course_finished(self):
return self._course_finished()
@property
def finish_date(self):
if not self.course_finished:
return None
progress = StudentProgress.objects\
.exclude(complete=None)\
.filter(user=self.user, unit__lesson__course=self.course)\
.order_by('-complete')
return progress.first().complete
def can_emmit_receipt(self):
if not self.get_current_class().user_can_certificate and not self.course_finished:
return False
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment