Example #1
0
 def create(self, username, password):
     return NotImplementedError()
     payload = { 'username':username, 'password':password }
     r = requests.post(self.url + '/rest/v1/sessions',data=payload)
     if r.status_code is not 200:
         raise UserClientError(r.text)
     return User.fromMap(r.json())
Example #2
0
 def submit(self):
     user = User.fromMap(self.cleaned_data)
     # check if username and email have not been used yet
     # if they have not then save the user
     if User.getByEmail(user.email) or User.getByUsername(user.username):
         raise UserConflictException()
     
     user.save()
     return UserSerializer(user).data
Example #3
0
 def update(self, user_id, username=None, password=None, email=None):
     payload = {}
     if username: payload['username'] = username
     if password: payload['password'] = password
     if email: payload['email'] = email
     
     headers = { 'HTTP_AUTHORIZATION' : self.session_id }
     
     r = requests.put(self.url + '/rest/v1/sessions/%s' % str(user_id), data=payload, headers=headers)
     if r.status_code is not 200:
         raise UserClientError(r.text)
     return User.fromMap(r.json())
Example #4
0
 def get(self, user_id):
     headers = { 'HTTP_AUTHORIZATION' : self.session_id }
     r = requests.delete(self.url + '/rest/v1/sessions/%s' % str(user_id), headers=headers)
     if r.status_code is not 200:
         raise UserClientError(r.text)
     return User.fromMap(r.json())