# Path: clubManagement/models.py
# class Attendance(models.Model):
#     user = models.ForeignKey(User, on_delete=models.CASCADE)
#     added_by = models.ForeignKey(User, on_delete=models.CASCADE,
#                                  related_name="added_by")
#     date = models.DateField()
#     modified_date = models.DateTimeField(auto_now=True, auto_now_add=False)
#     attendance = models.BooleanField(default=False)
# 
#     def __str__(self):
#         if self.attendance:
#             return self.user.username + " " + str(self.date) + " - present"
#         else:
#             return self.user.username + " " + str(self.date) + " - absent"


import csv
from datetime import date
from django.core.management import BaseCommand
from clubManagement.models import Attendance
from registration.models import UserInfo
        for user_info in user_info_list:
            if user_info.user.is_active and not user_info.is_mentor:
                user_list.append(user_info.user)

        if user_list:
            user_data[year] = user_list

    return user_data


def return_location_date_user_list(date_user_list, date):
    i = 0
    for date_user in date_user_list:
        if date_user[0] == date:
            return i
        i += 1
    date_user_list.append([date, []])
    return i


class Command(BaseCommand):
    help = 'Command to convert status update to csv'

    def handle(self, *args, **options):
        user_list_dict = get_active_users()

        for year, user_list in user_list_dict.items():
            date_user_list = []

            for user in user_list:

# Path: clubManagement/models.py
# class Attendance(models.Model):
#     user = models.ForeignKey(User, on_delete=models.CASCADE)
#     added_by = models.ForeignKey(User, on_delete=models.CASCADE,
#                                  related_name="added_by")
#     date = models.DateField()
#     modified_date = models.DateTimeField(auto_now=True, auto_now_add=False)
#     attendance = models.BooleanField(default=False)
# 
#     def __str__(self):
#         if self.attendance:
#             return self.user.username + " " + str(self.date) + " - present"
#         else:
#             return self.user.username + " " + str(self.date) + " - absent"


# Path: clubManagement/management/commands/attendance_to_csv.py
import csv
from datetime import date
from django.core.management import BaseCommand
from clubManagement.models import Attendance
from registration.models import UserInfo

        for user_info in user_info_list:
            if user_info.user.is_active and not user_info.is_mentor:
                user_list.append(user_info.user)

        if user_list:
            user_data[year] = user_list

    return user_data


def return_location_date_user_list(date_user_list, date):
    i = 0
    for date_user in date_user_list:
        if date_user[0] == date:
            return i
        i += 1
    date_user_list.append([date, []])
    return i


class Command(BaseCommand):
    help = 'Command to convert status update to csv'

    def handle(self, *args, **options):
        user_list_dict = get_active_users()

        for year, user_list in user_list_dict.items():
            date_user_list = []

            for user in user_list:

                attendance_list = Attendance.objects.filter(user=user).\