Ignore:
Timestamp:
01/11/16 15:56:23 (8 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
hg-Phase:
(<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
Message:

Implemented the basic GUI logic of the registration (re #285)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/web.py

    r746 r756  
    22import const
    33import util
     4from rpc import Registration
    45import rpc
    56import rpccommon
     
    620621        super(RPCRequest, self).__init__(callback)
    621622        self._client = client
     623
     624#------------------------------------------------------------------------------
     625
     626class Register(RPCRequest):
     627    """A registration request."""
     628    def __init__(self, client, callback, registrationData):
     629        """Construct the request."""
     630        super(Register, self).__init__(client, callback)
     631        self._registrationData = registrationData
     632
     633    def run(self):
     634        """Perform the registration."""
     635
     636        registrationData = self._registrationData
     637
     638        (resultCode, pilotID) = self._client.register(registrationData)
     639        result = Result()
     640        result.registered = resultCode==rpc.Client.RESULT_OK
     641        if result.registered:
     642            result.pilotID = pilotID
     643
     644            self._client.setCredentials(pilotID, registrationData.password)
     645            loginResult = self._client.login()
     646            result.loggedIn = loginResult is not None
     647
     648        result.invalidData = \
     649          resultCode==rpc.Client.RESULT_INVALID_DATA
     650        result.emailAlreadyRegistered = \
     651          resultCode==rpc.Client.RESULT_EMAIL_ALREADY_REGISTERED
     652
     653        return result
    622654
    623655#------------------------------------------------------------------------------
     
    11341166            self._rpcClient.setCredentials(config.pilotID, config.password)
    11351167
     1168    def register(self, callback, registrationData):
     1169        """Enqueue a registration request."""
     1170        self._addRequest(Register(self._rpcClient, callback, registrationData))
     1171
    11361172    def login(self, callback, pilotID, password, entranceExam = False):
    11371173        """Enqueue a login request."""
Note: See TracChangeset for help on using the changeset viewer.