make manage page part of detail page

This commit is contained in:
Stephan Telling 2017-05-21 16:05:31 +02:00
parent 3395fe8bd5
commit 06a24c5899
4 changed files with 57 additions and 93 deletions

View file

@ -1,16 +1,10 @@
from allauth.account.views import (
SignupView,
LoginView,
LogoutView,
ConfirmEmailView,
EmailVerificationSentView,
PasswordResetView
)
from django.conf import settings
from django.conf.urls import include, url
from django.contrib import admin
from django.views.generic import TemplateView, RedirectView
from django.core.urlresolvers import reverse_lazy
from camps.views import *
from info.views import *
from villages.views import *
@ -301,11 +295,6 @@ urlpatterns = [
TeamLeaveView.as_view(),
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
url(
r'(?P<slug>[-_\w+]+)/$',

View file

@ -1,6 +1,7 @@
{% extends 'base.html' %}
{% load commonmark %}
{% load teams_tags %}
{% load bootstrap3 %}
{% block title %}
Team: {{ team.name }} | {{ block.super }}
@ -33,4 +34,58 @@ Team: {{ team.name }} | {{ block.super }}
<li><b>{{ resp.get_full_name|default:"Unnamed" }}</b></li>
{% endfor %}
</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 %}

View file

@ -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 %}

View file

@ -6,7 +6,6 @@ from .forms import ManageTeamForm
from django.contrib.auth.mixins import LoginRequiredMixin
from django.shortcuts import redirect
from django.contrib import messages
from django.http import Http404
class TeamListView(CampViewMixin, ListView):
@ -15,9 +14,10 @@ class TeamListView(CampViewMixin, ListView):
context_object_name = 'teams'
class TeamDetailView(CampViewMixin, DetailView):
class TeamDetailView(CampViewMixin, DetailView, UpdateView, FormView):
template_name = "team_detail.html"
model = Team
form_class = ManageTeamForm
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()
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)
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)