def get_photos_from_date(self): """ Fetches a list of photos which apply to the given filter This function should be able to handle listing directories (for instance, month directories in the year or days in each month) as well as actually rendering photos. """ year, month, day = self._get_id_from_path("").split(os.sep) offset = self._get_from_query("page", 1) - 1 limit = self._get_from_query("limit", S.DEFAULT_PER_PAGE) num_photos = Photo.get_count_by_date(year=year, month=month, day=day) start_index = (offset * limit) + 1 end_index = min(((offset + 1) * limit), num_photos) photos = Photo.get_by_date(year=year, month=month, day=day, limit=limit, offset=(offset * limit)) tokens = { "photos": photos, "offset": offset, "limit": limit, "start_index": start_index, "end_index": end_index, "num_photos": num_photos } return self.construct_response(Template.render("photos/list.html", tokens))
def get_photos_from_date(self): """ Fetches a list of photos which apply to the given filter This function should be able to handle listing directories (for instance, month directories in the year or days in each month) as well as actually rendering photos. """ year, month, day = self._get_id_from_path("").split(os.sep) offset = self._get_from_query("page", 1) - 1 limit = self._get_from_query("limit", S.DEFAULT_PER_PAGE) num_photos = Photo.get_count_by_date(year=year, month=month, day=day) start_index = (offset * limit) + 1 end_index = min(((offset + 1) * limit), num_photos) photos = Photo.get_by_date(year=year, month=month, day=day, limit=limit, offset=(offset * limit)) tokens = { "photos": photos, "offset": offset, "limit": limit, "start_index": start_index, "end_index": end_index, "num_photos": num_photos } return self.construct_response( Template.render("photos/list.html", tokens))