bornhack-website/src/teams/views/guide.py
Thomas Steen Rasmussen 00af109e2f
add flake8 and isort to pre-commit config, make flake8 and isort happy (#441)
* add flake8 to pre-commit config, and fixup many things to make flake8 happy

* add isort and sort all imports, add to pre-commit and requirements
2020-02-12 13:10:41 +01:00

30 lines
865 B
Python

from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin
from django.views.generic import DetailView
from camps.mixins import CampViewMixin
from ..models import Team, TeamMember
class TeamGuideView(LoginRequiredMixin, CampViewMixin, UserPassesTestMixin, DetailView):
template_name = "team_guide.html"
context_object_name = "team"
model = Team
slug_url_kwarg = "team_slug"
active_menu = "guide"
def test_func(self):
# Make sure that the user is an approved member of the team
try:
TeamMember.objects.get(
user=self.request.user, team=self.get_object(), approved=True
)
except TeamMember.DoesNotExist:
return False
else:
return True
class TeamGuidePrintView(TeamGuideView):
template_name = "team_guide_print.html"