Example #1
0
def lists_template(apps,accounts,client=None):
    from idapi.models import UserList, UserListMember, get_auid
    portal = apps['portal']
    debug = apps['debug']
    users = accounts.values()
    auids = [get_auid(portal,user).uuid for user in users]

    info = dict(foo=3)
    if client:
        response, out = api(client,'app/lists/','post',dict(users=auids,name='test',info=info),app=portal)
        assert response.status_code == 201 and 'ulid' in out
        ulid = out['ulid']
        response, out = api(client,'app/lists/%s/'%ulid,app=portal)
        assert response.status_code == 200
        n = len(users)
        assert out == dict(name='test',info=info,users=auids,total=n,maxid=n,nusers=n)

        response, out = api(client,'app/lists/%s/'%ulid,app=debug)
        assert response.status_code == 200
        dauids = [get_auid(debug,user).uuid for user in users]
        assert out == dict(name='test',info=info,users=dauids,total=n,maxid=n,nusers=n)
    else:
        ulist = UserList.objects.create(name='test',info=info,owner=portal)
        for user in users:
            UserListMember.objects.create(userlist=ulist,member=user)
Example #2
0
 def destroy(self, request, ulid, pos, format=None):
     member = request.ulistmember
     if member is None: raise Http404
     member.delete(client=request.auth)
     auid = get_auid(request,member).uuid
     notify_list(request.ulist.ulid,'modify')
     return Response({'auid':auid,'position':pos},status=status.HTTP_204_NO_CONTENT)
Example #3
0
 def destroy(self, request, ulid, pos, format=None):
     #print 'destroy',ulid, pos, request.__dict__, format
     member = request.ulistmember
     if member is None: raise Http404
     member.delete(client=request.auth)
     auid = get_auid(request, member).uuid
     return Response({
         'auid': auid,
         'position': pos
     },
                     status=status.HTTP_204_NO_CONTENT)
Example #4
0
def test_auid(apps,accounts,tokens,client):
    from idapi.models import get_auid
    from accounts.models import Account
    portal = apps['portal']
    debug = apps['debug']
    user = accounts['member1']
    auid = get_auid(portal,user).uuid
    token = tokens['member1']

    response, out = api(client,'user/auid/',token=token)
    assert response.status_code == 200 and out['auid']==auid
Example #5
0
 def list(self, request, ulid, format=None):
     if request.method == 'HEAD': return Response()
     ulist = request.ulist
     query = ulist.members.order_by('no').all()
     users = []
     last = 1
     for user in query:
         while last < user.no:
             users.append('') # fill up empty
             last += 1
         auid = get_auid(request.auth,user.member)
         users.append(auid.uuid)
         last += 1
     return Response({'name':ulist.name,'info':ulist.info,'maxid':ulist.maxno,'total':ulist.members.count(),
             'nusers':len(users),'users':users})
Example #6
0
 def get(self, request, format=None):
     from idapi.models import get_auid
     token = request.auth
     user = token.user
     auid = get_auid(token.application,user)
     return Response({'auid':auid.uuid})