def get(self, request): form = Form(request.GET) if not form.is_valid(): exc = ParseError() exc.detail = {'detail': dict(form.errors.items())} raise exc return Response({"study": "hello-world"})
def get(self, request, pk, metric): if metric not in APP_STATS: raise http.Http404('No metric by that name.') app = self.get_object() stat = APP_STATS[metric] # Perform form validation. form = StatsForm(request.GET) if not form.is_valid(): exc = ParseError() exc.detail = {'detail': dict(form.errors.items())} raise exc qs = form.cleaned_data dimensions = {'app-id': app.id} if 'dimensions' in stat: for key, default in stat['dimensions'].items(): val = request.GET.get(key, default) if val is not None: # Avoid passing kwargs to the monolith client when the # dimension is None to avoid facet filters being applied. dimensions[key] = request.GET.get(key, default) return Response(_get_monolith_data(stat, qs.get('start'), qs.get('end'), qs.get('interval'), dimensions))
def get(self, request): form = StatsForm(request.GET) if not form.is_valid(): exc = ParseError() exc.detail = {'detail': dict(form.errors.items())} raise exc ids_and_counts = collect_id_counts(**form.cleaned_data) return Response({"crashes": ids_and_counts})
def validate(self, data): try: self.instance = LangPack.from_upload(data['upload'], instance=self.instance) except forms.ValidationError, e: exc = ParseError() exc.detail = {u'detail': e.messages} raise exc
def form_errors(forms): errors = _collect_form_errors(forms) exc = ParseError() exc.detail = {'detail': errors} raise exc