Untitled
unknown
plain_text
6 months ago
4.7 kB
3
Indexable
Never
from table import Table from table.columns import Column from table.utils import Accessor from master.models import * from django.utils.safestring import mark_safe from django.utils.html import format_html from student.utils import get_s3_url from django.conf import settings from datetime import timedelta class LatestColumn(Column): def render(self, value): data = Accessor(self.field).resolve(value) if data: id_card_obj = IdCardGenerationLog.objects.get( id = data) date_time = id_card_obj.generation_datetime d2 = date_time + timedelta(hours = 5, minutes=30) return d2.strftime("%d-%b-%y %H:%M") return '' class IdCardColumn(Column): def render(self, value): data = Accessor(self.field).resolve(value) try: s3file_name_id = "Coursera_id_generation/id_card/{}.pdf".format(data) # id_card = get_s3_url(s3file_name_id) IdCard = IdCardGenerationLog.objects.filter(coursera_student_id__student_id=data).last() uploadstudentphoto_object = CourseraStudent.objects.get( student_id=data) uuid_id_field = uploadstudentphoto_object.uuid_id pre_url2 = '{}/student/download-qrcode/?key=Coursera_id_generation/id_card/{}.pdf'.format(settings.BASE_URL,uuid_id_field) if IdCard.id_card_path: return mark_safe('<a href="{}" target="_blank" id="">ID Card </a>'.format(pre_url2)) else: return mark_safe('<p></p>') except: return '' class CustomColumnGovt(Column): ''' Display input and blank instead of None ''' def render(self, value): file_path_govt_id = "{}/{}".format(settings.MEDIA_ROOT,value.govt_id) govt_url2 = '{}/student/downloads3govtid/?key=Coursera_id_generation/gov_id/{}.{}'.format(settings.BASE_URL,value.uuid_id,file_path_govt_id.split(".")[-1].lower()) if value.govt_id: return mark_safe('<a href="{}" target="_blank" id="">govt ID </a>'.format(govt_url2)) else: return mark_safe('<p>-</p>') class CustomColumnPhoto(Column): ''' Display input and blank instead of None ''' def render(self, value): file_path_photo = "{}/{}".format(settings.MEDIA_ROOT,value.photo) photo_url2 = '{}/student/downloads3photo/?key=Coursera_id_generation/photo/{}.{}'.format(settings.BASE_URL,value.uuid_id,file_path_photo.split(".")[-1].lower()) if value.photo: return mark_safe('<a href="{}" target="_blank" id="">student photo </a>'.format(photo_url2)) else: return mark_safe('<p>-</p>') class CustomCheckboxColumnAccept(Column): ''' Display input and blank instead of None ''' def render(self, value): if value.photo_id_acceptance_flag==1: return mark_safe("""<input type="checkbox" id='{}-accept' name='{}@#@#$status_ac' onclick="checkacceptance(this)" checked='checked'>""".format(value,value)) else: return mark_safe("""<input type="checkbox" id='{}-accept' name='{}@#@#$status_ac' onclick="checkacceptance(this)" >""".format(value,value)) class CustomCheckboxColumnReject(Column): ''' Display input and blank instead of None ''' def render(self, value): if value.photo_id_acceptance_flag==0: return mark_safe("""<input type="checkbox" id='{}-reject' checked='checked' name='{}@#@#$status_rj' onclick="checkrejection(this)" >""".format(value,value)) else: return mark_safe("""<input type="checkbox" id='{}-reject' name='{}@#@#$status_rj' onclick="checkrejection(this)" >""".format(value,value)) class CustomCommentColumn(Column): ''' Display input and blank instead of None ''' def render(self, value): if value.photo_id_acceptance_flag==0: return mark_safe("""<input type="text" id='{}-comment' name='{}@#@#$comment' style="width:90%" value='{}'>""".format(value,value,value.rejection_comments)) else: return mark_safe("""<input type="text" id='{}-comment' name='{}@#@#$comment' style="width:90%" disabled>""".format(value,value)) class GeneratedbyColumn(Column): def render(self, value): data = Accessor(self.field).resolve(value) if data: id_card_obj = IdCardGenerationLog.objects.filter(coursera_student_id__student_id=data, admit_card_term_id__id=value.latest_admit_term_id) if id_card_obj: return id_card_obj.last().generated_by return '' class CustomDatetimeColumn(Column): def render(self, value): if value: return value.last_upd_datetime.strftime('%Y-%m-%d %I:%M%p') else: return ''
Leave a Comment