Changeset - 1bfd0cc2f048
[Not reviewed]
0 3 0
James Tauber - 12 years ago 2012-08-02 02:59:41
jtauber@jtauber.com
implemented team apply
3 files changed with 34 insertions and 0 deletions:
0 comments (0 inline, 0 general)
symposion/teams/urls.py
Show inline comments
...
 
@@ -7,2 +7,3 @@ urlpatterns = patterns("symposion.teams.views",
 
    url(r"^(?P<slug>[\w\-]+)/leave/$", "team_leave", name="team_leave"),
 
    url(r"^(?P<slug>[\w\-]+)/apply/$", "team_apply", name="team_apply"),
 
    
symposion/teams/views.py
Show inline comments
...
 
@@ -31,2 +31,10 @@ def can_leave(team, user):
 

	
 
def can_apply(team, user):
 
    state = team.get_state_for_user(user)
 
    if team.access == "application" and state is None:
 
        return True
 
    else:
 
        return False
 

	
 

	
 
## views
...
 
@@ -46,2 +54,3 @@ def team_detail(request, slug):
 
        "can_leave": can_leave(team, request.user),
 
        "can_apply": can_apply(team, request.user),
 
    })
...
 
@@ -80 +89,18 @@ def team_leave(request, slug):
 
        return redirect("team_detail", slug=slug)
 

	
 

	
 
@login_required
 
def team_apply(request, slug):
 
    team = get_object_or_404(Team, slug=slug)
 
    state = team.get_state_for_user(request.user)
 
    if team.access == "invitation" and state is None:
 
        raise Http404()
 
    
 
    if can_apply(team, request.user) and request.method == "POST":
 
        membership, created = Membership.objects.get_or_create(team=team, user=request.user)
 
        membership.state = "applied"
 
        membership.save()
 
        # contrib.message
 
        return redirect("team_detail", slug=slug)
 
    else:
 
        return redirect("team_detail", slug=slug)
symposion_project/templates/teams/team_detail.html
Show inline comments
...
 
@@ -21,2 +21,9 @@
 
    
 
    {% if can_apply %}
 
        <form method="post" action="{% url team_apply team.slug %}">
 
            {% csrf_token %}
 
            <input type="submit" class="btn btn-primary" value="apply">
 
        </form>
 
    {% endif %}
 
    
 
{% endblock %}
0 comments (0 inline, 0 general)