make manage page part of detail page
This commit is contained in:
parent
3395fe8bd5
commit
06a24c5899
|
@ -1,16 +1,10 @@
|
||||||
from allauth.account.views import (
|
from allauth.account.views import (
|
||||||
SignupView,
|
|
||||||
LoginView,
|
LoginView,
|
||||||
LogoutView,
|
LogoutView,
|
||||||
ConfirmEmailView,
|
|
||||||
EmailVerificationSentView,
|
|
||||||
PasswordResetView
|
|
||||||
)
|
)
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.conf.urls import include, url
|
from django.conf.urls import include, url
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.views.generic import TemplateView, RedirectView
|
|
||||||
from django.core.urlresolvers import reverse_lazy
|
|
||||||
from camps.views import *
|
from camps.views import *
|
||||||
from info.views import *
|
from info.views import *
|
||||||
from villages.views import *
|
from villages.views import *
|
||||||
|
@ -301,11 +295,6 @@ urlpatterns = [
|
||||||
TeamLeaveView.as_view(),
|
TeamLeaveView.as_view(),
|
||||||
name='team_leave'
|
name='team_leave'
|
||||||
),
|
),
|
||||||
url(
|
|
||||||
r'(?P<slug>[-_\w+]+)/manage/$',
|
|
||||||
TeamManageView.as_view(),
|
|
||||||
name='team_manage'
|
|
||||||
),
|
|
||||||
# this has to be the last url in the list
|
# this has to be the last url in the list
|
||||||
url(
|
url(
|
||||||
r'(?P<slug>[-_\w+]+)/$',
|
r'(?P<slug>[-_\w+]+)/$',
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
{% load commonmark %}
|
{% load commonmark %}
|
||||||
{% load teams_tags %}
|
{% load teams_tags %}
|
||||||
|
{% load bootstrap3 %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
Team: {{ team.name }} | {{ block.super }}
|
Team: {{ team.name }} | {{ block.super }}
|
||||||
|
@ -33,4 +34,58 @@ Team: {{ team.name }} | {{ block.super }}
|
||||||
<li><b>{{ resp.get_full_name|default:"Unnamed" }}</b></li>
|
<li><b>{{ resp.get_full_name|default:"Unnamed" }}</b></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
{% if request.user in team.responsible %}
|
||||||
|
|
||||||
|
<h3>Manage {{ team.name }} Team</h3>
|
||||||
|
<form method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
|
||||||
|
{% bootstrap_form form %}
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
{% buttons %}
|
||||||
|
<button class="btn btn-primary pull-right" type="submit">Save</button>
|
||||||
|
{% endbuttons %}
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
|
||||||
|
<table class="table table-bordered table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
Profile
|
||||||
|
<th >
|
||||||
|
Name
|
||||||
|
<th>
|
||||||
|
Status
|
||||||
|
<th>
|
||||||
|
Email
|
||||||
|
<th>
|
||||||
|
Description
|
||||||
|
<th>
|
||||||
|
Action
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
{% for member in team.teammember_set.all %}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
{{ member.user }}
|
||||||
|
<td>
|
||||||
|
{{ member.user.profile.name }}
|
||||||
|
<td>
|
||||||
|
{{ member.approved }}
|
||||||
|
<td>
|
||||||
|
{{ member.user.profile.email }}
|
||||||
|
<td>
|
||||||
|
{{ member.user.profile.description }}
|
||||||
|
<td>
|
||||||
|
TBD
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -1,68 +0,0 @@
|
||||||
{% extends 'base.html' %}
|
|
||||||
{% load commonmark %}
|
|
||||||
{% load teams_tags %}
|
|
||||||
{% load bootstrap3 %}
|
|
||||||
|
|
||||||
{% block title %}
|
|
||||||
Team: {{ team.name }} | {{ block.super }}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
|
|
||||||
<h3>Manage {{ team.name }} Team</h3>
|
|
||||||
|
|
||||||
{% if request.user in team.responsible or team.area.responsible %}
|
|
||||||
<form method="post">
|
|
||||||
{% csrf_token %}
|
|
||||||
|
|
||||||
{% bootstrap_form form %}
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
|
|
||||||
{% buttons %}
|
|
||||||
<button class="btn btn-primary pull-right" type="submit">Save</button>
|
|
||||||
{% endbuttons %}
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<h2>Memberships of the {{ team.name }} team</h2>
|
|
||||||
|
|
||||||
<table class="table table-bordered table-hover">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>
|
|
||||||
Profile
|
|
||||||
<th >
|
|
||||||
Name
|
|
||||||
<th>
|
|
||||||
Status
|
|
||||||
<th>
|
|
||||||
Email
|
|
||||||
<th>
|
|
||||||
Description
|
|
||||||
|
|
||||||
<tbody>
|
|
||||||
{% for member in team.teammember_set.all %}
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
{{ member.user }}
|
|
||||||
<td>
|
|
||||||
{{ member.user.profile.name }}
|
|
||||||
<td>
|
|
||||||
<!-- TODO: idea is to make the opposite thumps capable of changing the status -->
|
|
||||||
{% if member.approved %}
|
|
||||||
<i class="fa fa-thumbs-o-up"></i> <!--(<i class="fa fa-thumbs-o-down"></i>)-->
|
|
||||||
{% else %}
|
|
||||||
<i class="fa fa-thumbs-o-down"></i> <!--(<i class="fa fa-thumbs-o-up"></i>)-->
|
|
||||||
{% endif %}
|
|
||||||
<td>
|
|
||||||
{{ member.user.profile.email }}
|
|
||||||
<td>
|
|
||||||
{{ member.user.profile.description }}
|
|
||||||
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
{% endblock %}
|
|
|
@ -6,7 +6,6 @@ from .forms import ManageTeamForm
|
||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
from django.shortcuts import redirect
|
from django.shortcuts import redirect
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.http import Http404
|
|
||||||
|
|
||||||
|
|
||||||
class TeamListView(CampViewMixin, ListView):
|
class TeamListView(CampViewMixin, ListView):
|
||||||
|
@ -15,9 +14,10 @@ class TeamListView(CampViewMixin, ListView):
|
||||||
context_object_name = 'teams'
|
context_object_name = 'teams'
|
||||||
|
|
||||||
|
|
||||||
class TeamDetailView(CampViewMixin, DetailView):
|
class TeamDetailView(CampViewMixin, DetailView, UpdateView, FormView):
|
||||||
template_name = "team_detail.html"
|
template_name = "team_detail.html"
|
||||||
model = Team
|
model = Team
|
||||||
|
form_class = ManageTeamForm
|
||||||
context_object_name = 'team'
|
context_object_name = 'team'
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,15 +59,3 @@ class TeamLeaveView(LoginRequiredMixin, CampViewMixin, UpdateView):
|
||||||
TeamMember.objects.filter(team=self.get_object(), user=self.request.user).delete()
|
TeamMember.objects.filter(team=self.get_object(), user=self.request.user).delete()
|
||||||
messages.success(self.request, "You are no longer a member of the team %s" % self.get_object().name)
|
messages.success(self.request, "You are no longer a member of the team %s" % self.get_object().name)
|
||||||
return redirect('team_list', camp_slug=self.get_object().camp.slug)
|
return redirect('team_list', camp_slug=self.get_object().camp.slug)
|
||||||
|
|
||||||
|
|
||||||
class TeamManageView(LoginRequiredMixin, CampViewMixin, UpdateView, FormView):
|
|
||||||
template_name = 'team_manage.html'
|
|
||||||
model = Team
|
|
||||||
form_class = ManageTeamForm
|
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
|
||||||
if not request.user.is_staff:
|
|
||||||
raise Http404()
|
|
||||||
|
|
||||||
return super().get(request, *args, **kwargs)
|
|
||||||
|
|
Loading…
Reference in a new issue