def get(self, request, *args, **kwargs): excuse = Excuse.objects.get(pk=self.kwargs['pk']) brother = excuse.brother if not verify_brother(brother, request.user): messages.error(request, "Brother Access Denied!") return HttpResponseRedirect(reverse('dashboard:home')) return super(ExcuseEdit, self).get(request, *args, **kwargs)
def get(self, request, *args, **kwargs): submission = ServiceSubmission.objects.get(pk=self.kwargs['pk']) brother = submission.brother if not verify_brother(brother, request.user): messages.error(request, "Brother Access Denied!") return HttpResponseRedirect(reverse('dashboard:home')) return super(ServiceSubmissionEdit, self).get(request, *args, **kwargs)
def finish_thursday_detail(request, detail_id): """Marks a Thursday Detail as done, by either its owner or the detail manager""" detail = ThursdayDetail.objects.get(pk=detail_id) if not verify_brother(detail.brother, request.user): if request.user.brother not in Position.objects.get( title=Position.PositionChoices.DETAIL_MANAGER ).brothers.all(): messages.error(request, "That's not your detail!") return HttpResponseRedirect(reverse('dashboard:home')) if request.method == 'POST' and not detail.done: detail.done = True detail.finished_time = datetime.datetime.now() detail.save() context = {'detail': detail} return render(request, 'finish-thursday-detail.html', context)