コード例 #1
0
 def test_create_new(self):
     listing_id = self._create_new()
     cust = Customer.find(TEST_CUSTOMER_EMAIL, Campaign.load(self.site.default_campaign_id))
     listings = Listing.find_by_customer(cust)
     assert len(listings) == 1
     assert str(listings[0].listing_id) == listing_id
     Listing.find_last_n_assets(10)
     self._delete_new(listing_id)
コード例 #2
0
ファイル: customer.py プロジェクト: anonymoose/pvscore
    def _signup(self):
        """ KB: [2011-04-26]:
        Customer can't exist.  Fail if there is a customer_id param
        The customer should never be able to get here if he's logged in.  Forbid if there is a self.session open.
        Try to find the customer by the email provided.
        - If found by email, redirect back to the calling page (POST['url_path'] with msg = already_exists
        Save the customer object and store in the self.session as though the customer has logged in.

        If something goes wrong, redirect back to the calling page with msg = signup_failed
        """
        self.forbid_if(self.request.POST.get('customer_id') or self.request.ctx.customer or not self.request.ctx.campaign)
        campaign = self.request.ctx.campaign
        cust = Customer.find(self.request.POST.get('email'), campaign)
        if cust:
            self.flash('Email %s already in use' % cust.email)
            self.raise_redirect(self.request.referrer)
        cust = Customer()
        cust.campaign_id = campaign.campaign_id
        cust.bind(self.request.POST)
        cust.save()
        cust.flush()
        self.session['customer_id'] = cust.customer_id
        cust.invalidate_caches()
        return cust
コード例 #3
0
ファイル: customer.py プロジェクト: anonymoose/pvscore
    def contact(self):
        camp = self.request.ctx.campaign
        message = self.request.POST.get('message')
        email = self.request.POST.get('email')
        msg = "%s %s<br>(%s)<br><br>%s<br><br>%s" % (self.request.POST.get('fname'),
                                                     self.request.POST.get('lname'),
                                                     email,
                                                     self.request.POST.get('phone'),
                                                     message)
        if util.nvl(self.request.POST.get('save')):
            cust = Customer.find(email, camp)
            if not cust:
                cust = Customer()
                cust.campaign = camp
                cust.bind(self.request.POST)
                cust.phone = cust.phone[:20] if cust.phone else None # prevents people from putting in "904-716-7487 (mobile)" and it barfs
                cust.save()
            Status.add(cust, cust, Status.find_event(self.enterprise_id, cust, 'NOTE'),
                       'NOTE FROM CUSTOMER\n%s' % message)

        email_info = camp.get_email_info()
        mail = UserMail(camp)
        mail.send(email_info.email, 'SITE CONTACT FORM %s' % self.request.host, msg)
        return self.find_redirect()
コード例 #4
0
ファイル: customer.py プロジェクト: anonymoose/pvscore
 def check_duplicate_email(self):
     email = self.request.matchdict.get('email')
     cust = Customer.find(email, self.request.ctx.site.company)
     return 'True' if cust else 'False'