コード例 #1
0
ファイル: Profile.py プロジェクト: kradecki/psinque
    def post(self):
      
        upload_files = self.get_uploads('files[]')  # 'file' is file upload field in the form
        blob_info = upload_files[0]
        
        img = images.Image(blob_key=str(blob_info.key()))
        
        # we must execute a transform to access the width/height
        img.im_feeling_lucky() # do a transform, otherwise GAE complains.

        # set quality to 1 so the result will fit in 1MB if the image is huge
        img.execute_transforms(output_encoding=images.JPEG,quality=1)

        user = users.get_current_user()
        userProfile = UserProfile.all().filter("user =", user).get()
        userPhoto = UserPhoto(parent = userProfile,
                              image = blob_info.key(),
                              width = img.width,
                              height = img.height,
                              servingUrl = images.get_serving_url(blob_info.key()))
        userPhoto.put()
        
        template = jinja_environment.get_template('templates/Profile_Thumbnail.html')
        self.response.out.write(template.render({
            'photo': userPhoto,
        }))
コード例 #2
0
ファイル: Profile.py プロジェクト: kradecki/psinque
    def removephoto(self):

        key = self.getRequiredParameter('key')

        try:
            photo = UserPhoto.get(key)
            
            for persona in Persona.all().filter("picture =", photo):
                persona.picture = None
                persona.put()
              
            photo.image.delete()
            photo.delete()
            
            self.sendJsonOK()

        except datastore_errors.BadKeyError:
            raise AjaxError("Photo not found.")
コード例 #3
0
ファイル: Personas.py プロジェクト: kradecki/psinque
    def setgeneral(self):

        try:
            persona = Persona.get(self.getRequiredParameter('key'))
              
            newName = self.request.get("name")
            if newName != "":
                persona.name = newName

            persona.canViewPrefix = self.getRequiredBoolParameter('prefix')
            persona.canViewGivenNames = self.getRequiredBoolParameter('givennames')
            persona.canViewRomanGivenNames = self.getRequiredBoolParameter('givennamesroman')
            persona.canViewFamilyNames = self.getRequiredBoolParameter('familynames')
            persona.canViewRomanFamilyNames = self.getRequiredBoolParameter('familynamesroman')
            persona.canViewSuffix = self.getRequiredBoolParameter('suffix')
            persona.canViewBirthday = self.getRequiredBoolParameter('birthday')
            persona.canViewGender = self.getRequiredBoolParameter('gender')
            
            company = self.request.get("company")
            if company != "None":
                persona.company = Key(company)
            else:
                persona.company = None
            
            nickname = self.request.get("nickname")
            if nickname != "None":
                persona.nickname = Key(nickname)
            else:
                persona.nickname = None

            photoKey = self.request.get("photo")
            if photoKey != "":
                photo = UserPhoto.get(photoKey)
                persona.picture = photo
            
            persona.put()

            generateVCard(persona)

            self.sendJsonOK()

        except datastore_errors.BadKeyError:
            raise AjaxError("Persona not found.")
コード例 #4
0
ファイル: DataManipulation.py プロジェクト: kradecki/psinque
def deleteProfile(userProfileKey):

    userProfile = UserProfile.get(userProfileKey)    
    
    for e in CardDAVLogin.all().ancestor(userProfile):
        e.delete()
    for e in IndividualPermit.all().ancestor(userProfile):
        e.delete()
    for e in Persona.all().ancestor(userProfile):
        e.delete()
    for e in Psinque.all().ancestor(userProfile):
        e.delete()
    for e in Contact.all().ancestor(userProfile):
        e.delete()
    for e in Group.all().ancestor(userProfile):
        e.delete()
    for e in UserAddress.all().ancestor(userProfile):
        e.delete()
    for e in UserEmail.all().ancestor(userProfile):
        e.delete()
    for e in UserIM.all().ancestor(userProfile):
        e.delete()
    for e in UserPhoneNumber.all().ancestor(userProfile):
        e.delete()
    for e in UserPhoto.all().ancestor(userProfile):
        e.image.delete()
        e.delete()
    for e in UserNickname.all().ancestor(userProfile):
        e.delete()
    for e in UserCompany.all().ancestor(userProfile):
        e.delete()
    for e in UserWebpage.all().ancestor(userProfile):
        e.delete()
    
    if not userProfile.userSettings is None:
        userProfile.userSettings.delete()
        
    userProfile.delete()
    logging.info("User profile deleted")