예제 #1
0
 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"})
예제 #2
0
파일: views.py 프로젝트: waseem18/zamboni
    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))
예제 #3
0
파일: views.py 프로젝트: mozilla/crashathon
 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})
예제 #4
0
 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
예제 #5
0
 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
예제 #6
0
파일: base.py 프로젝트: Fjoerfoks/zamboni
def form_errors(forms):
    errors = _collect_form_errors(forms)
    exc = ParseError()
    exc.detail = {'detail': errors}
    raise exc