fix user check

This commit is contained in:
Thomas Steen Rasmussen 2017-03-14 18:06:23 +01:00
parent e316ebbb44
commit d159844750

View file

@ -28,7 +28,7 @@ class ProposalListView(LoginRequiredMixin, CampViewMixin, ListView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
# add eventproposals to the context # also add eventproposals to the context
context['eventproposal_list'] = models.EventProposal.objects.filter(camp=self.camp, user=self.request.user) context['eventproposal_list'] = models.EventProposal.objects.filter(camp=self.camp, user=self.request.user)
return context return context
@ -38,6 +38,9 @@ class SpeakerProposalCreateView(LoginRequiredMixin, CampViewMixin, CreateProposa
fields = ['name', 'biography', 'picture_small', 'picture_large'] fields = ['name', 'biography', 'picture_small', 'picture_large']
template_name = 'speakerproposal_form.html' template_name = 'speakerproposal_form.html'
def get_success_url(self):
return reverse('proposal_list', kwargs={'camp_slug': self.camp.slug})
class SpeakerProposalUpdateView(LoginRequiredMixin, CampViewMixin, EnsureUserOwnsProposalMixin, EnsureUnapprovedProposalMixin, EnsureWritableCampMixin, UpdateView): class SpeakerProposalUpdateView(LoginRequiredMixin, CampViewMixin, EnsureUserOwnsProposalMixin, EnsureUnapprovedProposalMixin, EnsureWritableCampMixin, UpdateView):
model = models.SpeakerProposal model = models.SpeakerProposal
@ -78,8 +81,8 @@ class SpeakerProposalPictureView(LoginRequiredMixin, CampViewMixin, EnsureUserOw
model = models.SpeakerProposal model = models.SpeakerProposal
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
# is the speaker public, or owned by current user? # is the proposal owned by current user?
if not self.get_object().user != request.user: if self.get_object().user != request.user:
raise Http404() raise Http404()
# do we have the requested picture? # do we have the requested picture?
@ -94,6 +97,7 @@ class SpeakerProposalPictureView(LoginRequiredMixin, CampViewMixin, EnsureUserOw
else: else:
raise Http404() raise Http404()
else: else:
# only 'thumbnail' and 'large' pictures supported
raise Http404() raise Http404()
# make nginx return the picture using X-Accel-Redirect # make nginx return the picture using X-Accel-Redirect