Пример #1
0
def createNewProfile(user):

    # Create an empty profile
    userProfile = UserProfile(user = user)
    userProfile.put()  # save the new (and empty) profile in the Datastore in order to obtain its key
    logging.info("New profile created, key = " + str(userProfile.key()))

    # User settings
    userSettings = UserSettings(parent = userProfile)
    userSettings.put()
    userProfile.userSettings = userSettings

    # Primary email address (needed for notifications, etc.)
    userEmail = UserEmail(parent = userProfile,
                          itemValue = user.email(),  # "*****@*****.**"
                          privacyType = 'Home',
                          primary = True)
    userEmail.put()

    userProfile.defaultGroup  = createNewGroup(userProfile, 'Default')
    userProfile.defaultPersona = createNewPersona(userProfile, 'Default', userEmail)
    userProfile.publicPersona  = createNewPersona(userProfile, 'Public', userEmail)

    # Save the updated user profile
    userProfile.put()

    
    nickname = UserNickname(parent = userProfile,
                            itemValue = user.nickname())
    nickname.put()

    return userProfile
Пример #2
0
    def addemail(self):

        email = self._checkNewItemByName(UserEmail, 'email')
        email = email.lower()

        userEmail = UserEmail(parent = self.userProfile,
                              itemValue = email,
                              privacyType = self.getRequiredParameter('privacy'),
                              primary = self.getRequiredBoolParameter('primary'))
        userEmail.put()

        # Add permissions for this email in every outgoing group
        for persona in self.userProfile.personas:
            permitEmail = PermitEmail(parent = persona,
                                      userEmail = userEmail)
            permitEmail.put()

        self._updateAllVCards()

        self.sendJsonOK({'key': str(userEmail.key())})