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)
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 }