samarth-p/College-ERP

It is not issue but a request

hamashoool opened this issue · 1 comments

You have done great work. but I would appreciate if you can make dynamic time period in here

def create_attendance(sender, instance, **kwargs):
    if kwargs['created']:
        start_date = instance.assign.start                    #date(2018, 8, 1)   
        end_date = instance.assign.end                        #date(2018, 11, 30)
        for single_date in daterange(start_date, end_date):
            if single_date.isoweekday() == days[instance.day]:
                try:
                    a = AttendanceClass.objects.get(date=single_date.strftime("%Y-%m-%d"), assign=instance.assign)
                except AttendanceClass.DoesNotExist:
                    a = AttendanceClass(date=single_date.strftime("%Y-%m-%d"), assign=instance.assign)
                    a.save()

I add two more columns in Assign table.

class Assign(models.Model):
    class_id = models.ForeignKey(Class, on_delete=models.CASCADE)
    course = models.ForeignKey(Course, on_delete=models.CASCADE)
    teacher = models.ForeignKey(Teacher, on_delete=models.CASCADE)

    #new added columns 
    start = models.DateField(null=True)
    end = models.DateField(null=True)

Then Instead of this

start_date = date(2018, 8, 1)

end_date = date(2018, 11, 30)

I did this something like this

start_date = instance.assign.start

end_date = instance.assign.end

but wen you create assign the attendance class time will show only one month.

can you solve this?

Thank you I just solve it