@require_POST
def join_group(request, url):
 group = get_object_or_404(Group, url=url)
 profile_to_add = request.user.userprofile
 if group.has_member(profile_to_add):
  messages.error(request, _('You are already in this group.'))
 elif group.has_pending_member(profile_to_add):
  messages.error(request, _('Your request to join this group is still pending.'))
 elif (group.accepting_new_members == 'no'):
  messages.error(request, _('This group is not accepting requests to join.'))
 else:
  if (group.accepting_new_members == 'yes'):
   status = GroupMembership.MEMBER
   messages.info(request, _('You have been added to this group.'))
   if group.terms:
    status = GroupMembership.PENDING_TERMS
  elif (group.accepting_new_members == 'by_request'):
   status = GroupMembership.PENDING
   messages.info(request, _('Your membership request has been sent to the group curator(s).'))
  group.add_member(profile_to_add, status=status)
 return redirect(reverse('groups:show_group', args=[group.url]))

@ require_POST def join_group ( request , url ) : group = get_object_or_404 ( Group , url = url ) profile_to_add = request . user . userprofile if group . has_member ( profile_to_add ) : messages . error ( request , _ ( 'You are already in this group.' ) ) elif group . has_pending_member ( profile_to_add ) : messages . error ( request , _ ( 'Your request to join this group is still pending.' ) ) elif ( group . accepting_new_members == 'no' ) : messages . error ( request , _ ( 'This group is not accepting requests to join.' ) ) else : if ( group . accepting_new_members == 'yes' ) : status = GroupMembership . MEMBER messages . info ( request , _ ( 'You have been added to this group.' ) ) if group . terms : status = GroupMembership . PENDING_TERMS elif ( group . accepting_new_members == 'by_request' ) : status = GroupMembership . PENDING messages . info ( request , _ ( 'Your membership request has been sent to the group curator(s).' ) ) group . add_member ( profile_to_add , status = status ) return redirect ( reverse ( 'groups:show_group' , args = [ group . url ] ) )
user request to join group .