def create_photo_with_url(cls, url, real_file, mime, **settings): dbphoto = DBPhoto.create(url=url, mime=mime, real_file=real_file) dbphoto.save() _ = dbphoto.stats # init stats photo = cls(dbphoto) photo.update(**settings) return photo
def create_photo(cls, binary, **settings): url, real_file, url_thumb, real_file_thumb, mime = save_photo(binary, settings['file_name']) dbphoto = DBPhoto.create(url=url, mime=mime, real_file=real_file) dbphoto.url_thumb = url_thumb dbphoto.real_file_thumb = real_file_thumb dbphoto.save() _ = dbphoto.stats # init stats photo = cls(dbphoto) photo.update(**settings) return photo
def create_photo(cls, binary, **settings): url, real_file, url_thumb, real_file_thumb, mime = save_photo(binary) dbphoto = DBPhoto.create(url=url, mime=mime, real_file=real_file) dbphoto.url_thumb = url_thumb dbphoto.real_file_thumb = real_file_thumb dbphoto.save() _ = dbphoto.stats # init stats photo = cls(dbphoto) photo.update(**settings) return photo
def hot_photos(cls, count=12, order="like_count desc"): return DBPhoto.hot_photos(count, order)
def get_by_id(cls, id): dbphoto = DBPhoto.get_by_id(id) return dbphoto and cls(dbphoto)