def post(self): id = self['id'] provider = Provider.get_by_id(long(id)) owner = provider.owner.name if provider else '' phone = provider.phone_num if provider else '' self.write(json.dumps({'provider':{'owner':owner,'phone':phone}}), content_type = 'application/json')
def get(self): path = 'provider_details.html' provider = Provider.get_by_id(long(self['id'])) appliance_id = self['appliance_id'] appliance = Appliance.for_id(long(appliance_id)) if appliance_id else None store_name = appliance.store.name if appliance else '' schedule_repair_url = provider.schedule_repair_url schedule_repair_url = schedule_repair_url + '&appliance_id='+ appliance_id if appliance_id else schedule_repair_url template_values = {'details':provider.template_format,'name':provider.name, 'ratings':[x for x in range(1,6)], 'schedule_repair_url':schedule_repair_url, 'appliance_id':appliance_id, 'store_name':store_name} self.write(self.get_rendered_html(path, template_values), 200)
def get(self): path = 'provider_schedule_repair.html' provider = Provider.get_by_id(long(self['id'])) appliance = Appliance.get_by_id(long(self['appliance_id'])) details = [ { 'name':'provider', 'title':'Provider', 'value':provider.name, 'id':provider.id, 'readonly':'readonly' }, { 'name':'store', 'title':'Store', 'value':appliance.store.name, 'readonly':'readonly' }, { 'name':'appliance', 'title':'Appliance', 'value':appliance.name, 'readonly':'readonly' }, { 'name':'appliance_serial', 'title':'Serial Number', 'value':appliance.serial_num, 'readonly':'readonly' }, { 'name':'appliance_manufacturer', 'title':'Manufacturer', 'value':appliance.manufacturer, 'readonly':'readonly' }, { 'name':'fix_by', 'value':'Select date (mm/dd/yy)', 'title':'Fix by date', 'type':'date', 'readonly':'' }, { 'name':'remarks', 'value':'', 'title':'Remarks', 'readonly':'' } ] priorities = ['Critical', 'Normal', 'Routine'] template_values = {'details':details,'name':'New Work Order', 'ratings':[x for x in range(1,6)], 'priorities':priorities, 'appliance_id':self['appliance_id']} self.write(self.get_rendered_html(path, template_values), 200)
def provider_obj(self): return Provider.get_by_id(long(self.provider))