Example #1
0
    def submit(self):
        try:
            session = Session.getByID(self.cleaned_data['session_id'])
        except CassaNotFoundException:
            raise SessionNotFoundException()

        session.delete()
        return SessionSerializer(session).data
Example #2
0
 def submit(self):
     
     # get the original session
     try:
         session = Session.getByID(self.cleaned_data['session_id'])
     except CassaNotFoundException:
         raise SessionNotFoundException()
     session.update(self.cleaned_data)
     session.save()
     
     return SessionSerializer(session).data
Example #3
0
 def submit(self):
     user = User.getByUsername(self.cleaned_data['username'])
     if not user:
         raise SessionAuthorizationException()
     
     if not user.authenticate(self.cleaned_data['password']):
         raise SessionAuthorizationException()
     
     self.cleaned_data['user_id'] = UUID(user.user_id)
     del self.cleaned_data['username']
     del self.cleaned_data['password']
     session = Session.fromMap(self.cleaned_data)
 
     session.save()
     return SessionSerializer(session).data
Example #4
0
 def delete(self, session_id):
     r = requests.delete(self.url + '/rest/v1/sessions/%s' % str(session_id))
     if r.status_code is not 200:
         raise SessionClientError(r.text)
     return Session.fromMap(r.json())
Example #5
0
 def create(self, username, password):
     payload = { 'username':username, 'password':password }
     r = requests.post(self.url + '/rest/v1/sessions',data=payload)
     if r.status_code is not 200:
         raise SessionClientError(r.text)
     return Session.fromMap(r.json())