start work on #123

This commit is contained in:
Stephan Telling 2017-05-07 17:55:31 +02:00
parent 73eaf5bae4
commit 3395fe8bd5
4 changed files with 95 additions and 1 deletions

View file

@ -301,6 +301,11 @@ 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+]+)/$',

8
src/teams/forms.py Normal file
View file

@ -0,0 +1,8 @@
from django.forms import ModelForm
from .models import Team
class ManageTeamForm(ModelForm):
class Meta:
model = Team
fields = ['description', 'needs_members']

View file

@ -0,0 +1,68 @@
{% 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

@ -1,10 +1,12 @@
from django.views.generic import ListView, DetailView from django.views.generic import ListView, DetailView
from django.views.generic.edit import UpdateView from django.views.generic.edit import UpdateView, FormView
from camps.mixins import CampViewMixin from camps.mixins import CampViewMixin
from .models import Team, TeamMember from .models import Team, TeamMember
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):
@ -58,3 +60,14 @@ class TeamLeaveView(LoginRequiredMixin, CampViewMixin, UpdateView):
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)