Beispiel #1
0
    def dispatch(self, request, *args, **kwargs):
        """Where should we send the user off to next.

        If raise_exception is set to True, the server will return a
        forbidden response, disallowing the user to access the site's
        content.

        """
        age_gate_passed = request.session.get('age_gate_passed', False)

        if not age_gate_passed:
            if self.raise_exception:
                raise PermissionDenied
            else:
                return utils.redirect_to_age_gate(
                    request.get_full_path(),
                    reverse_lazy(self.age_gate_url)
                )

        return super(AgeGateMixin, self).dispatch(request, *args, **kwargs)