Пример #1
0
    def post(self, vanity_url=None):
        form = ProviderProfileForm().get_form(self.request.POST)
        service_form = ProviderServiceForm().get_form()

        if form.validate():
            # Store Provider
            provider = db.get_provider_from_vanity_url(vanity_url)
            
            form.populate_obj(provider)
            provider.put()
            
            provider_user = provider.user.get()
            if provider_user.language != provider.profile_language:
                provider_user.language = provider.profile_language
                provider_user.put()
                self.set_language(provider.profile_language)
            
            self.render_profile(provider, profile_form=form, service_form=service_form, success_message=saved_message)

            # log the event
            self.log_event(user=provider.user, msg="Edit Profile: Success")

        else:
            # show error
            provider = db.get_provider_from_vanity_url(vanity_url)
            self.render_profile(provider, profile_form=form, service_form=service_form)
            
            # log the event
            self.log_event(user=provider.user, msg="Edit Profile: Validation Error")
Пример #2
0
    def post(self, vanity_url=None):
        form = ProviderVanityURLForm().get_form(self.request.POST)
        
        if form.validate():
            # Store Provider
            provider = db.get_provider_from_vanity_url(vanity_url)
            
            form.populate_obj(provider)
            
            provider.put()

            self.redirect('/provider/address/' + provider.vanity_url)

            # log the event
            self.log_event(user=provider.user, msg="Edit Address: Success")

        else:
            # show validation error
            provider = db.get_provider_from_vanity_url(vanity_url)
            address_form = ProviderAddressForm().get_form(obj=provider)

            self.render_address(provider, address_form=address_form, vanity_url_form=form)
            
            # log the event
            self.log_event(user=provider.user, msg="Edit Address: Validation Error")
Пример #3
0
    def post(self, vanity_url=None):
        form = ProviderProfileForm().get_form(self.request.POST)
        service_form = ProviderServiceForm().get_form()

        if form.validate():
            # Store Provider
            provider = db.get_provider_from_vanity_url(vanity_url)

            form.populate_obj(provider)
            provider.put()

            provider_user = provider.user.get()
            if provider_user.language != provider.profile_language:
                provider_user.language = provider.profile_language
                provider_user.put()
                self.set_language(provider.profile_language)

            self.render_profile(provider, profile_form=form, service_form=service_form, success_message=saved_message)

            # log the event
            self.log_event(user=provider.user, msg="Edit Profile: Success")

        else:
            # show error
            provider = db.get_provider_from_vanity_url(vanity_url)
            self.render_profile(provider, profile_form=form, service_form=service_form)

            # log the event
            self.log_event(user=provider.user, msg="Edit Profile: Validation Error")
Пример #4
0
    def get(self, vanity_url=None):
        provider = db.get_provider_from_vanity_url(vanity_url)
        logging.info("provider dump before edit:" + str(vars(provider)))
        address_form = ProviderAddressForm().get_form(obj=provider)
        vanity_url_form = ProviderVanityURLForm().get_form(obj=provider)

        self.render_address(provider, address_form=address_form, vanity_url_form=vanity_url_form)
Пример #5
0
    def get(self, vanity_url=None, operation=None, key=None):
        provider = db.get_provider_from_vanity_url(vanity_url)
        service_object_key = None

        if key:
            service_object_key = ndb.Key(urlsafe=key)
            
        if service_object_key:
            if operation == 'delete':
                            
                service_object_key.delete()
                
                self.redirect('/provider/profile/%s' % provider.vanity_url) 

            elif operation == 'edit':                
                # get the object
                obj = service_object_key.get()
                
                # populate the form
                service_form = ProviderServiceForm().get_form(obj=obj)
                profile_form = ProviderProfileForm().get_form(obj=provider)
                
                self.render_profile(provider, profile_form=profile_form, service_form=service_form, edit= 'service', edit_key = key)
                
                                
            else:
                self.redirect('/provider/profile/%s' % provider.vanity_url) 
Пример #6
0
    def get(self, vanity_url=None, operation=None, key=None):
        provider = db.get_provider_from_vanity_url(vanity_url)
        service_object_key = None

        if key:
            service_object_key = ndb.Key(urlsafe=key)

        if service_object_key:
            if operation == "delete":

                service_object_key.delete()

                self.redirect("/provider/profile/%s" % provider.vanity_url)

            elif operation == "edit":
                # get the object
                obj = service_object_key.get()

                # populate the form
                service_form = ProviderServiceForm().get_form(obj=obj)
                profile_form = ProviderProfileForm().get_form(obj=provider)

                self.render_profile(
                    provider, profile_form=profile_form, service_form=service_form, edit="service", edit_key=key
                )

            else:
                self.redirect("/provider/profile/%s" % provider.vanity_url)
Пример #7
0
    def post(self, vanity_url=None):
        provider = db.get_provider_from_vanity_url(vanity_url)

        # set your secret key: remember to change this to your live secret key in production
        # see your keys here https://manage.stripe.com/account
        if util.is_dev_server(self.request):
            stripe.api_key = _STRIPE_TEST_KEY_SECRET
        else:
            stripe.api_key = _STRIPE_PROD_KEY_SECRET

        # get the credit card details submitted by the form
        token = self.request.POST['stripeToken']
        plan = self.request.POST['plan']

        try:
            customer = stripe.Customer.create(card=token,
                                              plan=plan,
                                              email=provider.email)

            # save the customer ID in your database so you can use it later
            provider_account = ProviderAccount()
            provider_account.provider = provider.key
            provider_account.stripe_customer_id = customer.id
            provider_account.stripe_plan_id = plan
            provider_account.put()

            provider.booking_enabled = True
            provider.upgrade_enabled = False

            provider.put()

            self.redirect("/provider/upgrade/success/" + provider.vanity_url)
        except CardError:
            self.render_template("provider/upgrade_failed.html",
                                 provider=provider)
Пример #8
0
    def get(self,
            vanity_url=None,
            book_date=None,
            book_hour=None,
            book_minutes=None):
        provider = db.get_provider_from_vanity_url(vanity_url)

        booking_datetime_string = "%s %s:%s" % (book_date, book_hour,
                                                book_minutes)
        booking_datetime_utc = to_utc(
            datetime.strptime(booking_datetime_string, '%Y-%m-%d %H:%M'))
        if not provider.is_available(booking_datetime_utc):
            logging.warn(
                "Trying to book a time not available in the schedule...")
            self.redirect("/" + vanity_url + "/book")
        else:
            booking_form = None

            user = self.get_current_user()
            if user:
                booking_form = AppointmentDetailsForLoggedInUser().get_form(
                    provider=provider)
            else:
                # no user logged in, ask for email and stuff
                booking_form = AppointmentDetails().get_form(provider=provider)

            booking_form['booking_date'].data = book_date
            booking_form['booking_time'].data = book_hour + ":" + book_minutes

            self.render_template('provider/public/booking_details.html',
                                 provider=provider,
                                 booking_form=booking_form)
Пример #9
0
    def get(self, feature_switch=None, vanity_url=None):
        
        # validate features that can be switched
        if feature_switch in ['booking_enabled', 'address_enabled', 'connect_enabled', 'stats_enabled', 'upgrade_enabled']:
            provider = db.get_provider_from_vanity_url(vanity_url)
            
            # toggle state
            current_state = getattr(provider, feature_switch)
            
            if current_state:           
                setattr(provider, feature_switch, False)
                success_message = 'feature %s is now set to %s' % (feature_switch, False)
                #provider.add_note('%s = False' % feature_switch)
                    
            else:
                setattr(provider, feature_switch, True)
                success_message = 'feature %s is now set to %s' % (feature_switch, True)
                #provider.add_note('%s = True' % feature_switch)

            provider.put()
            
            self.render_administration(self, provider, success_message=success_message)

        else:
            logging.error('Received unknown feature switch : %s' % feature_switch)
Пример #10
0
    def get(self, feature_switch=None, vanity_url=None):

        # validate features that can be switched
        if feature_switch in [
                'booking_enabled', 'address_enabled', 'connect_enabled',
                'stats_enabled', 'upgrade_enabled'
        ]:
            provider = db.get_provider_from_vanity_url(vanity_url)

            # toggle state
            current_state = getattr(provider, feature_switch)

            if current_state:
                setattr(provider, feature_switch, False)
                success_message = 'feature %s is now set to %s' % (
                    feature_switch, False)
                #provider.add_note('%s = False' % feature_switch)

            else:
                setattr(provider, feature_switch, True)
                success_message = 'feature %s is now set to %s' % (
                    feature_switch, True)
                #provider.add_note('%s = True' % feature_switch)

            provider.put()

            self.render_administration(self,
                                       provider,
                                       success_message=success_message)

        else:
            logging.error('Received unknown feature switch : %s' %
                          feature_switch)
Пример #11
0
    def post(self, vanity_url=None):
        provider = db.get_provider_from_vanity_url(vanity_url)
        provider.vanity_domain = self.request.get('domain')
        provider.put()
        
        logging.info("(ProviderDomainHandler) Provider %s setting vanity domain to %s" % (provider.email, provider.vanity_domain))

        self.redirect('/admin/provider/admin/' + provider.vanity_url)
Пример #12
0
    def get(self, vanity_url=None):
        provider = db.get_provider_from_vanity_url(vanity_url)
        profile_form = ProviderProfileForm().get_form(obj=provider)
        service_form = ProviderServiceForm().get_form()

        logging.debug("(ProviderEditProfileHandler.get) Edit profile for provider %s" % provider.email)

        self.render_profile(provider, profile_form=profile_form, service_form=service_form)
Пример #13
0
 def get(self, vanity_url=None):
     provider = db.get_provider_from_vanity_url(vanity_url)
     
     user = provider.user.get()
     
     events = db.get_events_for_user(user)
     
     self.render_template("/provider/event_log.html", provider=provider, events=events)
Пример #14
0
    def get(self, vanity_url=None):
        provider = db.get_provider_from_vanity_url(vanity_url)
        profile_form = ProviderProfileForm().get_form(obj=provider)
        service_form = ProviderServiceForm().get_form()
        
        logging.debug("(ProviderEditProfileHandler.get) Edit profile for provider %s" % provider.email)

        self.render_profile(provider, profile_form=profile_form, service_form=service_form)
Пример #15
0
    def test_delete_experience_from_profile(self):
        self.self_signup_provider()

        # fill profile section
        self.fill_new_provider_profile_correctly_action()

        response = self.testapp.get('/provider/cv/' +
                                    self._TEST_PROVIDER_VANITY_URL)

        experience_form = response.forms['experience_form']

        experience_form['start_year'] = 2003
        experience_form['end_year'] = 2006
        experience_form['company_name'] = 'Kinatex'
        experience_form['title'] = 'Manual Physiotherapy'
        experience_form['description'] = 'Worked with my hands'

        response = experience_form.submit().follow()

        # check on the profile admin page
        response.mustcontain('2003', '2006')
        response.mustcontain('Kinatex')
        response.mustcontain('Manual Physiotherapy')
        response.mustcontain('Worked with my hands')

        # check on the public profile
        response = self.testapp.get('/' + self._TEST_PROVIDER_VANITY_URL)
        response.mustcontain('2003', '2006')
        response.mustcontain('Kinatex')
        response.mustcontain('Manual Physiotherapy')
        response.mustcontain('Worked with my hands')

        provider = db.get_provider_from_vanity_url(
            self._TEST_PROVIDER_VANITY_URL)
        education = provider.get_experience()[0]

        response_after_delete = self.testapp.get(
            '/provider/cv/experience/' + self._TEST_PROVIDER_VANITY_URL +
            "/delete/" + education.key.urlsafe())

        # experience should be gone
        response_after_delete.mustcontain(no='2003')
        response_after_delete.mustcontain(no='2006')
        response_after_delete.mustcontain(no='Kinatex')
        response_after_delete.mustcontain(no='Manual Physiotherapy')
        response_after_delete.mustcontain(no='Worked with my hands')

        # check on the public profile
        public_response_after_delete = self.testapp.get(
            '/' + self._TEST_PROVIDER_VANITY_URL)
        public_response_after_delete.mustcontain(no='2003')
        public_response_after_delete.mustcontain(no='2006')
        public_response_after_delete.mustcontain(no='Kinatex')
        public_response_after_delete.mustcontain(no='Manual Physiotherapy')
        public_response_after_delete.mustcontain(no='Worked with my hands')

        self.assert_msg_in_log("Edit CV: delete experience success",
                               admin=False)
Пример #16
0
    def get(self, vanity_url=None):
        provider = db.get_provider_from_vanity_url(vanity_url)
        stripe_key = _STRIPE_TEST_KEY_PUBLIC
        if util.is_dev_server(self.request):
            stripe_key = _STRIPE_TEST_KEY_PUBLIC
        else:
            stripe_key = _STRIPE_PROD_KEY_PUBLIC

        self.render_template("provider/upgrade.html", provider=provider, stripe_key=stripe_key)
Пример #17
0
 def post(self, vanity_url=None):
     provider = db.get_provider_from_vanity_url(vanity_url)
     
     domain_form = ProviderDomainForm().get_form(self.request.POST)
     if domain_form.validate():
         domain_form.populate_obj(provider)
         provider.put()
         
     self.render_administration(self, provider)
Пример #18
0
    def post(self, vanity_url=None, section=None, operation=None, key=None):

        # instantiate and fill the section form
        section_form = self.forms[section]().get_form(self.request.POST, request_webob = self.request)

        provider = db.get_provider_from_vanity_url(vanity_url)

        if section_form.validate():
            # Store section
            
            if operation == 'add':
                new_section_object = self.objs[section]()
                    
                section_form.populate_obj(new_section_object)

                new_section_object.provider = provider.key
                new_section_object.put()
                
                # stored eduction
                logging.debug("(ProviderEducationHandler.post) Stored section %s key=%s" % (section, new_section_object.key))

            if operation == 'edit':
                section_object_key = ndb.Key(urlsafe=key)
        
                if section_object_key:
                    section_object = section_object_key.get()
                    section_form.populate_obj(section_object)
                    section_object.put()
                    
                    # stored
                    logging.info("(ProviderEducationHandler.post) Stored section %s key=%s" % (section, section_object.key))
                else:
                    logging.info("(ProviderEducationHandler.post) No section object found for key %s" % key)

            self.redirect('/provider/cv/' + provider.vanity_url)
            
            # log the event
            self.log_event(user=provider.user, msg="Edit CV: %s %s success" % (operation, section))

        else:            
            kwargs = {}
            for k in self.forms:
                if k == section:
                    # this one has errors
                    kwargs[k + '_form'] = section_form
                else:
                    # blank form
                    kwargs[k + '_form'] = self.forms[k]().get_form(request_webob = self.request)
            
            if operation == 'edit':
                kwargs['edit'] = section
                kwargs['edit_key'] = key
            
            self.render_cv(provider, **kwargs)
            
            # log the event
            self.log_event(user=provider.user, msg="Edit CV: %s %s validation error" % (operation, section))
Пример #19
0
    def post(self, vanity_url=None):
        provider = db.get_provider_from_vanity_url(vanity_url)

        domain_form = ProviderDomainForm().get_form(self.request.POST)
        if domain_form.validate():
            domain_form.populate_obj(provider)
            provider.put()

        self.render_administration(self, provider)
Пример #20
0
    def test_delete_experience_from_profile(self):
        self.self_signup_provider()

        # fill profile section
        self.fill_new_provider_profile_correctly_action()

        response = self.testapp.get('/provider/cv/' + self._TEST_PROVIDER_VANITY_URL)

        experience_form = response.forms['experience_form']
        
        experience_form['start_year'] = 2003
        experience_form['end_year'] = 2006
        experience_form['company_name'] = 'Kinatex'
        experience_form['title'] = 'Manual Physiotherapy'
        experience_form['description'] = 'Worked with my hands'

        response = experience_form.submit().follow()
        
        # check on the profile admin page
        response.mustcontain('2003','2006')
        response.mustcontain('Kinatex')
        response.mustcontain('Manual Physiotherapy')
        response.mustcontain('Worked with my hands')
        
        
        # check on the public profile
        response = self.testapp.get('/' + self._TEST_PROVIDER_VANITY_URL)
        response.mustcontain('2003','2006')
        response.mustcontain('Kinatex')
        response.mustcontain('Manual Physiotherapy')
        response.mustcontain('Worked with my hands')


        
        provider = db.get_provider_from_vanity_url(self._TEST_PROVIDER_VANITY_URL)
        education = provider.get_experience()[0]

        response_after_delete = self.testapp.get('/provider/cv/experience/' + self._TEST_PROVIDER_VANITY_URL + "/delete/" + education.key.urlsafe())


        # experience should be gone
        response_after_delete.mustcontain(no='2003')
        response_after_delete.mustcontain(no='2006')
        response_after_delete.mustcontain(no='Kinatex')
        response_after_delete.mustcontain(no='Manual Physiotherapy')
        response_after_delete.mustcontain(no='Worked with my hands')
                
        # check on the public profile
        public_response_after_delete = self.testapp.get('/' + self._TEST_PROVIDER_VANITY_URL)
        public_response_after_delete.mustcontain(no='2003')
        public_response_after_delete.mustcontain(no='2006')
        public_response_after_delete.mustcontain(no='Kinatex')
        public_response_after_delete.mustcontain(no='Manual Physiotherapy')
        public_response_after_delete.mustcontain(no='Worked with my hands')

        self.assert_msg_in_log("Edit CV: delete experience success", admin=False)
Пример #21
0
    def post(self, vanity_url=None):
        provider = db.get_provider_from_vanity_url(vanity_url)
        provider.vanity_domain = self.request.get('domain')
        provider.put()

        logging.info(
            "(ProviderDomainHandler) Provider %s setting vanity domain to %s" %
            (provider.email, provider.vanity_domain))

        self.redirect('/admin/provider/admin/' + provider.vanity_url)
Пример #22
0
    def get(self, vanity_url=None):
        provider = db.get_provider_from_vanity_url(vanity_url)

        user = provider.user.get()

        events = db.get_events_for_user(user)

        self.render_template("/provider/event_log.html",
                             provider=provider,
                             events=events)
Пример #23
0
def validate_vanity_url(vanity_url):
    vanity_url = vanity_url.lower()
    
    # remove any non-alpha
    vanity_url = ''.join([c for c in vanity_url if c.isalpha()])
    
    # remove any unicode accents
    vanity_url = unidecode(vanity_url)
    
    # check if it's taken
    increment = 0
    while db.get_provider_from_vanity_url(vanity_url) is not None:
        increment += 1
        
        # strip previous number
        vanity_url = ''.join([c for c in vanity_url if c.isalpha()])
        
        # add a new number
        vanity_url = vanity_url + str(increment)
    
    
    # check if it's a reserved word
    route_list = webapp2.get_app().router.match_routes
    regex_to_check = []
    for route in route_list:
        if isinstance(route, BaseRoute):
            regex_to_check.append(route.template)
        elif isinstance(route, PathPrefixRoute):
            regex_to_check.append(route.prefix)


    reserved_url = False
    for regex in regex_to_check:
        # skip the default "/" route
        if not regex == "/":
            # remove leading slash
            regex = regex.replace("/", "", 1)
            # remove anything after trailing slash
            regex = regex.split("/")[0]
            
            if re.match(regex, vanity_url):
                reserved_url = True
        
    if reserved_url:
        increment += 1
        
        # strip previous number
        vanity_url = ''.join([c for c in vanity_url if c.isalpha()])
        
        # add a new number
        vanity_url = vanity_url + str(increment)
    
    return vanity_url
    
    
Пример #24
0
    def get(self, vanity_url=None):
        provider_target = db.get_provider_from_vanity_url(vanity_url)
        
        user_source = self.get_current_user()
        if user_source and auth.PROVIDER_ROLE in user_source.roles:
            provider_source = db.get_provider_from_user(user_source)
            
            # check if there is already a pending request
            
            if provider_source in provider_target.get_provider_network_pending():
                message = _("Connection pending...")
                self.render_public_profile(provider=provider_target, success_message=message)
            elif provider_source in provider_target.get_provider_network():
                message = _("Already connected!")
                self.render_public_profile(provider=provider_target, success_message=message)
            elif provider_source == provider_target:
                message = _("You can't connect to yourself!")
                self.render_public_profile(provider=provider_target, success_message=message)
            else:
                provider_network_connection = None
                
                if provider_source in provider_target.get_provider_network_rejected():
                    # this connection was rejected before.
                    provider_network_connection = db.get_provider_network_connection(provider_source.key, provider_target.key)
                    # what the hell...let them try again!
                    provider_network_connection.rejected = False
                else:
                    # no pending request, let's make one        
                    provider_network_connection = ProviderNetworkConnection()
                    provider_network_connection.source_provider = provider_source.key
                    provider_network_connection.target_provider = provider_target.key
                    
                provider_network_connection.confirmed = False

                try:
                    provider_network_connection.put()

                    message = _("Connection requested")
                    self.render_public_profile(provider=provider_target, success_message=message)
                    
                    # now send out an email
                    # the url for accepting for target_provider
                    url_obj = urlparse.urlparse(self.request.url)
                    accept_url = urlparse.urlunparse((url_obj.scheme, url_obj.netloc, '/login/accept/' + provider_network_connection.key.urlsafe(), '', '', ''))
                        
                    mail.email_connect_request(self.jinja2, from_provider=provider_source, target_provider=provider_target, accept_url=accept_url)
                    
                except Exception as e:
                    error_message = 'Error making connection: ' + e.message
                    self.render_public_profile(provider=provider_target, error_message=error_message)

                    
        else:
            # redirect to login page if not logged in, then send back here after creditials are verified
            self.redirect("/login/connect/" + provider_target.key.urlsafe())
Пример #25
0
    def get(self, vanity_url=None):
        provider = db.get_provider_from_vanity_url(vanity_url)
        stripe_key = _STRIPE_TEST_KEY_PUBLIC
        if util.is_dev_server(self.request):
            stripe_key = _STRIPE_TEST_KEY_PUBLIC
        else:
            stripe_key = _STRIPE_PROD_KEY_PUBLIC

        self.render_template("provider/upgrade.html",
                             provider=provider,
                             stripe_key=stripe_key)
Пример #26
0
    def get(self, vanity_url=None, msg_key=None):
        provider = db.get_provider_from_vanity_url(vanity_url)
        
        messages = { 'new' : _("Welcome to Veosan! Please get started by completing your profile."),
                     'reset' : _("Welcome back! Password has been reset."),
                    }
        
        profile_form = ProviderProfileForm().get_form(obj=provider)
        service_form = ProviderServiceForm().get_form()

        self.render_profile(provider, profile_form=profile_form, service_form=service_form, success_message=messages[msg_key])
Пример #27
0
    def get(self, vanity_url=None, operation=None, provider_key=None):
        provider = db.get_provider_from_vanity_url(vanity_url)
        error_message = None
        success_message = None
        
        if operation == 'accept':
            provider_network_connection = ndb.Key(urlsafe=provider_key).get()
            source_provider_key = provider_network_connection.source_provider
            source_provider = source_provider_key.get()
            
            if provider_network_connection.confirmed:

                # already connected
                msg = _('You are already connected to')
                success_message = msg + " %s %s" % (source_provider.first_name, source_provider.last_name)
            else:
                target_provider_key = provider.key
                
                if source_provider_key == target_provider_key:
                    success_message = _("You can't connect to yourself!")
                
                else:
                    provider_network_connection = db.get_provider_network_connection(source_provider_key, target_provider_key)
                    if provider_network_connection:
                        provider_network_connection.confirmed = True
                        provider_network_connection.rejected = False
                        
                        try:
                            provider_network_connection.put()
                            msg = _('You are now connected to')
                            success_message = msg + " %s %s" % (source_provider.first_name, source_provider.last_name)
                        except Exception as e:
                            error_message = 'Error making connection: ' + e.message
                    else:
                        error_message = _('No connection found')
                
        if operation == 'reject':
            provider_network_connection = ndb.Key(urlsafe=provider_key).get()
            source_provider_key = provider_network_connection.source_provider
            source_provider = source_provider_key.get()
            target_provider_key = provider.key
            
            # keep the connection around just mark it as rejected
            provider_network_connection = db.get_provider_network_connection(source_provider_key, target_provider_key)
            provider_network_connection.rejected = True
            provider_network_connection.rejection_count += 1
            provider_network_connection.put()
            
            msg = _("You have rejected")
            success_message = msg + " %s %s" % (source_provider.first_name, source_provider.last_name)
        
        provider_invite_form = ProviderInviteForm().get_form()
        
        self.render_template("provider/network.html", provider=provider, provider_invite_form=provider_invite_form, success_message=success_message, error_message=error_message)
Пример #28
0
    def test_delete_education_from_profile(self):
        self.self_signup_provider()

        # fill profile section
        self.fill_new_provider_profile_correctly_action()

        response = self.testapp.get('/provider/cv/' +
                                    self._TEST_PROVIDER_VANITY_URL)

        education_form = response.forms['education_form']

        education_form['start_year'] = 1998
        education_form['end_year'] = 2002
        education_form['school_name'] = 'Université McGill'
        education_form['degree_type'] = 'bachelor'
        education_form['degree_title'] = 'Clinical Physiotherapy'
        education_form['description'] = 'Graduated with honors'

        response = education_form.submit().follow()

        response.mustcontain('1998', '2002')
        response.mustcontain('Université McGill')
        response.mustcontain('Graduated with honors')
        response.mustcontain('Clinical Physiotherapy')
        response.mustcontain("Baccalauréat")

        provider = db.get_provider_from_vanity_url(
            self._TEST_PROVIDER_VANITY_URL)
        education = provider.get_education()[0]

        response_after_delete = self.testapp.get(
            '/provider/cv/education/' + self._TEST_PROVIDER_VANITY_URL +
            "/delete/" + education.key.urlsafe())

        # education should be gone
        response_after_delete.mustcontain(no='1998')
        response_after_delete.mustcontain(no='2002')
        response_after_delete.mustcontain(no='Graduated with honors')
        response_after_delete.mustcontain(no='Clinical Physiotherapy')
        # Mcgill and baccalaureat will be in the page because of form drop downs...

        # check on the public profile
        public_response_after_delete = self.testapp.get(
            '/' + self._TEST_PROVIDER_VANITY_URL)
        public_response_after_delete.mustcontain(no='1998')
        public_response_after_delete.mustcontain(no='2002')
        public_response_after_delete.mustcontain(no='Graduated with honors')
        public_response_after_delete.mustcontain(no='Clinical Physiotherapy')
        public_response_after_delete.mustcontain(no='Université McGill')
        public_response_after_delete.mustcontain(no="Baccalauréat")

        self.assert_msg_in_log("Edit CV: delete education success",
                               admin=False)
Пример #29
0
 def post(self, vanity_url=None):
     provider = db.get_provider_from_vanity_url(vanity_url)
     new_password = self.request.get('password')
     if provider and new_password:
         user = db.get_user_from_email(provider.email)
         if user:
             # hash password (same as passing password_raw to user_create)
             password_hash = security.generate_password_hash(new_password, length=12)    
             user.password = password_hash
             user.put()
             
     self.redirect('/admin/provider/admin/' + provider.vanity_url)
Пример #30
0
    def get(self,
            vanity_url=None,
            operation=None,
            key=None,
            day=None,
            start_time=None):
        provider = db.get_provider_from_vanity_url(vanity_url)
        kwargs = {}
        if key:
            schedule_key = ndb.Key(urlsafe=key)

        if operation == 'add':
            logging.info("(ProviderEducationHandler.get) Add schedule key=%s" %
                         key)
            #new_schedule.end_time = new_schedule.start_time + 4
            schedule_form = ProviderScheduleForm().get_form()
            schedule_form.day.data = day
            schedule_form.start_time.data = int(start_time)

            end_time = int(start_time) + 4
            max_time = max([k[0] for k in time.get_time_list()])
            if end_time > max_time:
                end_time = max_time

            schedule_form.end_time.data = int(end_time)

            kwargs['schedule_form'] = schedule_form
            kwargs['add'] = 'add'
            self.render_schedule(provider, **kwargs)

        elif operation == 'delete':
            logging.info(
                "(ProviderEducationHandler.get) Delete schedule key=%s" % key)
            schedule_key.delete()
            # log the event
            self.log_event(user=provider.user, msg="Schedule delete")

            self.redirect('/provider/schedule/%s' % provider.vanity_url)

        elif operation == 'edit':
            logging.info(
                "(ProviderEducationHandler.get) Edit schedule key=%s" % key)
            # get the object
            obj = schedule_key.get()
            # populate the form
            kwargs['schedule_form'] = ProviderScheduleForm().get_form(obj=obj)
            kwargs['edit_key'] = key

            self.render_schedule(provider, **kwargs)

        else:
            self.render_schedule(provider, **kwargs)
Пример #31
0
    def post(self, vanity_url=None):
        provider = db.get_provider_from_vanity_url(vanity_url)

        patient_form = RegistrationDetailsForNewPatient().get_form(
            self.request.POST)

        if patient_form.validate():
            booking_key_urlsafe = patient_form['booking_key'].data
            booking = db.get_from_urlsafe_key(booking_key_urlsafe)

            # create a new patient
            patient = Patient()

            patient_form.populate_obj(patient)
            self.set_gae_geography_from_headers(patient)
            patient.put()

            # create a new user
            user = self.create_empty_user_for_patient(patient)
            user.language = self.get_language()

            # set the password
            password = patient_form['password'].data
            password_hash = security.generate_password_hash(password,
                                                            length=12)
            user.password = password_hash
            user.put()

            # login with new password
            self.login_user(user.get_email(), password)

            # store booking
            user = patient.user.get()
            booking.patient = patient.key
            booking.confirmed = user.confirmed = False
            booking.put()

            # send a confirmation/activation email
            url_obj = urlparse.urlparse(self.request.url)
            activation_url = urlparse.urlunparse(
                (url_obj.scheme, url_obj.netloc,
                 '/login/booking/' + booking.key.urlsafe(), '', '', ''))
            logging.info(
                '(NewPatientHandler.post) generated activation url for user %s : %s '
                % (patient.email, activation_url))
            mail.email_booking_to_patient(self, booking, activation_url)

            PatientBaseHandler.render_confirmation_email_sent(self, booking)
        else:
            self.render_template('provider/public/booking_new_patient.html',
                                 provider=provider,
                                 patient_form=patient_form)
Пример #32
0
    def get(self, vanity_url=None):
        provider = db.get_provider_from_vanity_url(vanity_url)
        user = db.get_user_from_email(provider.email)
        token = self.create_token(user, 'set_new_password')
        
        # claim url
        url_obj = urlparse.urlparse(self.request.url)
        claim_url = urlparse.urlunparse((url_obj.scheme, url_obj.netloc, '/claim/' + token, '', '', ''))
        
        user.claim_url = claim_url
        user.put()

        self.redirect('/admin/provider/admin/' + provider.vanity_url)
Пример #33
0
    def post(self, vanity_url=None):
        provider = db.get_provider_from_vanity_url(vanity_url)
        new_password = self.request.get('password')
        if provider and new_password:
            user = db.get_user_from_email(provider.email)
            if user:
                # hash password (same as passing password_raw to user_create)
                password_hash = security.generate_password_hash(new_password,
                                                                length=12)
                user.password = password_hash
                user.put()

        self.redirect('/admin/provider/admin/' + provider.vanity_url)
Пример #34
0
def validate_vanity_url(vanity_url):
    vanity_url = vanity_url.lower()

    # remove any non-alpha
    vanity_url = ''.join([c for c in vanity_url if c.isalpha()])

    # remove any unicode accents
    vanity_url = unidecode(vanity_url)

    # check if it's taken
    increment = 0
    while db.get_provider_from_vanity_url(vanity_url) is not None:
        increment += 1

        # strip previous number
        vanity_url = ''.join([c for c in vanity_url if c.isalpha()])

        # add a new number
        vanity_url = vanity_url + str(increment)

    # check if it's a reserved word
    route_list = webapp2.get_app().router.match_routes
    regex_to_check = []
    for route in route_list:
        if isinstance(route, BaseRoute):
            regex_to_check.append(route.template)
        elif isinstance(route, PathPrefixRoute):
            regex_to_check.append(route.prefix)

    reserved_url = False
    for regex in regex_to_check:
        # skip the default "/" route
        if not regex == "/":
            # remove leading slash
            regex = regex.replace("/", "", 1)
            # remove anything after trailing slash
            regex = regex.split("/")[0]

            if re.match(regex, vanity_url):
                reserved_url = True

    if reserved_url:
        increment += 1

        # strip previous number
        vanity_url = ''.join([c for c in vanity_url if c.isalpha()])

        # add a new number
        vanity_url = vanity_url + str(increment)

    return vanity_url
Пример #35
0
    def test_everything_correct_then_edit_and_change_valid_field_to_invalid(
            self):
        self.self_signup_provider()

        response = self.testapp.get('/provider/cv/' +
                                    self._TEST_PROVIDER_VANITY_URL)

        education_form = response.forms['education_form']

        education_form['start_year'] = 1998
        education_form['end_year'] = 2002
        education_form['school_name'] = 'Curtain University'
        education_form['degree_type'] = 'bachelor'
        education_form['degree_title'] = 'Clinical Physiotherapy'
        education_form['description'] = 'Graduated with honors'

        response = education_form.submit().follow()

        # all good
        response.mustcontain('1998', '2002')
        response.mustcontain('Graduated with honors')
        response.mustcontain('Clinical Physiotherapy')
        response.mustcontain("Baccalauréat")
        response.mustcontain("Curtain University")

        # now edit
        provider = db.get_provider_from_vanity_url(
            self._TEST_PROVIDER_VANITY_URL)
        education = provider.get_education()[0]
        education_key = education.key.urlsafe()
        edit_response = self.testapp.get('/provider/cv/education/' +
                                         self._TEST_PROVIDER_VANITY_URL +
                                         '/edit/' + education_key)

        # change a valid field to invalid
        edit_form = edit_response.forms['education_form']
        edit_form['start_year'] = 19988991
        error_response = edit_form.submit()

        error_response.mustcontain('SVP entrez une année valide.')
        error_response.mustcontain('19988991')

        # now change it to valid again
        edit_form_corrected = error_response.forms['education_form']
        edit_form_corrected['start_year'] = 1979
        saved_response = edit_form_corrected.submit().follow()
        saved_response.mustcontain('1979')

        # check the event log
        self.assert_msg_in_log("Edit CV: add education success", admin=False)
Пример #36
0
    def get(self, vanity_url=None):
        provider = db.get_provider_from_vanity_url(vanity_url)
        user = db.get_user_from_email(provider.email)
        token = self.create_token(user, 'set_new_password')

        # claim url
        url_obj = urlparse.urlparse(self.request.url)
        claim_url = urlparse.urlunparse(
            (url_obj.scheme, url_obj.netloc, '/claim/' + token, '', '', ''))

        user.claim_url = claim_url
        user.put()

        self.redirect('/admin/provider/admin/' + provider.vanity_url)
Пример #37
0
    def get(self, vanity_url=None, section=None, operation=None, key=None):
        provider = db.get_provider_from_vanity_url(vanity_url)
        kwargs = self.generate_blank_forms()
        section_object_key = None

        if key:
            section_object_key = ndb.Key(urlsafe=key)

        if section_object_key:
            if operation == 'delete':
                logging.info(
                    "(ProviderEducationHandler.get) Delete section %s key=%s" %
                    (section, key))

                section_object_key.delete()

                # success, empty forms so you can play again
                kwargs = self.generate_blank_forms()

                # log the event
                self.log_event(user=provider.user,
                               msg="Edit CV: %s %s success" %
                               (operation, section))

                self.redirect('/provider/cv/' + provider.vanity_url)

            elif operation == 'edit':
                logging.info(
                    "(ProviderEducationHandler.get) Edit section %s key=%s" %
                    (section, key))

                # get the object
                obj = section_object_key.get()

                # populate the form
                kwargs[section + "_form"] = self.forms[section]().get_form(
                    obj=obj, request_webob=self.request)
                kwargs['edit'] = section
                kwargs['edit_key'] = key
                self.render_cv(provider, **kwargs)

            else:
                self.redirect('/provider/cv/' + provider.vanity_url)

        else:
            logging.info(
                "(ProviderEducationHandler.get) No section object found for key %s"
                % key)
            self.render_cv(provider, **kwargs)
Пример #38
0
    def post(self, vanity_url=None, operation=None, key=None):
        logging.info('ProviderScheduleHandler POST')
        # instantiate and fill the form
        schedule_form = ProviderScheduleForm().get_form(self.request.POST,
                                                        obj=Schedule())
        provider = db.get_provider_from_vanity_url(vanity_url)
        error_messages = None

        if schedule_form.validate():
            # Store schedule
            if operation == 'add':
                new_schedule = Schedule()
                schedule_form.populate_obj(new_schedule)
                new_schedule.provider = provider.key
                new_schedule.put()
                # stored eduction
                logging.debug("(ProviderSchedule.post) New schedule %s " %
                              new_schedule)

            elif operation == 'edit':
                schedule_key = ndb.Key(urlsafe=key)

                if schedule_key:
                    schedule = schedule_key.get()
                    schedule_form.populate_obj(schedule)
                    schedule.put()
                    # stored
                    logging.info(
                        "(ProviderEducationHandler.post) Stored schedule key=%s"
                        % schedule.key)
                else:
                    logging.info(
                        "(ProviderEducationHandler.post) No schedule found for key %s"
                        % key)

            else:
                logging.error('Operation Not handled %s' % operation)

            self.redirect('/provider/schedule/%s' % provider.vanity_url)

        else:
            error_messages = schedule_form.errors
            logging.info('Schedule form did not validate: %s' % error_messages)

            kwargs = {}
            kwargs['schedule_form'] = schedule_form
            kwargs['edit_key'] = key

            self.render_schedule(provider, **kwargs)
Пример #39
0
    def post(self, vanity_url=None, operation=None, provider_key=None):
        provider = db.get_provider_from_vanity_url(vanity_url)
        
        if operation == 'invite' :
            form = ProviderInviteForm().get_form(self.request.POST)
            if form.validate():
                invite = Invite()
                form.populate_obj(invite)

                # check if the target email is an existing user
                target_provider = db.get_provider_from_email(invite.email)
                if target_provider: 
                    # already a member, just make a connection request
                    self.redirect('/%s/connect' % target_provider.vanity_url)
                
                else:
                    # new person
                    # associate provider to invite
                    invite.provider = provider.key
                    
                    # create a token for this invite that will be used to pre-populate the signup form
                    invite.token = self.create_token_oldstyle(invite.email)
                    
                    # save
                    invite.put()
                    
                    # create an invite url
                    url_obj = urlparse.urlparse(self.request.url)
                    invite_url = urlparse.urlunparse((url_obj.scheme, url_obj.netloc, '/invite/' + invite.token, '', '', ''))
                    logging.info('(ProviderNetworkHandler.post) unique invite URL:' + invite_url)
        
                    # send the actual email...
                    mail.email_invite(self.jinja2, invite, invite_url)
                    
                    # all good
                    msg = _("Invitation sent to")
                    message = msg + " %s %s" % (invite.first_name, invite.last_name)
                    
                    # new form for next invite
                    provider_invite_form = ProviderInviteForm().get_form()
                    self.render_template("provider/network.html", success_message=message, provider=provider, provider_invite_form=provider_invite_form)
            else:
                self.render_template("provider/network.html", provider=provider, provider_invite_form=form)
        else:
            # post unknown operation
            
            provider_invite_form = ProviderInviteForm().get_form()
            self.render_template("provider/network.html", success_message=message, provider=provider, provider_invite_form=provider_invite_form)
Пример #40
0
    def test_delete_education_from_profile(self):
        self.self_signup_provider()

        # fill profile section
        self.fill_new_provider_profile_correctly_action()

        response = self.testapp.get('/provider/cv/' + self._TEST_PROVIDER_VANITY_URL)

        education_form = response.forms['education_form']
        
        education_form['start_year'] = 1998
        education_form['end_year'] = 2002
        education_form['school_name'] = 'Université McGill'
        education_form['degree_type'] = 'bachelor'
        education_form['degree_title'] = 'Clinical Physiotherapy'
        education_form['description'] = 'Graduated with honors'

        response = education_form.submit().follow()
        
        response.mustcontain('1998','2002')
        response.mustcontain('Université McGill')
        response.mustcontain('Graduated with honors')
        response.mustcontain('Clinical Physiotherapy')
        response.mustcontain("Baccalauréat")
        
        provider = db.get_provider_from_vanity_url(self._TEST_PROVIDER_VANITY_URL)
        education = provider.get_education()[0]

        response_after_delete = self.testapp.get('/provider/cv/education/' + self._TEST_PROVIDER_VANITY_URL + "/delete/" + education.key.urlsafe())


        # education should be gone
        response_after_delete.mustcontain(no='1998')
        response_after_delete.mustcontain(no='2002')
        response_after_delete.mustcontain(no='Graduated with honors')
        response_after_delete.mustcontain(no='Clinical Physiotherapy')
        # Mcgill and baccalaureat will be in the page because of form drop downs...
        
        # check on the public profile
        public_response_after_delete = self.testapp.get('/' + self._TEST_PROVIDER_VANITY_URL)
        public_response_after_delete.mustcontain(no='1998')
        public_response_after_delete.mustcontain(no='2002')
        public_response_after_delete.mustcontain(no='Graduated with honors')
        public_response_after_delete.mustcontain(no='Clinical Physiotherapy')
        public_response_after_delete.mustcontain(no='Université McGill')
        public_response_after_delete.mustcontain(no="Baccalauréat")

        self.assert_msg_in_log("Edit CV: delete education success", admin=False)
Пример #41
0
    def get(self, vanity_url=None, disable=None):
        provider = db.get_provider_from_vanity_url(vanity_url)

        if self.session.has_key('signup_button'):
            signup_origin = self.session['signup_button']
            if signup_origin:
                provider.signup_origin = signup_origin
                provider.put_async()

        if disable == 'disable':
            provider.display_welcome_page = False
            provider.put()
            self.redirect('/provider/profile/' + provider.vanity_url)
            return  # don't render template after redirect

        self.render_template("provider/welcome.html", provider=provider)
Пример #42
0
    def post(self, vanity_url=None):
        provider = db.get_provider_from_vanity_url(vanity_url)
        logging.info("(ProviderAddressUploadHandler.post) Found provider: %s" % provider.email)
        
        upload_form = ProviderPhotoForm().get_form(self.request.POST)
        upload_files = self.get_uploads(upload_form.profile_photo.name)[0]
        
        logging.info("(ProviderAddressUploadHandler.post) Uploaded blob key: %s " % upload_files.key())
        provider.profile_photo_blob_key = upload_files.key()
        provider.put()
        
        # redirect to profile page        
        self.redirect('/provider/profile/%s' % provider.vanity_url) 

        # log the event
        self.log_event(user=provider.user, msg="Edit Profile: Upload Photo")
Пример #43
0
    def get(self, vanity_url=None, disable=None):
        provider = db.get_provider_from_vanity_url(vanity_url)

        if self.session.has_key('signup_button'):
            signup_origin = self.session['signup_button']
            if signup_origin:
                provider.signup_origin = signup_origin
                provider.put_async()

        if disable == 'disable':
            provider.display_welcome_page = False
            provider.put()
            self.redirect('/provider/profile/' + provider.vanity_url)
            return # don't render template after redirect

        self.render_template("provider/welcome.html", provider=provider)
Пример #44
0
    def post(self, vanity_url=None):
        provider = db.get_provider_from_vanity_url(vanity_url)
        logging.info("(ProviderAddressUploadHandler.post) Found provider: %s" % provider.email)

        upload_form = ProviderPhotoForm().get_form(self.request.POST)
        upload_files = self.get_uploads(upload_form.profile_photo.name)[0]

        logging.info("(ProviderAddressUploadHandler.post) Uploaded blob key: %s " % upload_files.key())
        provider.profile_photo_blob_key = upload_files.key()
        provider.put()

        # redirect to profile page
        self.redirect("/provider/profile/%s" % provider.vanity_url)

        # log the event
        self.log_event(user=provider.user, msg="Edit Profile: Upload Photo")
Пример #45
0
    def post(self, vanity_url=None):
        provider = db.get_provider_from_vanity_url(vanity_url)

        patient_form = RegistrationDetailsForNewPatient().get_form(self.request.POST)
        
        if patient_form.validate():
            booking_key_urlsafe = patient_form['booking_key'].data
            booking = db.get_from_urlsafe_key(booking_key_urlsafe)

            # create a new patient
            patient = Patient()
                    
            patient_form.populate_obj(patient)
            self.set_gae_geography_from_headers(patient)
            patient.put()

            # create a new user
            user = self.create_empty_user_for_patient(patient)
            user.language = self.get_language()

            # set the password            
            password = patient_form['password'].data
            password_hash = security.generate_password_hash(password, length=12)    
            user.password = password_hash
            user.put()
            
            # login with new password
            self.login_user(user.get_email(), password)

            # store booking
            user = patient.user.get()
            booking.patient = patient.key
            booking.confirmed = user.confirmed = False
            booking.put()

            # send a confirmation/activation email
            url_obj = urlparse.urlparse(self.request.url)
            activation_url = urlparse.urlunparse((url_obj.scheme, url_obj.netloc, '/login/booking/' + booking.key.urlsafe(), '', '', ''))
            logging.info('(NewPatientHandler.post) generated activation url for user %s : %s ' %  (patient.email, activation_url))
            mail.email_booking_to_patient(self, booking, activation_url)
            
            PatientBaseHandler.render_confirmation_email_sent(self, booking)
        else:
            self.render_template('provider/public/booking_new_patient.html', provider=provider, patient_form=patient_form)

                
Пример #46
0
    def get(self, vanity_url=None, operation=None, key=None, day=None, start_time=None):
        provider = db.get_provider_from_vanity_url(vanity_url)
        kwargs = {}
        if key:
            schedule_key = ndb.Key(urlsafe=key)
            
        if operation == 'add':
            logging.info("(ProviderEducationHandler.get) Add schedule key=%s" % key)
            #new_schedule.end_time = new_schedule.start_time + 4
            schedule_form = ProviderScheduleForm().get_form()
            schedule_form.day.data = day
            schedule_form.start_time.data = int(start_time)
            
            
            end_time = int(start_time) + 4
            max_time = max([k[0] for k in time.get_time_list()])
            if end_time > max_time:
                end_time = max_time
            
            schedule_form.end_time.data = int(end_time)
            
            kwargs['schedule_form'] = schedule_form
            kwargs['add'] = 'add'
            self.render_schedule(provider, **kwargs)

            
        elif operation == 'delete':
            logging.info("(ProviderEducationHandler.get) Delete schedule key=%s" % key)    
            schedule_key.delete()        
            # log the event
            self.log_event(user=provider.user, msg="Schedule delete")
            
            self.redirect('/provider/schedule/%s' % provider.vanity_url)

        elif operation == 'edit':
            logging.info("(ProviderEducationHandler.get) Edit schedule key=%s" % key)
            # get the object
            obj = schedule_key.get()
            # populate the form
            kwargs['schedule_form'] = ProviderScheduleForm().get_form(obj=obj)
            kwargs['edit_key'] = key
            
            self.render_schedule(provider, **kwargs)
        
        else:
            self.render_schedule(provider, **kwargs)
Пример #47
0
    def __call__(self, form, field):
        vanity_url = field.data
    
        if vanity_url:
            # force the vanity URL to lowercase
            vanity_url = vanity_url.lower()

            # try to fetch a provider with this vanity URL
            provider = db.get_provider_from_vanity_url(vanity_url)
                        
            if provider:
                # taken
                raise ValidationError(self.message)
    
            else:
                #available
                pass
Пример #48
0
    def post(self, vanity_url=None):
        provider = db.get_provider_from_vanity_url(vanity_url)
        target_provider_email = self.request.get('email')
        if target_provider_email:
            target_provider = db.get_provider_from_email(target_provider_email)
            
            provider_network_connection = ProviderNetworkConnection()
            provider_network_connection.source_provider = provider.key
            provider_network_connection.target_provider = target_provider.key
            provider_network_connection.confirmed = True
            provider_network_connection.rejected = False
            provider_network_connection.forced_by_admin = True
            provider_network_connection.put()

            logging.info("(ProviderForceFriendsHandler) Provider %s forcing connection to %s" % (provider.email, provider.vanity_domain))

        self.redirect('/admin/provider/admin/' + provider.vanity_url)
Пример #49
0
    def test_everything_correct_then_edit_and_change_valid_field_to_invalid(self):
        self.self_signup_provider()

        response = self.testapp.get('/provider/cv/' + self._TEST_PROVIDER_VANITY_URL)

        education_form = response.forms['education_form']
        
        education_form['start_year'] = 1998
        education_form['end_year'] = 2002
        education_form['school_name'] = 'Curtain University'
        education_form['degree_type'] = 'bachelor'
        education_form['degree_title'] = 'Clinical Physiotherapy'
        education_form['description'] = 'Graduated with honors'

        response = education_form.submit().follow()
                
        # all good
        response.mustcontain('1998','2002')
        response.mustcontain('Graduated with honors')
        response.mustcontain('Clinical Physiotherapy')
        response.mustcontain("Baccalauréat")
        response.mustcontain("Curtain University")

        # now edit
        provider = db.get_provider_from_vanity_url(self._TEST_PROVIDER_VANITY_URL)
        education = provider.get_education()[0]
        education_key = education.key.urlsafe()
        edit_response = self.testapp.get('/provider/cv/education/' + self._TEST_PROVIDER_VANITY_URL + '/edit/' + education_key)
                
        # change a valid field to invalid       
        edit_form = edit_response.forms['education_form']
        edit_form['start_year'] = 19988991
        error_response = edit_form.submit()
        
        error_response.mustcontain('SVP entrez une année valide.')
        error_response.mustcontain('19988991')

        # now change it to valid again
        edit_form_corrected = error_response.forms['education_form']
        edit_form_corrected['start_year'] = 1979
        saved_response = edit_form_corrected.submit().follow()
        saved_response.mustcontain('1979')

        
        # check the event log
        self.assert_msg_in_log("Edit CV: add education success", admin=False)
Пример #50
0
    def get(self, vanity_url=None, msg_key=None):
        provider = db.get_provider_from_vanity_url(vanity_url)

        messages = {
            'new':
            _("Welcome to Veosan! Please get started by completing your profile."
              ),
            'reset':
            _("Welcome back! Password has been reset."),
        }

        profile_form = ProviderProfileForm().get_form(obj=provider)
        service_form = ProviderServiceForm().get_form()

        self.render_profile(provider,
                            profile_form=profile_form,
                            service_form=service_form,
                            success_message=messages[msg_key])
Пример #51
0
 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
     )
Пример #52
0
    def post(self, vanity_url=None, operation=None, key=None):
        logging.info('ProviderScheduleHandler POST')        
        # instantiate and fill the form
        schedule_form = ProviderScheduleForm().get_form(self.request.POST, obj=Schedule())
        provider = db.get_provider_from_vanity_url(vanity_url)
        error_messages = None
        
        if schedule_form.validate():
            # Store schedule
            if operation == 'add':
                new_schedule = Schedule()
                schedule_form.populate_obj(new_schedule)
                new_schedule.provider = provider.key
                new_schedule.put()
                # stored eduction
                logging.debug("(ProviderSchedule.post) New schedule %s " % new_schedule)
                
            elif operation == 'edit':
                schedule_key = ndb.Key(urlsafe=key)
        
                if schedule_key:
                    schedule = schedule_key.get()
                    schedule_form.populate_obj(schedule)
                    schedule.put()
                    # stored
                    logging.info("(ProviderEducationHandler.post) Stored schedule key=%s" % schedule.key)
                else:
                    logging.info("(ProviderEducationHandler.post) No schedule found for key %s" % key)

            else:
                logging.error('Operation Not handled %s' % operation)
                
            self.redirect('/provider/schedule/%s' % provider.vanity_url)

        else:
            error_messages = schedule_form.errors
            logging.info('Schedule form did not validate: %s' % error_messages)
            
            kwargs = {}
            kwargs['schedule_form'] = schedule_form
            kwargs['edit_key'] = key

            self.render_schedule(provider, **kwargs)
Пример #53
0
    def post(self, vanity_url=None):
        provider = db.get_provider_from_vanity_url(vanity_url)
        target_provider_email = self.request.get('email')
        if target_provider_email:
            target_provider = db.get_provider_from_email(target_provider_email)

            provider_network_connection = ProviderNetworkConnection()
            provider_network_connection.source_provider = provider.key
            provider_network_connection.target_provider = target_provider.key
            provider_network_connection.confirmed = True
            provider_network_connection.rejected = False
            provider_network_connection.forced_by_admin = True
            provider_network_connection.put()

            logging.info(
                "(ProviderForceFriendsHandler) Provider %s forcing connection to %s"
                % (provider.email, provider.vanity_domain))

        self.redirect('/admin/provider/admin/' + provider.vanity_url)
Пример #54
0
 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)
Пример #55
0
    def get(self, vanity_url=None, section=None, operation=None, key=None):
        provider = db.get_provider_from_vanity_url(vanity_url)
        kwargs = self.generate_blank_forms()
        section_object_key = None

        if key:
            section_object_key = ndb.Key(urlsafe=key)
        
        if section_object_key:
            if operation == 'delete':
                logging.info("(ProviderEducationHandler.get) Delete section %s key=%s" % (section, key))
                            
                section_object_key.delete()
                
                # success, empty forms so you can play again            
                kwargs = self.generate_blank_forms()
            
                # log the event
                self.log_event(user=provider.user, msg="Edit CV: %s %s success" % (operation, section))

                self.redirect('/provider/cv/' + provider.vanity_url)

            elif operation == 'edit':
                logging.info("(ProviderEducationHandler.get) Edit section %s key=%s" % (section, key))
                
                # get the object
                obj = section_object_key.get()
                
                # populate the form
                kwargs[section + "_form"] = self.forms[section]().get_form(obj=obj, request_webob = self.request)
                kwargs['edit'] = section
                kwargs['edit_key'] = key
                self.render_cv(provider, **kwargs)
                
            else:
                self.redirect('/provider/cv/' + provider.vanity_url)

        else:
            logging.info("(ProviderEducationHandler.get) No section object found for key %s" % key)
            self.render_cv(provider, **kwargs)
Пример #56
0
    def get_language(self):
        # parse path and look for potential vanity url
        url = self.request.url
        url_obj = urlparse.urlparse(url)
        path = url_obj.path
        if path:
            path_no_slash = path.replace('/','')
        
        provider_from_vanity_url = db.get_provider_from_vanity_url(path_no_slash)

        # parse url and look for potential language
        url_language = language.get_language_from_url(self.request.url) 
        
        # look for a prospect
        prospect = None
        if self.session.has_key('prospect_id'):
            prospect_id = self.session['prospect_id']
            if prospect_id:
                prospect = db.get_prospect_from_prospect_id(prospect_id) 
        
        
        # set the best language based on information available to us in order of priority
        # 1. directly in URL
        # 2. from a logged in user
        # 3. from a provider's default language (if viewing their profile)
        # 4. from a prospect's preset language
        # 5. default system language
        if url_language:
            return url_language
        elif self.get_current_user():
            return self.get_current_user().language
        elif provider_from_vanity_url and provider_from_vanity_url.profile_language:
            return provider_from_vanity_url.profile_language
        elif prospect:
            return prospect.language
        else:
            return util.DEFAULT_LANG 
Пример #57
0
    def post(self, vanity_url=None, operation=None, key=None):
        provider = db.get_provider_from_vanity_url(vanity_url)

        service_form = ProviderServiceForm().get_form(self.request.POST)
        if service_form.validate():
            if operation == 'add':
                service_object = ProviderService()
                service_form.populate_obj(service_object)
                service_object.provider = provider.key
                service_object.put()

            if operation == 'edit':
                service_object_key = ndb.Key(urlsafe=key)
        
                if service_object_key:
                    service_object = service_object_key.get()
                    service_form.populate_obj(service_object)
                    service_object.put()
            
            self.redirect('/provider/profile/%s' % provider.vanity_url) 
        else:
            profile_form = ProviderProfileForm().get_form(obj=provider)

            self.render_profile(provider, profile_form=profile_form, service_form=service_form)