Пример #1
0
def get_user(request):
    cookies = request._request.META['HTTP_COOKIE']
    cookies = cookies.replace(' ', '').split(';')
    uid = ''
    for cookie in cookies:
        uid = cookie.replace(' ', '')
        if uid.startswith('uid='):
            uid = uid.replace('uid=', '')
    assert_uid_valid(uid)
    return UserNode.get_or_create({'uid': uid})[0]
Пример #2
0
 def post(self, request, tid):
     print 'request.data', request.data
     uid = request.data['uid']
     user = UserNode.get_or_create({'uid': uid})[0]
     task = user.tasks.get(tid=tid)
     target_task = None
     if 'target_tid' in request.data:
         target_tid = request.data['target_tid']
         target_task = TaskInst.nodes.get(tid=target_tid)
     task = user.upload(task, target_task)
     return Response(task.get_info())
Пример #3
0
 def post(self,
          request,
          user,
          task,
          username,
          super_role=SUPER_ROLE.STANDARD,
          role=None):
     target_user = get_user_by_username(username)
     target_user_node = UserNode.get_or_create({'uid':
                                                target_user['uid']})[0]
     user.invite(task, target_user_node, super_role, role)
     return Response({
         'basic':
         target_user,
         'has_task':
         target_user_node.tasks.relationship(task).get_info()
     })
Пример #4
0
 def post(self, request, user, task, uid):
     assert_uid_valid(uid)
     target_user = UserNode.get_or_create({'uid': uid})[0]
     user.revoke_invitation(task, target_user)
     return Response('SUCCESS')
Пример #5
0
 def post(self, request, tid):
     uid = request.data['uid']
     user = UserNode.get_or_create({'uid': uid})[0]
     task = TaskInst.nodes.get(tid=tid)
     new_task = user.download(task)
     return Response(new_task.get_info())