diff --git a/src/teams/templates/team_members.html b/src/teams/templates/team_members.html
index 49a1e25a..b3fef15a 100644
--- a/src/teams/templates/team_members.html
+++ b/src/teams/templates/team_members.html
@@ -29,25 +29,26 @@
- {% for teammember in team.memberships.all %}
+ {% for member in team.memberships.all %}
+ {% if member.approved or not member.approved and request.user in team.responsible_members.all %}
- {{ teammember.user.profile.get_public_credit_name }} {% if teammember.user == request.user %}(this is you!){% endif %}
+ {{ member.user.profile.get_public_credit_name }} {% if member.user == request.user %}(this is you!){% endif %}
|
- Team {% if teammember.responsible %}Responsible{% else %}Member{% endif %}
- {% if not teammember.approved %}(pending approval){% endif %}
+ Team {% if member.responsible %}Responsible{% else %}Member{% endif %}
+ {% if not member.approved %}(pending approval){% endif %}
|
{% if request.user in team.responsible_members.all %}
|
{% endif %}
+ {% endif %}
{% empty %}
No members found!
{% endfor %}
diff --git a/src/teams/urls.py b/src/teams/urls.py
index 6c5adfd5..b4def544 100644
--- a/src/teams/urls.py
+++ b/src/teams/urls.py
@@ -16,6 +16,7 @@ from teams.views.members import (
)
from teams.views.info import (
+ InfoCategoriesListView,
InfoItemUpdateView,
InfoItemCreateView,
InfoItemDeleteView,
@@ -73,12 +74,12 @@ urlpatterns = [
path(
'/remove/',
TeamMemberRemoveView.as_view(),
- name='teammember_remove',
+ name='member_remove',
),
path(
'/approve/',
TeamMemberApproveView.as_view(),
- name='teammember_approve',
+ name='member_approve',
),
]),
),
@@ -112,26 +113,36 @@ urlpatterns = [
]),
),
path(
- 'info//', include([
+ 'info/',
+ include([
path(
- 'create/',
- InfoItemCreateView.as_view(),
- name='info_item_create',
+ '',
+ InfoCategoriesListView.as_view(),
+ name='info_categories'
),
path(
- '/', include([
+ '/', include([
path(
- 'update/',
- InfoItemUpdateView.as_view(),
- name='info_item_update',
+ 'create/',
+ InfoItemCreateView.as_view(),
+ name='info_item_create',
),
path(
- 'delete/',
- InfoItemDeleteView.as_view(),
- name='info_item_delete',
+ '/', include([
+ path(
+ 'update/',
+ InfoItemUpdateView.as_view(),
+ name='info_item_update',
+ ),
+ path(
+ 'delete/',
+ InfoItemDeleteView.as_view(),
+ name='info_item_delete',
+ ),
+ ]),
),
- ]),
- ),
+ ])
+ )
])
)
]),
diff --git a/src/teams/views/base.py b/src/teams/views/base.py
index 06c928e1..cce95e70 100644
--- a/src/teams/views/base.py
+++ b/src/teams/views/base.py
@@ -25,6 +25,7 @@ class TeamGeneralView(CampViewMixin, DetailView):
context_object_name = 'team'
model = Team
slug_url_kwarg = 'team_slug'
+ active_menu = 'general'
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
diff --git a/src/teams/views/info.py b/src/teams/views/info.py
index f2da0bcb..0d49162d 100644
--- a/src/teams/views/info.py
+++ b/src/teams/views/info.py
@@ -1,18 +1,39 @@
from django.contrib.auth.mixins import LoginRequiredMixin
from django.http import HttpResponseRedirect
-from django.views.generic import CreateView, UpdateView, DeleteView
+from django.views.generic import CreateView, UpdateView, DeleteView, ListView
from reversion.views import RevisionMixin
from camps.mixins import CampViewMixin
from info.models import InfoItem, InfoCategory
+from ..models import Team
from .mixins import EnsureTeamResponsibleMixin, TeamViewMixin
+class InfoCategoriesListView(LoginRequiredMixin, CampViewMixin, TeamViewMixin, EnsureTeamResponsibleMixin, ListView):
+ model = InfoCategory
+ template_name = "team_info_categories.html"
+ slug_field = 'anchor'
+ active_menu = 'info_categories'
+
+ def get_team(self):
+ return Team.objects.get(
+ camp__slug=self.kwargs['camp_slug'],
+ slug=self.kwargs['team_slug']
+ )
+
+
class InfoItemCreateView(LoginRequiredMixin, CampViewMixin, TeamViewMixin, EnsureTeamResponsibleMixin, CreateView):
model = InfoItem
- template_name = "info_item_form.html"
+ template_name = "team_info_item_form.html"
fields = ['headline', 'body', 'anchor', 'weight']
slug_field = 'anchor'
+ active_menu = 'info_categories'
+
+ def get_team(self):
+ return Team.objects.get(
+ camp__slug=self.kwargs['camp_slug'],
+ slug=self.kwargs['team_slug']
+ )
def form_valid(self, form):
info_item = form.save(commit=False)
@@ -24,13 +45,28 @@ class InfoItemCreateView(LoginRequiredMixin, CampViewMixin, TeamViewMixin, Ensur
def get_success_url(self):
return self.team.get_absolute_url()
+ def get_context_data(self, **kwargs):
+ context = super().get_context_data(**kwargs)
+ context['category'] = InfoCategory.objects.get(
+ team__camp__slug=self.kwargs['camp_slug'],
+ anchor=self.kwargs['category_anchor']
+ )
+ return context
+
class InfoItemUpdateView(LoginRequiredMixin, CampViewMixin, TeamViewMixin, EnsureTeamResponsibleMixin, RevisionMixin, UpdateView):
model = InfoItem
- template_name = "info_item_form.html"
+ template_name = "team_info_item_form.html"
fields = ['headline', 'body', 'anchor', 'weight']
slug_field = 'anchor'
slug_url_kwarg = 'item_anchor'
+ active_menu = 'info_categories'
+
+ def get_team(self):
+ return Team.objects.get(
+ camp__slug=self.kwargs['camp_slug'],
+ slug=self.kwargs['team_slug']
+ )
def get_success_url(self):
next = self.request.GET.get('next')
@@ -41,9 +77,16 @@ class InfoItemUpdateView(LoginRequiredMixin, CampViewMixin, TeamViewMixin, Ensur
class InfoItemDeleteView(LoginRequiredMixin, CampViewMixin, TeamViewMixin, EnsureTeamResponsibleMixin, RevisionMixin, DeleteView):
model = InfoItem
- template_name = "info_item_delete_confirm.html"
+ template_name = "team_info_item_delete_confirm.html"
slug_field = 'anchor'
slug_url_kwarg = 'item_anchor'
+ active_menu = 'info_categories'
+
+ def get_team(self):
+ return Team.objects.get(
+ camp__slug=self.kwargs['camp_slug'],
+ slug=self.kwargs['team_slug']
+ )
def get_success_url(self):
next = self.request.GET.get('next')
diff --git a/src/teams/views/members.py b/src/teams/views/members.py
index cbd03e00..8d050504 100644
--- a/src/teams/views/members.py
+++ b/src/teams/views/members.py
@@ -20,6 +20,7 @@ class TeamMembersView(CampViewMixin, DetailView):
context_object_name = 'team'
model = Team
slug_url_kwarg = 'team_slug'
+ active_menu = 'members'
class TeamJoinView(LoginRequiredMixin, CampViewMixin, UpdateView):
@@ -27,6 +28,7 @@ class TeamJoinView(LoginRequiredMixin, CampViewMixin, UpdateView):
model = Team
fields = []
slug_url_kwarg = 'team_slug'
+ active_menu = 'members'
def get(self, request, *args, **kwargs):
if not Profile.objects.get(user=request.user).description:
@@ -57,6 +59,7 @@ class TeamLeaveView(LoginRequiredMixin, CampViewMixin, UpdateView):
model = Team
fields = []
slug_url_kwarg = 'team_slug'
+ active_menu = 'members'
def get(self, request, *args, **kwargs):
if request.user not in self.get_object().members.all():
@@ -75,6 +78,7 @@ class TeamMemberRemoveView(LoginRequiredMixin, CampViewMixin, TeamViewMixin, Ens
template_name = "teammember_remove.html"
model = TeamMember
fields = []
+ active_menu = 'members'
def form_valid(self, form):
form.instance.delete()
@@ -92,6 +96,7 @@ class TeamMemberApproveView(LoginRequiredMixin, CampViewMixin, TeamViewMixin, En
template_name = "teammember_approve.html"
model = TeamMember
fields = []
+ active_menu = 'members'
def form_valid(self, form):
form.instance.approved = True
diff --git a/src/teams/views/tasks.py b/src/teams/views/tasks.py
index d18c2465..02b5ba29 100644
--- a/src/teams/views/tasks.py
+++ b/src/teams/views/tasks.py
@@ -12,18 +12,21 @@ class TeamTasksView(CampViewMixin, DetailView):
context_object_name = 'team'
model = Team
slug_url_kwarg = 'team_slug'
+ active_menu = 'tasks'
class TaskDetailView(CampViewMixin, TeamViewMixin, DetailView):
template_name = "task_detail.html"
context_object_name = "task"
model = TeamTask
+ active_menu = 'tasks'
class TaskCreateView(LoginRequiredMixin, CampViewMixin, TeamViewMixin, EnsureTeamResponsibleMixin, CreateView):
model = TeamTask
template_name = "task_form.html"
fields = ['name', 'description']
+ active_menu = 'tasks'
def get_team(self):
return Team.objects.get(
@@ -47,6 +50,7 @@ class TaskUpdateView(LoginRequiredMixin, CampViewMixin, TeamViewMixin, EnsureTea
model = TeamTask
template_name = "task_form.html"
fields = ['name', 'description']
+ active_menu = 'tasks'
def get_context_data(self, *args, **kwargs):
context = super().get_context_data(**kwargs)