def deserialize(doc): '''Deserializes the object from a list of 4 elements''' permi = ElementPermissions(doc[ElementPermissions.SERIAL_ID], doc[ElementPermissions.SERIAL_IS_PRIVATE]) permi.read = Permissions.deserialize(doc[ElementPermissions.SERIAL_READ]) permi.write = Permissions.deserialize(doc[ElementPermissions.SERIAL_WRITE]) return permi
def deserialize(doc): '''Deserializes the object from a list of 4 elements''' permi = ElementPermissions(doc[ElementPermissions.SERIAL_ID], doc[ElementPermissions.SERIAL_IS_PRIVATE]) permi.read = Permissions.deserialize( doc[ElementPermissions.SERIAL_READ]) permi.write = Permissions.deserialize( doc[ElementPermissions.SERIAL_WRITE]) return permi
def deserialize(doc): brl = BRLUser(doc[User.SERIAL_ID_KEY]) user = User(brl) user._encrypted_password = doc[User.SERIAL_ENCRYPTED_PASSWORD] user.password_timestamp = doc.get(User.SERIAL_PASSWORD_TIMESTAMP, None) if User.SERIAL_NUMERIC_ID in doc: user.numeric_id = ID.deserialize(doc[User.SERIAL_NUMERIC_ID]) # Profile fields user.firstname = doc.get(User.SERIAL_FIRSTNAME, None) user.lastname = doc.get(User.SERIAL_LASTNAME, None) user.country = doc.get(User.SERIAL_COUNTRY, None) user.description = doc.get(User.SERIAL_DESCRIPTION, None) user.email = doc.get(User.SERIAL_EMAIL, None) user.visible_email = doc.get(User.SERIAL_VISIBLE_EMAIL, 0) == 1 user.allow_mailing = doc.get(User.SERIAL_ALLOW_MAILING, 0) == 1 user.active = doc.get(User.SERIAL_ACTIVE, 0) == 1 user.staff = doc.get(User.SERIAL_STAFF, 0) == 1 user.joined_date = UtcDatetime.deserialize( doc.get(User.SERIAL_JOINED_DATE, None)) user.confirmation_date = UtcDatetime.deserialize( doc.get(User.SERIAL_CONFIRMATION_DATE, None)) user.confirmation_token = doc.get(User.SERIAL_CONFIRMATION_TOKEN, None) # Old workspace methods user.block_counter = doc.get(User.SERIAL_MOD_COUNTER, 0) blocks_data = doc.get(User.SERIAL_BLOCKS, {}) user.blocks = DictDeserializer( BRLBlock, BlockMetaInfoDeserializer).deserialize(blocks_data) user.administrators = Permissions.deserialize( doc.get(User.SERIAL_ADMINISTRATORS, {})) social_accounts_doc = doc.get(User.SERIAL_SOCIAL_ACCOUNTS) user.social_accounts = DictDeserializer( str, SocialAccount).deserialize(social_accounts_doc) # Achievements user.read_api_counter = doc.get(User.SERIAL_READ_API_COUNTER, 0) user.publish_counter = doc.get(User.SERIAL_PUBLISH_COUNTER, 0) user.reuse_counter = doc.get(User.SERIAL_REUSE_COUNTER, 0) # Additional profile fields user.street_1 = doc.get(User.SERIAL_STREET1, "") user.street_2 = doc.get(User.SERIAL_STREET2, "") user.city = doc.get(User.SERIAL_CITY, "") user.postal_code = doc.get(User.SERIAL_POSTAL_CODE, "") user.region = doc.get(User.SERIAL_REGION, "") user.tax_id = doc.get(User.SERIAL_TAX_ID, "") user.vat = doc.get(User.SERIAL_VAT, "") # OAuth user.oauth_github_token = doc.get(User.SERIAL_OAUTH_GITHUB_TOKEN, None) user.oauth_google_token = doc.get(User.SERIAL_OAUTH_GOOGLE_TOKEN, None) # Max workspace size, default BII_MAX_USER_WORKSPACE_SIZE user.max_workspace_size = doc.get(User.SERIAL_MAX_WORKSPACE_SIZE, BII_MAX_USER_WORKSPACE_SIZE) # Invited by user.invited_by = doc.get(User.SERIAL_INVITED_BY, None) return user
def deserialize(doc): brl = BRLUser(doc[User.SERIAL_ID_KEY]) user = User(brl) user._encrypted_password = doc[User.SERIAL_ENCRYPTED_PASSWORD] user.password_timestamp = doc.get(User.SERIAL_PASSWORD_TIMESTAMP, None) if User.SERIAL_NUMERIC_ID in doc: user.numeric_id = ID.deserialize(doc[User.SERIAL_NUMERIC_ID]) # Profile fields user.firstname = doc.get(User.SERIAL_FIRSTNAME, None) user.lastname = doc.get(User.SERIAL_LASTNAME, None) user.country = doc.get(User.SERIAL_COUNTRY, None) user.description = doc.get(User.SERIAL_DESCRIPTION, None) user.email = doc.get(User.SERIAL_EMAIL, None) user.visible_email = doc.get(User.SERIAL_VISIBLE_EMAIL, 0) == 1 user.allow_mailing = doc.get(User.SERIAL_ALLOW_MAILING, 0) == 1 user.active = doc.get(User.SERIAL_ACTIVE, 0) == 1 user.staff = doc.get(User.SERIAL_STAFF, 0) == 1 user.joined_date = UtcDatetime.deserialize(doc.get(User.SERIAL_JOINED_DATE, None)) user.confirmation_date = UtcDatetime.deserialize(doc.get(User.SERIAL_CONFIRMATION_DATE, None)) user.confirmation_token = doc.get(User.SERIAL_CONFIRMATION_TOKEN, None) # Old workspace methods user.block_counter = doc.get(User.SERIAL_MOD_COUNTER, 0) blocks_data = doc.get(User.SERIAL_BLOCKS, {}) user.blocks = DictDeserializer(BRLBlock, BlockMetaInfoDeserializer).deserialize(blocks_data) user.administrators = Permissions.deserialize(doc.get(User.SERIAL_ADMINISTRATORS, {})) social_accounts_doc = doc.get(User.SERIAL_SOCIAL_ACCOUNTS) user.social_accounts = DictDeserializer(str, SocialAccount).deserialize(social_accounts_doc) # Achievements user.read_api_counter = doc.get(User.SERIAL_READ_API_COUNTER, 0) user.publish_counter = doc.get(User.SERIAL_PUBLISH_COUNTER, 0) user.reuse_counter = doc.get(User.SERIAL_REUSE_COUNTER, 0) # Additional profile fields user.street_1 = doc.get(User.SERIAL_STREET1, "") user.street_2 = doc.get(User.SERIAL_STREET2, "") user.city = doc.get(User.SERIAL_CITY, "") user.postal_code = doc.get(User.SERIAL_POSTAL_CODE, "") user.region = doc.get(User.SERIAL_REGION, "") user.tax_id = doc.get(User.SERIAL_TAX_ID, "") user.vat = doc.get(User.SERIAL_VAT, "") # OAuth user.oauth_github_token = doc.get(User.SERIAL_OAUTH_GITHUB_TOKEN, None) user.oauth_google_token = doc.get(User.SERIAL_OAUTH_GOOGLE_TOKEN, None) # Max workspace size, default BII_MAX_USER_WORKSPACE_SIZE user.max_workspace_size = doc.get(User.SERIAL_MAX_WORKSPACE_SIZE, BII_MAX_USER_WORKSPACE_SIZE) # Invited by user.invited_by = doc.get(User.SERIAL_INVITED_BY, None) return user