def _show_prep(self, report_id): report = Report.load(report_id) campaigns = products = companies = users = vendors = None if report.show_campaign_id: campaigns = util.select_list(Campaign.find_all(self.enterprise_id), 'campaign_id', 'name', True) if report.show_vendor_id: vendors = util.select_list(Vendor.find_all(self.enterprise_id), 'vendor_id', 'name', True) if report.show_company_id: companies = util.select_list(Company.find_all(self.enterprise_id), 'company_id', 'name', True) if report.show_user_id: users = util.select_list(Users.find_all(self.enterprise_id), 'user_id', 'user_id', True) if report.show_product_id: products = util.select_list(Product.find_all(self.enterprise_id), 'product_id', 'name', True) return { 'today' : util.today_date(), 'tomorrow' : util.tomorrow(), 'thirty_ago' : util.today_date() - datetime.timedelta(days=30), 'rpt_end_dt' : self.request.GET.get('rpt_end_dt'), 'rpt_start_dt' : self.request.GET.get('rpt_start_dt'), 'enterprise_id' : self.enterprise_id, 'report' : report, 'campaigns' : campaigns, 'products' : products, 'companies' : companies, 'users' : users, 'vendors' : vendors }
from pvscore.tests import TestController, secure from pvscore.model.crm.appointment import Appointment import pvscore.lib.util as util # T pvscore.tests.controllers.test_crm_appointment YESTERDAY = util.yesterday() TODAY = util.today() TOMORROW = util.tomorrow() class TestCrmAppointment(TestController): @secure def test_show_new(self): R = self.get("/crm/appointment/new") assert R.status_int == 200 R.mustcontain("New Appointment") f = R.forms["frm_appointment"] self.assertEqual(f["title"].value, "") def _create_new(self): # create the appointment and ensure he's editable. R = self.get("/crm/appointment/new") assert R.status_int == 200 R.mustcontain("New Appointment") f = R.forms["frm_appointment"] self.assertEqual(f["appointment_id"].value, "") f.set("title", "Test Appointment") f.set("phone", "9041234567") f.set("description", "Test Description") f.set("start_dt", util.format_date(TOMORROW))