@require_POST
def confirm_member(request, url, user_pk):
 group = get_object_or_404(Group, url=url)
 profile = get_object_or_404(UserProfile, pk=user_pk)
 is_curator = (request.user.userprofile in group.curators.all())
 is_manager = request.user.userprofile.is_manager
 group_url = reverse('groups:show_group', args=[group.url])
 next_url = request.REQUEST.get('next_url', group_url)
 if (not (is_curator or is_manager)):
  raise Http404()
 try:
  membership = GroupMembership.objects.get(group=group, userprofile=profile)
 except GroupMembership.DoesNotExist:
  messages.error(request, _('This user has not requested membership in this group.'))
 else:
  if (membership.status == GroupMembership.MEMBER):
   messages.error(request, _('This user is already a member of this group.'))
  else:
   status = GroupMembership.MEMBER
   if group.terms:
    status = GroupMembership.PENDING_TERMS
   group.add_member(profile, status=status)
   messages.info(request, _('This user has been added as a member of this group.'))
 return redirect(next_url)

@ require_POST def confirm_member ( request , url , user_pk ) : group = get_object_or_404 ( Group , url = url ) profile = get_object_or_404 ( UserProfile , pk = user_pk ) is_curator = ( request . user . userprofile in group . curators . all ( ) ) is_manager = request . user . userprofile . is_manager group_url = reverse ( 'groups:show_group' , args = [ group . url ] ) next_url = request . REQUEST . get ( 'next_url' , group_url ) if ( not ( is_curator or is_manager ) ) : raise Http404 ( ) try : membership = GroupMembership . objects . get ( group = group , userprofile = profile ) except GroupMembership . DoesNotExist : messages . error ( request , _ ( 'This user has not requested membership in this group.' ) ) else : if ( membership . status == GroupMembership . MEMBER ) : messages . error ( request , _ ( 'This user is already a member of this group.' ) ) else : status = GroupMembership . MEMBER if group . terms : status = GroupMembership . PENDING_TERMS group . add_member ( profile , status = status ) messages . info ( request , _ ( 'This user has been added as a member of this group.' ) ) return redirect ( next_url )
add a member to a group who has requested membership .