def userprofile(self): self.sendContent('templates/Admin_UserProfile.html', activeEntry = "", templateVariables = { 'userProfiles': UserProfile.all(), })
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, }))
def view(self): # form for editing details userProfile = UserProfile.all().filter("user ="******"Profile", templateVariables = { 'firstlogin': firstLogin, 'userProfile': userProfile, 'months': monthNames, 'primaryEmail': userProfile.emails.filter("primary =", True).get(), 'additionalEmails': userProfile.emails.filter("primary =", False).order('-creationTime').fetch(limit = 1000), 'phones': userProfile.phones.order('-creationTime').fetch(limit = 1000), 'ims': userProfile.ims.order('-creationTime').fetch(limit = 1000), 'wwws': userProfile.webpages.order('-creationTime').fetch(limit = 1000), 'addresses': userProfile.addresses.order('-creationTime').fetch(limit = 1000), 'nicknames': userProfile.nicknames.order('-creationTime').fetch(limit = 1000), 'companies': userProfile.companies.order('-creationTime').fetch(limit = 1000), 'genders': genders, 'countries': countries, 'imTypes': { x:imTypes for x in privacyTypes }, 'wwwTypes': { x:wwwTypes for x in privacyTypes }, 'phoneTypes': { x:phoneTypes for x in privacyTypes }, 'privacyTypes': privacyTypes, })
def getUserProfile(self): try: getattr(self, 'userProfile') return True except AttributeError: self.userProfile = UserProfile.all(keys_only = True).filter("user ="******"/profile/view") return False self.userProfile = UserProfile.get(self.userProfile) return True
def getUserProfile(self): ''' Retrieves the UserProfile for the current user from the Datastore. If the profile does not exist, the user is redirected to the profile edit page. ''' try: getattr(self, "userProfile") return True except AttributeError: self.userProfile = UserProfile.all(keys_only = True).filter("user ="******"/profile/view") return False self.userProfile = UserProfile.get(self.userProfile) # retrieve actual data from datastore return True