def get(self, vanity_url=None, start_date=None, bk=None):
     """
         Display Booking Schedule
     """
     # provoder already selection from public profile
     period = timedelta(days=7)
     provider = db.get_provider_from_vanity_url(vanity_url)
     start_date, week_nav = self.calculate_start_date_and_week_navigation(start_date, period)
     schedules = provider.get_schedules()
     confirmed_bookings = provider.get_future_confirmed_bookings()
     # logging.info('SCHEDULES %s' % schedules.fetch())
     available_datetimes_map = util.generate_complete_datetimes_dict(
         schedules, start_date, period, confirmed_bookings
     )
     # logging.info( 'SCHEDULES DICT %s' % schedule_datetimes_dict)
     # available_datetimes_map = util.remove_confirmed_bookings_from_schedule(schedule_datetimes_dict, confirmed_bookings)
     self.render_template(
         "provider/public/booking_schedule.html", provider=provider, dtm=available_datetimes_map, week_nav=week_nav
     )
 def get(self, vanity_url=None, start_date=None, bk=None):
     '''
         Display Booking Schedule
     '''
     # provoder already selection from public profile
     period = timedelta(days=7)
     provider = db.get_provider_from_vanity_url(vanity_url)
     start_date, week_nav = self.calculate_start_date_and_week_navigation(
         start_date, period)
     schedules = provider.get_schedules()
     confirmed_bookings = provider.get_future_confirmed_bookings()
     #logging.info('SCHEDULES %s' % schedules.fetch())
     available_datetimes_map = util.generate_complete_datetimes_dict(
         schedules, start_date, period, confirmed_bookings)
     #logging.info( 'SCHEDULES DICT %s' % schedule_datetimes_dict)
     #available_datetimes_map = util.remove_confirmed_bookings_from_schedule(schedule_datetimes_dict, confirmed_bookings)
     self.render_template('provider/public/booking_schedule.html',
                          provider=provider,
                          dtm=available_datetimes_map,
                          week_nav=week_nav)
Example #3
0
    def get(self, vanity_url=None):
        # convert to lowercase
        vanity_url = vanity_url.lower()

        logging.info(
            '(ProviderPublicProfileHandler.get) Received vanity_url: %s' %
            vanity_url)
        provider = db.get_provider_from_vanity_url(vanity_url)
        if provider:
            logging.info(
                '(ProviderPublicProfileHandler.get) Found provider %s, rendering profile'
                % provider.email)

            # set the display language to provider's preference
            language = provider.profile_language
            if language:
                self.set_language(language)
            else:
                self.set_language(util.DEFAULT_LANG)

            # add some dates & times to display part of schedule on page
            start_date = time.tomorrow()
            period = timedelta(days=14)

            schedules = provider.get_schedules()
            confirmed_bookings = provider.get_future_confirmed_bookings()
            datetimes_map = util.generate_complete_datetimes_dict(
                schedules, start_date, period, confirmed_bookings)
            #
            #datetimes_map = util.remove_confirmed_bookings_from_schedule(schedule_datetimes_dict, confirmed_bookings)

            dtm = datetimes_map

            date_time_list = []

            # flatten the map and give first 5 results
            # TODO: sort
            count = 0
            for (day_key, day_times) in dtm.items():
                if count >= 5:
                    break

                for t in day_times:
                    date_time_list.append((day_key, day_times, t))
                    count += 1
                    if count >= 5:
                        break

            date_time_list = sorted(date_time_list, key=itemgetter(0, 2))

            # found a provider, render profile
            self.render_public_profile(
                provider=provider, date_time_list=date_time_list)

            # increment view count, store async
            # we don't really care if it doesn't work
            # old --> use event log instead
            provider.profile_views += 1
            provider.put_async()

            # log the event
            user = self.get_current_user()
            if user and user.key == provider.user:
                self.log_event(
                    user=provider.user, msg="Public profile: self-view")
            else:
                self.log_event(
                    user=provider.user, msg="Public profile: public view")

        else:
            logging.info(
                '(ProviderPublicProfileHandler.get) No provider found, sending to index'
            )

            # nobody found, send them to the homepage
            self.redirect("/")
Example #4
0
    def get(self, vanity_url=None):
        # convert to lowercase
        vanity_url = vanity_url.lower()

        logging.info(
            '(ProviderPublicProfileHandler.get) Received vanity_url: %s' %
            vanity_url)
        provider = db.get_provider_from_vanity_url(vanity_url)
        if provider:
            logging.info(
                '(ProviderPublicProfileHandler.get) Found provider %s, rendering profile'
                % provider.email)

            # set the display language to provider's preference
            language = provider.profile_language
            if language:
                self.set_language(language)
            else:
                self.set_language(util.DEFAULT_LANG)

            # add some dates & times to display part of schedule on page
            start_date = time.tomorrow()
            period = timedelta(days=14)

            schedules = provider.get_schedules()
            confirmed_bookings = provider.get_future_confirmed_bookings()
            datetimes_map = util.generate_complete_datetimes_dict(
                schedules, start_date, period, confirmed_bookings)
            #
            #datetimes_map = util.remove_confirmed_bookings_from_schedule(schedule_datetimes_dict, confirmed_bookings)

            dtm = datetimes_map

            date_time_list = []

            # flatten the map and give first 5 results
            # TODO: sort
            count = 0
            for (day_key, day_times) in dtm.items():
                if count >= 5:
                    break

                for t in day_times:
                    date_time_list.append((day_key, day_times, t))
                    count += 1
                    if count >= 5:
                        break

            date_time_list = sorted(date_time_list, key=itemgetter(0, 2))

            # found a provider, render profile
            self.render_public_profile(provider=provider,
                                       date_time_list=date_time_list)

            # increment view count, store async
            # we don't really care if it doesn't work
            # old --> use event log instead
            provider.profile_views += 1
            provider.put_async()

            # log the event
            user = self.get_current_user()
            if user and user.key == provider.user:
                self.log_event(user=provider.user,
                               msg="Public profile: self-view")
            else:
                self.log_event(user=provider.user,
                               msg="Public profile: public view")

        else:
            logging.info(
                '(ProviderPublicProfileHandler.get) No provider found, sending to index'
            )

            # nobody found, send them to the homepage
            self.redirect("/")