def get_static_from_tour_guide_popularity(start_date, end_date): """ Return an descending ordered list from tourguide's tours popularity between dates. You can find an example to call this method in testdatabase.py file. :param start_date: String that represent a date like this: "2015-09-01" :param end_date: same as start_date :return: """ list_of_tours = TourDAO.get_list_of_tours_between_dates(start_date, end_date) d = dict() for tour in list_of_tours: if tour.tour_guide_id in d: d[tour.tour_guide_id] += RegistrationDAO.get_registration_count_by_tour_id(tour.id) else: d[tour.tour_guide_id] = RegistrationDAO.get_registration_count_by_tour_id(tour.id) return_list = [] for key, value in d.items(): return_list.append((UserDAO.get_user_by_id(key).fullname, value)) return_list = sorted(return_list, key=StatisticDAO.get_key, reverse=True) return return_list
def get_static_from_tour_guide_popularity(start_date, end_date): """ Return an descending ordered list from tourguide's tours popularity between dates. You can find an example to call this method in testdatabase.py file. :param start_date: String that represent a date like this: "2015-09-01" :param end_date: same as start_date :return: """ list_of_tours = TourDAO.get_list_of_tours_between_dates( start_date, end_date) d = dict() for tour in list_of_tours: if tour.tour_guide_id in d: d[tour. tour_guide_id] += RegistrationDAO.get_registration_count_by_tour_id( tour.id) else: d[tour. tour_guide_id] = RegistrationDAO.get_registration_count_by_tour_id( tour.id) return_list = [] for key, value in d.items(): return_list.append((UserDAO.get_user_by_id(key).fullname, value)) return_list = sorted(return_list, key=StatisticDAO.get_key, reverse=True) return return_list
def get_tours(start_date, end_date): """ Return a list of tuple. Tuple contains a name and number of registered member. The return list is ordered. You can find an example to call this method in testdatabase.py file. :param start_date: String that represent a date like this: "2015-09-01" :param end_date: same as start_date :return: """ list_of_tours = TourDAO.get_id_list_of_tours_by_date( start_date, end_date) d = dict() for name, id in list_of_tours: d[id] = RegistrationDAO.get_registration_count_by_tour_id(id) return_list = [] for name, id in list_of_tours: return_list.append((name, d[id])) return_list = sorted(return_list, key=StatisticDAO.get_key, reverse=True) return return_list
def tours(current_page): tour_form = TourForm() if not tours_blueprint.current_items_per_page: tours_blueprint.current_items_per_page = \ tour_form.tours_per_page.default if not tours_blueprint.current_order_by: tours_blueprint.current_order_by = tour_form.order_by.default if tour_form.validate_on_submit(): tours_blueprint.current_items_per_page = tour_form.tours_per_page.data tours_blueprint.current_order_by = tour_form.order_by.data return redirect(url_for('tours.tours_default')) pagination = TourDAO.get_page_of_tours( current_page, tours_blueprint.current_items_per_page, tours_blueprint.current_order_by) app_tours = [] if current_user.is_authenticated: rows = RegistrationDAO.get_registrations_tour_ids_of_user(current_user) app_tours = [x[0] for x in rows] return render_template('tours.html', tour_form=tour_form, tours=pagination.items, pagination=pagination, items=tours_blueprint.current_items_per_page, sort=tours_blueprint.current_order_by, apply_tours=app_tours)
def view_tour(tour_id): tour = TourDAO.get_tour_by_id(tour_id) weathers = WeatherFactory(tour.place, 7).get_weathers() applyed = False if current_user.is_authenticated: applyed = RegistrationDAO.check_registrated(current_user, tour) delay = DelayTourForm() return render_template('tour-view.html', tour=tour, weathers=weathers, user=current_user, applyed=applyed)
def get_tours(start_date, end_date): """ Return a list of tuple. Tuple contains a name and number of registered member. The return list is ordered. You can find an example to call this method in testdatabase.py file. :param start_date: String that represent a date like this: "2015-09-01" :param end_date: same as start_date :return: """ list_of_tours = TourDAO.get_id_list_of_tours_by_date(start_date, end_date) d = dict() for name, id in list_of_tours: d[id] = RegistrationDAO.get_registration_count_by_tour_id(id) return_list = [] for name, id in list_of_tours: return_list.append((name, d[id])) return_list = sorted(return_list, key=StatisticDAO.get_key, reverse=True) return return_list
def test_get_registration_by_tour_id(self): print(RegistrationDAO.get_registration_count_by_tour_id(1)) self.assertEquals(True, True)