implemented team accept/reject
This commit is contained in:
parent
bc9d5f5db6
commit
7fe481ee98
3 changed files with 34 additions and 0 deletions
|
@ -2,11 +2,15 @@ from django.conf.urls.defaults import *
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = patterns("symposion.teams.views",
|
urlpatterns = patterns("symposion.teams.views",
|
||||||
|
# team specific
|
||||||
url(r"^(?P<slug>[\w\-]+)/$", "team_detail", name="team_detail"),
|
url(r"^(?P<slug>[\w\-]+)/$", "team_detail", name="team_detail"),
|
||||||
url(r"^(?P<slug>[\w\-]+)/join/$", "team_join", name="team_join"),
|
url(r"^(?P<slug>[\w\-]+)/join/$", "team_join", name="team_join"),
|
||||||
url(r"^(?P<slug>[\w\-]+)/leave/$", "team_leave", name="team_leave"),
|
url(r"^(?P<slug>[\w\-]+)/leave/$", "team_leave", name="team_leave"),
|
||||||
url(r"^(?P<slug>[\w\-]+)/apply/$", "team_apply", name="team_apply"),
|
url(r"^(?P<slug>[\w\-]+)/apply/$", "team_apply", name="team_apply"),
|
||||||
|
|
||||||
|
# membership specific
|
||||||
url(r"^promote/(?P<pk>\d+)/$", "team_promote", name="team_promote"),
|
url(r"^promote/(?P<pk>\d+)/$", "team_promote", name="team_promote"),
|
||||||
url(r"^demote/(?P<pk>\d+)/$", "team_demote", name="team_demote"),
|
url(r"^demote/(?P<pk>\d+)/$", "team_demote", name="team_demote"),
|
||||||
|
url(r"^accept/(?P<pk>\d+)/$", "team_accept", name="team_accept"),
|
||||||
|
url(r"^reject/(?P<pk>\d+)/$", "team_reject", name="team_reject"),
|
||||||
)
|
)
|
||||||
|
|
|
@ -134,3 +134,29 @@ def team_demote(request, pk):
|
||||||
membership.save()
|
membership.save()
|
||||||
# contrib.message
|
# contrib.message
|
||||||
return redirect("team_detail", slug=membership.team.slug)
|
return redirect("team_detail", slug=membership.team.slug)
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def team_accept(request, pk):
|
||||||
|
if request.method == "POST":
|
||||||
|
membership = get_object_or_404(Membership, pk=pk)
|
||||||
|
state = membership.team.get_state_for_user(request.user)
|
||||||
|
if request.user.is_staff or state == "manager":
|
||||||
|
if membership.state == "applied":
|
||||||
|
membership.state = "member"
|
||||||
|
membership.save()
|
||||||
|
# contrib.message
|
||||||
|
return redirect("team_detail", slug=membership.team.slug)
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def team_reject(request, pk):
|
||||||
|
if request.method == "POST":
|
||||||
|
membership = get_object_or_404(Membership, pk=pk)
|
||||||
|
state = membership.team.get_state_for_user(request.user)
|
||||||
|
if request.user.is_staff or state == "manager":
|
||||||
|
if membership.state == "applied":
|
||||||
|
membership.state = "rejected"
|
||||||
|
membership.save()
|
||||||
|
# contrib.message
|
||||||
|
return redirect("team_detail", slug=membership.team.slug)
|
||||||
|
|
|
@ -61,6 +61,10 @@
|
||||||
{% for membership in team.applicants %}
|
{% for membership in team.applicants %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ membership.user.email }}</td>
|
<td>{{ membership.user.email }}</td>
|
||||||
|
<td>
|
||||||
|
<form style="margin: 0; float: left;" method="post" action="{% url team_accept membership.pk %}">{% csrf_token %}<button type="submit" class="btn btn-mini">accept</button></form>
|
||||||
|
<form style="margin: 0; float: left;" method="post" action="{% url team_reject membership.pk %}">{% csrf_token %}<button type="submit" class="btn btn-mini">reject</button></form>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
Loading…
Reference in a new issue