コード例 #1
0
ファイル: views.py プロジェクト: silasray/pyMoxy
 def post(self, request, method_key):
     
     body = json.loads(request.body)
     triggered_by, applied_during, applied_to = DelayResponseRuleResource.extract_stage_data(body)
     rule = get_rule(method_key, body['conditions'], triggered_by, applied_during, applied_to)
     if rule is None:
         rule = RuleModel(method_key=method_key,
                          triggered_by=triggered_by,
                          applied_during=applied_during,
                          applied_to=applied_to)
         rule.save()
         for name, value in body['conditions'].iteritems():
             RuleConditionModel(rule_model=rule,
                                name=name,
                                value=value).save()
     DelayResponseModel(rule_model=rule, delay=body['delay']).save()
     return HttpResponse()
コード例 #2
0
ファイル: views.py プロジェクト: silasray/pyMoxy
 def post(self, request, method_key):
     
     body = json.loads(request.body)
     triggered_by, applied_during, applied_to = CannedResponseRuleResource.extract_stage_data(body)
     rule = get_rule(method_key, body['conditions'], triggered_by, applied_during, applied_to)
     if rule is None:
         rule = RuleModel(method_key=method_key,
                          triggered_by=triggered_by,
                          applied_during=applied_during,
                          applied_to=applied_to)
         rule.save()
         for name, value in body['conditions'].iteritems():
             RuleConditionModel(rule_model=rule,
                                name=name,
                                value=value).save()
     canned_response = CannedResponseModel.from_dict(body)
     rule.cannedresponsemodel_set.add(canned_response)
     canned_response.save()
     return HttpResponse()