views.py 1.44 KB
Newer Older
1 2
from django.views.generic import DetailView, ListView, CreateView, UpdateView, DeleteView

3 4
from housing.models import Building, Room
from accounts.models import Student
5

6 7
from braces.views import LoginRequiredMixin

8 9 10 11 12 13 14 15
# a list of neighborhoods and their buildings
class ListBuildings(LoginRequiredMixin, ListView):
    model = Building
    login_url = '/'

# building floors, other information
class DetailBuilding(LoginRequiredMixin, DetailView):
    model = Building
16
    context_object_name = 'building'
17 18 19 20 21 22
    template_name='detailBuilding.html'

    def get_context_data(self, **kwargs):
        context = super(DetailBuilding, self).get_context_data(**kwargs)
        context['room_list'] = Room.objects.filter(building__name=''+self.get_object().name).order_by('number')
        return context
23 24 25 26 27 28 29 30 31 32 33 34
    login_url = '/'

# this lists the rooms on the floor
class ListRooms(LoginRequiredMixin, ListView):
    model = Room
    login_url = '/'

# this lists students in a room
class DetailRoom(LoginRequiredMixin, ListView):
    model = Room
    login_url = '/'

35
# update a student
36 37 38 39 40 41
#class UpdateStudent(LoginRequiredMixin, UpdateView):
#    model = Student
#    form_class = '/'
#    success_url = '/' # change the success url to something more interesting

#    login_url = '/'
42 43

# update a room
44 45 46 47
#class updateroom(loginrequiredmixin, updateview):
#    model = room
#    form_class =
#    success_url = '/' # change the success url to something more interesting
48

49
#    login_url = '/'