clear_rooms.py 440 Bytes
Newer Older
Daniel W Bond's avatar
pep8 me    
Daniel W Bond committed
1
2
3
from django.core.management.base import BaseCommand
from accounts.models import Student

4
5
6
7

class Command(BaseCommand):
    args = ""
    help = "Deletes all students' rooms at the end of the semester"
Daniel W Bond's avatar
pep8 me    
Daniel W Bond committed
8

9
10
11
12
    def handle(self, *args, **kwargs):
        count = 0
        for student in Student.objects.all():
            student.room = None
Daniel W Bond's avatar
pep8 me    
Daniel W Bond committed
13
            count += 1
Briana N Abraham's avatar
Briana N Abraham committed
14

15
        self.stdout.write("Successfully overwrote %d student room(s)." % count)