示例#1
0
 def do_PUT(self):
     company = self.context.company
     try:
         company.country = get_json_unicode(self.input,
                                            'country',
                                            False,
                                            company.country,
                                            length=3)
         company.employees = get_json_token(self.input, 'employees',
                                            CompanySchema['employees'],
                                            False, company.employees)
         company.conductor = get_json_token(self.input, 'conductor',
                                            CompanySchema['conductor'],
                                            False, company.conductor)
         company.referer = get_json_token(self.input, 'referer',
                                          CompanySchema['referer'], False,
                                          company.referer)
         company.workers_participated = get_json_bool(
             self.input, 'workers-participated', False,
             company.workers_participated)
         company.needs_met = get_json_bool(self.input, 'needs-met', False,
                                           company.needs_met)
         company.recommend_tool = get_json_bool(self.input,
                                                'recommend-tool', False,
                                                company.recommend_tool)
     except (KeyError, ValueError) as e:
         return {'type': 'error', 'message': str(e)}
     return self.do_GET()
示例#2
0
 def do_PUT(self):
     company = self.context.company
     try:
         company.country = get_json_unicode(self.input, 'country', False,
                 company.country, length=3)
         company.employees = get_json_token(self.input, 'employees',
                 CompanySchema['employees'], False, company.employees)
         company.conductor = get_json_token(self.input, 'conductor',
                 CompanySchema['conductor'], False, company.conductor)
         company.referer = get_json_token(self.input, 'referer',
                 CompanySchema['referer'], False, company.referer)
         company.workers_participated = get_json_bool(self.input,
                 'workers-participated', False,
                 company.workers_participated)
     except (KeyError, ValueError) as e:
         return {'type': 'error',
                 'message': str(e)}
     return self.do_GET()
示例#3
0
 def do_PUT(self):
     plan = self.context
     try:
         for (attr, key) in [('action_plan', 'plan'),
                             ('prevention_plan', 'prevention'),
                             ('requirements', 'requirements'),
                             ('responsible', 'responsible'),
                             ('reference', 'reference')]:
             setattr(
                 plan, attr,
                 get_json_unicode(self.input, key, False,
                                  getattr(plan, attr)))
         plan.budget = get_json_int(self.input, 'budget', False,
                                    plan.budget)
         plan.planning_start = get_json_date(self.input, 'planning-start',
                                             False, plan.planning_start)
         plan.planning_end = get_json_date(self.input, 'planning-end',
                                           False, plan.planning_end)
     except (KeyError, ValueError) as e:
         return {'type': 'error', 'message': str(e)}
     return self.do_GET()
示例#4
0
 def do_PUT(self):
     plan = self.context
     try:
         for (attr, key) in [('action_plan', 'plan'),
                             ('prevention_plan', 'prevention'),
                             ('requirements', 'requirements'),
                             ('responsible', 'responsible'),
                             ('reference', 'reference')]:
             setattr(plan, attr,
                     get_json_unicode(self.input, key, False,
                         getattr(plan, attr)))
         plan.budget = get_json_int(self.input, 'budget', False,
                 plan.budget)
         plan.planning_start = get_json_date(self.input, 'planning-start',
                 False, plan.planning_start)
         plan.planning_end = get_json_date(self.input, 'planning-end',
                 False, plan.planning_end)
     except (KeyError, ValueError) as e:
         return {'type': 'error',
                 'message': str(e)}
     return self.do_GET()