コード例 #1
0
ファイル: catalog.py プロジェクト: anonymoose/pvscore
 def params(self):
     campaign = self.request.ctx.campaign
     site = self.request.ctx.site
     if not "cart" in self.session:
         self.session["cart"] = Cart(site)
     cart = self.session["cart"]
     events = Appointment.find_public(self.enterprise_id)
     return {
         "site": site,
         #'base' : '%s/%s/' % (self.request.host_url.replace('http', 'https') if util.is_production() else self.request.host_url , site.namespace),
         "base": "%s/%s/" % (self.request.host_url, site.namespace),
         "user": self.request.ctx.user,
         "product": None,
         "products_related": None,
         "category": None,
         "cart": cart,
         "events": events,
         "seo_title": site.seo_title,
         "seo_keywords": site.seo_keywords,
         "seo_description": site.seo_description,
         "campaign": campaign,
         "categories": SmartCatalog.category_list(campaign),
         "customer": load_customer(self.request, True),  # this way customer is always there, just may be empty
         "matchdict": self.request.matchdict,
         "back_link": self.session.get("back_link"),
         "specials": self.specials_product_list(self.request.GET.get("specials_category_id"), 0, 4),
         "recent_products": self.session["recent_products"] if "recent_products" in self.session else {},
     }
コード例 #2
0
ファイル: appointment.py プロジェクト: anonymoose/pvscore
 def save(self):
     customer_id = self.request.POST.get('customer_id', None)
     apt = Appointment.load(self.request.POST.get('appointment_id'))
     if not apt:
         apt = Appointment()
         apt.user_created = self.request.ctx.user.user_id
     apt.bind(self.request.POST, False)
     if customer_id != '':
         apt.customer_id = customer_id
     apt.save()
     apt.flush()
     self.flash('Successfully saved "%s".' % apt.title)
     if customer_id:
         return HTTPFound('/crm/appointment/edit_for_customer/%s/%s' % (customer_id, apt.appointment_id))
     else:
         return HTTPFound('/crm/appointment/edit/%s' % apt.appointment_id)
コード例 #3
0
    def test_edit_existing_for_customer(self):
        appointment_id = self._create_new_for_customer()
        appt = Appointment.load(appointment_id)
        assert appt is not None
        R = self.get("/crm/appointment/edit_for_customer/%s/%s" % (appt.customer_id, appointment_id))
        assert R.status_int == 200
        f = R.forms["frm_appointment"]
        R.mustcontain("Edit Customer Appointment")
        self.assertEqual(str(f["appointment_id"].value), str(appointment_id))
        self.assertEqual(str(f["customer_id"].value), str(appt.customer_id))

        self.assertEqual(f["title"].value, "Test Customer Appointment")
        self.assertEqual(f["description"].value, "Test Description")

        f.set("title", "Test Customer Appointment New")
        f.set("description", "Test Description New")

        R = f.submit("submit")
        self.assertEqual(R.status_int, 302)
        R = R.follow()
        assert R.status_int == 200
        f = R.forms["frm_appointment"]
        R.mustcontain("Edit Customer Appointment")

        self.assertEqual(f["title"].value, "Test Customer Appointment New")
        self.assertEqual(f["description"].value, "Test Description New")
        self.assertEqual(str(f["customer_id"].value), str(appt.customer_id))
        self._delete_new(appointment_id)
コード例 #4
0
ファイル: appointment.py プロジェクト: anonymoose/pvscore
 def show_appointments(self):
     customer_id = self.request.matchdict.get('customer_id')
     customer = Customer.load(customer_id)
     return {
         'customer' : customer,
         'appointments' : Appointment.find_by_customer(customer)
         }
コード例 #5
0
 def test_list_for_customer(self):
     appointment_id = self._create_new_for_customer()
     appt = Appointment.load(appointment_id)
     assert appt is not None
     R = self.get("/crm/appointment/show_appointments/%s" % appt.customer_id)
     assert R.status_int == 200
     R.mustcontain("Test Customer Appointment")
     self._delete_new(appointment_id)
コード例 #6
0
ファイル: appointment.py プロジェクト: anonymoose/pvscore
 def _edit_impl(self):
     appointment_id = self.request.matchdict.get('appointment_id')
     customer_id = self.request.matchdict.get('customer_id')
     if appointment_id:
         appointment = Appointment.load(appointment_id)
         self.forbid_if(not appointment)
     else:
         appointment = Appointment()
     hours = util.hours_list()
     customer = None
     customer = Customer.load(customer_id)
     self.forbid_if(customer and customer.campaign.company.enterprise_id != self.enterprise_id)
     appointment.customer_id = customer_id
     return {
         'today' : util.today_date(),
         'tomorrow' : util.today_date() + datetime.timedelta(days=1),
         'customer' : customer,
         'appointment' : appointment,
         'timezones' : country_timezones('US'),
         'hours' : hours
         }
コード例 #7
0
ファイル: dashboard.py プロジェクト: anonymoose/pvscore
 def _prep(self):
     charts = []
     # basic included snapshot reports.
     if self.request.ctx.user.priv.view_report:
         charts.append(PeriodOrderSummary(self.request))
         charts.append(MTDSalesByVendor(self.request))
         #charts.append(PeriodCustomerCountSummary(self.request))
     return {
         'companies': Company.find_all(self.request.ctx.enterprise.enterprise_id),
         'charts' : charts,
         'appointments' : Appointment.find_future_by_user(self.request.ctx.user)[:10]
         }
コード例 #8
0
 def test_month_view(self):
     appointment_id1 = self._create_new_for_customer()
     appointment_id2 = self._create_new()
     appt1 = Appointment.load(appointment_id1)
     assert appt1 is not None
     R = self.get("/crm/appointment/month_view/%s/%s" % (TOMORROW.year, TOMORROW.month))
     assert R.status_int == 200
     R.mustcontain("/crm/appointment/edit_for_customer/%s/%s" % (appt1.customer_id, appointment_id1))
     R.mustcontain("/crm/appointment/edit/%s" % appointment_id2)
     self._delete_new(appointment_id2)
     self._delete_new(appointment_id2)
     R = self.get("/crm/appointment/this_month")
     assert R.status_int == 200
コード例 #9
0
ファイル: appointment.py プロジェクト: anonymoose/pvscore
 def search(self):
     title = self.request.POST.get('title')
     if 'description' not in self.request.POST:
         # KB: [2012-12-13]: This happens when we come from the inline search and only one field is passed (it's title)
         description = title
     else:
         description = self.request.POST.get('description')
     appts = Appointment.search(self.enterprise_id, title, description)
     return {
         'title' : title,
         'description' : description,
         'appointments' : appts
         }
コード例 #10
0
 def test_inline_search(self):
     appointment_id1 = self._create_new_for_customer()
     appointment_id2 = self._create_new()
     appt1 = Appointment.load(appointment_id1)
     assert appt1 is not None
     R = self.post("/crm/appointment/search", {"title": "Test"})
     assert R.status_int == 200
     R.mustcontain("Appointment Search")
     R.mustcontain("Test Appointment")
     R.mustcontain("Test Customer Appointment")
     R.mustcontain("/crm/appointment/edit_for_customer/%s/%s" % (appt1.customer_id, appointment_id1))
     R.mustcontain("/crm/appointment/edit/%s" % appointment_id2)
     self._delete_new(appointment_id2)
     self._delete_new(appointment_id2)
コード例 #11
0
ファイル: appointment.py プロジェクト: anonymoose/pvscore
 def _day_view_impl(self, year=None, month=None, day=None):
     year = year if year else int(self.request.matchdict.get('year'))
     month = month if month else int(self.request.matchdict.get('month'))
     day = day if day else int(self.request.matchdict.get('day'))
     today = datetime.date(year, month, day)
     yesterday = today - datetime.timedelta(days=1)
     tomorrow = today + datetime.timedelta(days=1)
     appointments = Appointment.find_by_day(year, month, day, self.request.ctx.user)
     return {
         'hours_list' : util.hours_list(),
         'today' : today,
         'yesterday' : yesterday,
         'tomorrow' : tomorrow,
         'appointments' : appointments
         }
コード例 #12
0
 def test_day_view(self):
     appointment_id1 = self._create_new_for_customer()
     appointment_id2 = self._create_new()
     appt1 = Appointment.load(appointment_id1)
     assert appt1 is not None
     R = self.get("/crm/appointment/day_view/%s/%s/%s" % (TOMORROW.year, TOMORROW.month, TOMORROW.day))
     assert R.status_int == 200
     R.mustcontain("Test Appointment")
     R.mustcontain("Test Customer Appointment")
     R.mustcontain("/crm/appointment/edit_for_customer/%s/%s" % (appt1.customer_id, appointment_id1))
     R.mustcontain("/crm/appointment/edit/%s" % appointment_id2)
     R.mustcontain("/crm/appointment/day_view/%s/%s/%s" % (TODAY.year, TODAY.month, TODAY.day))
     self._delete_new(appointment_id2)
     self._delete_new(appointment_id2)
     R = self.get("/crm/appointment/tomorrow")
     assert R.status_int == 200
     R = self.get("/crm/appointment/this_day")
     assert R.status_int == 200
コード例 #13
0
 def test_search(self):
     appointment_id1 = self._create_new_for_customer()
     appointment_id2 = self._create_new()
     appt1 = Appointment.load(appointment_id1)
     assert appt1 is not None
     R = self.get("/crm/appointment/show_search")
     assert R.status_int == 200
     R.mustcontain("Appointment Search")
     f = R.forms["frm_appointment_search"]
     f.set("title", "Test")
     f.set("description", "Test Description")
     R = f.submit("submit")
     assert R.status_int == 200
     R.mustcontain("Appointment Search")
     R.mustcontain("Test Appointment")
     R.mustcontain("Test Customer Appointment")
     R.mustcontain("/crm/appointment/edit_for_customer/%s/%s" % (appt1.customer_id, appointment_id1))
     R.mustcontain("/crm/appointment/edit/%s" % appointment_id2)
     self._delete_new(appointment_id2)
     self._delete_new(appointment_id2)
コード例 #14
0
ファイル: appointment.py プロジェクト: anonymoose/pvscore
 def _month_view_impl(self, year=None, month=None):
     year = year if year else int(self.request.matchdict.get('year'))
     month = month if month else int(self.request.matchdict.get('month'))
     appointments = Appointment.find_by_month(year, month, self.request.ctx.user)
     first_day_of_month = datetime.date(year, month, 1)
     calendar.setfirstweekday(6)
     month_list = util.month_list_simple()
     month_name = month_list[month-1]
     next_month = first_day_of_month + datetime.timedelta(weeks=5)
     last_month = first_day_of_month - datetime.timedelta(weeks=1)
     month_cal = calendar.monthcalendar(year, month)
     return {
         'today' : util.today_date(),
         'appointments' : appointments,
         'month_cal' : month_cal,
         'month_name' : month_name,
         'month' : month,
         'year' : year,
         'next_month' : next_month,
         'last_month' : last_month
         }
コード例 #15
0
 def _delete_new(self, appointment_id):
     Appointment.full_delete(appointment_id)
     self.commit()
コード例 #16
0
ファイル: appointment.py プロジェクト: anonymoose/pvscore
 def list(self):
     return {
         'user' : self.request.ctx.user,
         'appointments' : Appointment.find_by_user(self.request.ctx.user)
         }