Skip to content

Commit

Permalink
Add join/leave to Actions menu when viewing group with permission to …
Browse files Browse the repository at this point in the history
…join or as a member
  • Loading branch information
mikhuang committed Jul 2, 2013
1 parent ae6e3d4 commit 1a9fe15
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions deme_django/cms/templatetags/item_tags.py
Expand Up @@ -418,6 +418,14 @@ def render(self, context):
if isinstance(item, Collection) and agentcan_helper(context, 'modify_membership', item):
list_items.append("""<li><a href="#" onclick="openDialogBox('addmember%(id)s'); return false;" tabindex="-1" title="Add an item into this collection" class="insert-item" data-target="addmember%(id)s"><i class="demeicon demeicon-add-collection"></i> Add to %(name)s</a></li>""" % {'id': item.pk, 'name': item_name })

# join/leave this collection
if isinstance(item, Group):
cur_agent_in_collection = item.child_memberships.filter(active=True, item=context['cur_agent']).exists()
if cur_agent_in_collection and agentcan_helper(context, 'remove_self', item):
list_items.append("""<li><a href="#" onclick="$('#removeselfformc%(identifier)s')[0].submit();" tabindex="-1" title="Remove my membership in %(name)s"><i class="glyphicon glyphicon-user"></i> Leave this group</a></li>""" % {'identifier':item.pk,'name': item_name})
if not cur_agent_in_collection and agentcan_helper(context, 'add_self', item):
list_items.append("""<li><a href="#" onclick="$('#addselfformc%(identifier)s')[0].submit();" tabindex="-1" title="Become a member of %(name)s"><i class="glyphicon glyphicon-user"></i> Join this group</a></li>""" % {'identifier':item.pk,'name': item_name})

if agentcan_global_helper(context, 'create %s' % item.item_type_string):
list_items.append('<li><a href="%s" tabindex="-1" title="Copy" class="copy"><i class="demeicon demeicon-copy"></i> Copy</a></li>' % copy_url)

Expand Down

0 comments on commit 1a9fe15

Please sign in to comment.