Exemplo n.º 1
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)
Exemplo n.º 2
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)
Exemplo n.º 3
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
Exemplo n.º 4
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)
Exemplo n.º 5
0
 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)
Exemplo n.º 6
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
Exemplo n.º 7
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)
Exemplo n.º 8
0
 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
         }