def get_profile_image(self): primary_image = Image.query( ndb.AND( Image.reference_key == self.session.get('user_id'), Image.active == True)).order(-Image.image_creation_date).get() if primary_image is not None: return images.get_serving_url(primary_image.image_key) else: return None
def set_profile_image(self, user_id): profile_image = Image.query( ndb.AND(Image.reference_key == user_id, Image.image_type == 1)).order(-Image.image_creation_date).get() if profile_image: self.session['Profile_url'] = images.get_serving_url( profile_image.image_key) + "=s100-c" else: self.session['Profile_url'] = None
def get_main_picture(self, id): main_image = Image.query(ndb.AND(Image.reference_key == id, Image.active == True), ancestor=PICTURE_PARENT_KEY).get() if main_image: main_image = images.get_serving_url( main_image.image_key) + "=s150-c" return main_image
def get_user_profile_main_image(self, user_id, image_size='', default_image=None): user_image = Image.query(Image.reference_key == user_id).order( -Image.image_creation_date).get() if user_image: print user_image user_image.serving_url = images.get_serving_url( user_image.image_key) return user_image.serving_url + image_size else: return default_image
def getProfilePictures(self, id): main_image = None image = None image = Image.query( ndb.AND(Image.reference_key == id, Image.active == True)).order(-Image.image_creation_date) image.fetch(limit=6) if image: for a in image: a.serving_url = images.get_serving_url(a.image_key) + "=s800-c" main_image = [] for a in image: main_image.append( images.get_serving_url(a.image_key) + "=s800-c") main_image.append(a.image_key) break return image, main_image