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/rpc.py

    r745 r756  
    125125#---------------------------------------------------------------------------------------
    126126
     127class Registration(object):
     128    """Data for registration."""
     129    def __init__(self, name, yearOfBirth, emailAddress, emailAddressPublic,
     130                 vatsimID, ivaoID, phoneNumber, nationality, password):
     131        """Construct the registration data."""
     132        self.name = name
     133        self.yearOfBirth = yearOfBirth
     134        self.emailAddress = emailAddress
     135        self.emailAddressPublic = 1 if emailAddressPublic is True else \
     136          0 if emailAddressPublic is False else emailAddressPublic
     137        self.vatsimID = "" if vatsimID is None else vatsimID
     138        self.ivaoID = "" if ivaoID is None else ivaoID
     139        self.phoneNumber = phoneNumber
     140        self.nationality = nationality
     141        self.password = password
     142
     143#---------------------------------------------------------------------------------------
     144
    127145class RPCException(Exception):
    128146    """An exception thrown by RPC operations."""
     
    155173    RESULT_DATABASE_ERROR = 3
    156174
     175    # Result code: invalid data
     176    RESULT_INVALID_DATA = 4
     177
    157178    # Result code: the flight does not exist
    158179    RESULT_FLIGHT_NOT_EXISTS = 101
     
    160181    # Result code: the flight has already been reported.
    161182    RESULT_FLIGHT_ALREADY_REPORTED = 102
     183
     184    # Result code: a user with the given e-mail address already exists
     185    RESULT_EMAIL_ALREADY_REGISTERED = 103
    162186
    163187    def __init__(self, getCredentialsFn):
     
    189213        self._sessionID = None
    190214
     215    def register(self, registrationData):
     216        """Register with the given data.
     217
     218        Returns a tuple of:
     219        - the error code,
     220        - the PID if there is no error."""
     221        reply = Reply(self._server.register(registrationData))
     222
     223        return (reply.result,
     224                reply.value["pid"] if reply.result==Client.RESULT_OK else None)
     225
    191226    def login(self):
    192227        """Login using the given previously set credentials.
     
    194229        The session ID is stored in the object and used for later calls.
    195230
    196         Returns a boolean indicating if login has succeeded."""
     231        Returns the name of the pilot on success, or None on error."""
    197232        self._sessionID = None
    198233
Note: See TracChangeset for help on using the changeset viewer.