18
18
from django .views .generic import ListView
19
19
from django .utils .decorators import method_decorator
20
20
from django .core .urlresolvers import reverse_lazy
21
-
21
+ from volunteer . utils import vol_id_check
22
22
23
23
class AdministratorLoginRequiredMixin (object ):
24
24
@@ -573,6 +573,10 @@ def sign_up(request, shift_id, volunteer_id):
573
573
class ViewHoursView (LoginRequiredMixin , FormView , TemplateView ):
574
574
template_name = 'shift/hours_list.html'
575
575
576
+ @method_decorator (vol_id_check )
577
+ def dispatch (self , * args , ** kwargs ):
578
+ return super (ViewHoursView , self ).dispatch (* args , ** kwargs )
579
+
576
580
def get_context_data (self , ** kwargs ):
577
581
context = super (ViewHoursView , self ).get_context_data (** kwargs )
578
582
volunteer_id = self .kwargs ['volunteer_id' ]
@@ -582,36 +586,15 @@ def get_context_data(self, **kwargs):
582
586
583
587
584
588
@login_required
589
+ @vol_id_check
585
590
def view_volunteer_shifts (request , volunteer_id ):
586
- user = request .user
587
- vol = None
588
-
589
- try :
590
- vol = user .volunteer
591
- except ObjectDoesNotExist :
592
- pass
591
+ shift_list = get_unlogged_shifts_by_volunteer_id (volunteer_id )
592
+ return render (
593
+ request ,
594
+ 'shift/volunteer_shifts.html' ,
595
+ {'shift_list' : shift_list , 'volunteer_id' : volunteer_id , }
596
+ )
593
597
594
- # check that a volunteer is logged in
595
- if vol :
596
- if volunteer_id :
597
- volunteer = get_volunteer_by_id (volunteer_id )
598
- if volunteer :
599
- user = request .user
600
- if int (user .volunteer .id ) == int (volunteer_id ):
601
- shift_list = get_unlogged_shifts_by_volunteer_id (volunteer_id )
602
- return render (
603
- request ,
604
- 'shift/volunteer_shifts.html' ,
605
- {'shift_list' : shift_list , 'volunteer_id' : volunteer_id , }
606
- )
607
- else :
608
- return HttpResponse (status = 403 )
609
- else :
610
- raise Http404
611
- else :
612
- raise Http404
613
- else :
614
- return HttpResponse (status = 403 )
615
598
616
599
617
600
class VolunteerSearchView (AdministratorLoginRequiredMixin , FormView ):
0 commit comments