mhall119 has proposed merging lp:~mhall119/loco-directory/fixes-583913 into 
lp:loco-directory.

Requested reviews:
  loco-directory-dev (loco-directory-dev)
Related bugs:
  #583913 Don't show "join this team" link if already a member of the team
  https://bugs.launchpad.net/bugs/583913


Only display 'Edit Details', 'Add Event' and 'Join this team' links when 
appropriate given the user's status.
-- 
https://code.launchpad.net/~mhall119/loco-directory/fixes-583913/+merge/26300
Your team loco-directory-dev is requested to review the proposed merge of 
lp:~mhall119/loco-directory/fixes-583913 into lp:loco-directory.
=== modified file 'loco_directory/teams/views.py'
--- loco_directory/teams/views.py	2010-05-17 14:28:41 +0000
+++ loco_directory/teams/views.py	2010-05-28 13:13:34 +0000
@@ -74,8 +74,15 @@
 
 def team_detail(request, team_slug):
     team_object = get_object_or_404(Team, lp_name=team_slug)
+    is_member = False
+    is_admin = False
+    if request.user.is_authenticated():
+        is_member = launchpad.is_team_member(request.user, team_object)
+        is_admin = launchpad.is_admin_or_owner(request.user.username, team_object)
     context = {
         'team': team_object,
+        'is_member' : is_member,
+        'is_admin' : is_admin,
     }
     return render_to_response('teams/team_detail.html', 
                                          context, RequestContext(request))

=== modified file 'loco_directory/templates/teams/team_detail.html'
--- loco_directory/templates/teams/team_detail.html	2010-05-04 05:58:12 +0000
+++ loco_directory/templates/teams/team_detail.html	2010-05-28 13:13:34 +0000
@@ -17,8 +17,8 @@
     <div id="options-right">
         {% if user.is_authenticated %}
         <ul>
-            <li><a class="option edit" href="{% url team-edit team.lp_name %}" title="{% trans "Edit team details." %}">&nbsp;</a></li>
-            <li><a class="option add-team-event" href="{% url team-event-new team.lp_name %}" title="{% trans "Add new Event." %}">&nbsp;</a></li>
+        	{% if is_admin %}<li><a class="option edit" href="{% url team-edit team.lp_name %}" title="{% trans "Edit team details." %}">&nbsp;</a></li>{% endif %}
+            {% if is_member %}<li><a class="option add-team-event" href="{% url team-event-new team.lp_name %}" title="{% trans "Add new Event." %}">&nbsp;</a></li>{% endif %}
         </ul>
         {% endif %}
     </div>
@@ -40,7 +40,7 @@
     </tr>
 	<tr>
 	  <th scope="row"><label>{% trans "Launchpad Page:" %}</label></th>
-	  <td><a href="https://launchpad.net/~{{ team.lp_name }}">{{ team.name }}</a> (<a href="https://launchpad.net/~{{ team.lp_name }}/+join">{% trans "Join this team!" %}</a>)</td>
+	  <td><a href="https://launchpad.net/~{{ team.lp_name }}">{{ team.name }}</a>{% if is_member %}{% else %} (<a href="https://launchpad.net/~{{ team.lp_name }}/+join">{% trans "Join this team!" %}</a>){% endif %}</td>
 	</tr>
 
         <tr>

_______________________________________________
Mailing list: https://launchpad.net/~loco-directory-dev
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~loco-directory-dev
More help   : https://help.launchpad.net/ListHelp

Reply via email to