Example #1
0
    def Created(self, obj):
        p_date = jd(obj.created).strftime('%C')
        display_text = f'<p style="font-family: \'samim\';">{p_date}</p>'
        # return mark_safe(display_text)

        e_date = date_point = jd(obj.created).strftime('%Q')
        return e_date
Example #2
0
    def Date(self, obj):
        p_date = jd(obj.created).strftime('%C')
        display_text = f'<p style="font-family: \'samim\';">{p_date}</p>'
        # return mark_safe(display_text)

        e_date = date_point = jd(obj.created).strftime('%Q')
        return e_date
    
    # def get_readonly_fields(self, request, obj = None):
    #     return [f.name for f in self.model._meta.fields] 
Example #3
0
    def clean_start_time(self, *args, **kwargs):
        year, month, day = self.cleaned_data['start_time'].strftime(
            '%Y-%m-%d').split('-')
        hours, minutes, seconds = self.cleaned_data['start_time'].strftime(
            '%H:%M:%S').split(':')
        shamsi = jd(int(year), int(month), int(day), int(hours), int(minutes),
                    int(seconds))

        # import pdb; pdb.set_trace()
        four_hours_later = jd.now() + timedelta(hours=4)
        result = four_hours_later - shamsi.now()
        threshold = result.total_seconds() / 3600
        if threshold < 4:
            raise forms.ValidationError(
                'مدت انتظار هر سفر حداقل چهار ساعت است.')

        # return converted to miladi
        return shamsi.todatetime()
Example #4
0
 def updated_at(self, obj):
     return jd(obj.updated)
Example #5
0
 def created_at(self, obj):
     return jd(obj.created)
Example #6
0
 def published(self, obj):
     return jd(obj.published_at)