Ejemplo n.º 1
0
 def test_preview_chart(self):
     query = {
         "pInvertedAxis": u"",
         "pNullValuePreset": u"",
         "pHeaderSelection": u"K1:K1",
         "pId": 70703,
         "pType": u"linechart",
         "pData": u"K2:K4",
         "pNullValueAction": u"exclude",
         "pLabelSelection": u"C2:C4",
         "pInvertData": u"",
     }
     result, content_type = preview_chart(query)
     # print result
     assert content_type == "application/json; charset=UTF-8"
Ejemplo n.º 2
0
 def test_preview_map(self):
     query = {
         "pId": 70703,
         "pType": "mapchart",
         "pNullValueAction": "exclude",
         "pNullValuePreset": "",
         "pData": "C2:C12",
         "pLatitudSelection": "K2:K12",
         "pLongitudSelection": "L2:L12",
         "pHeaderSelection": "",
         "pTraceSelection": "",
         # 'pZoom': '1',
         # 'pBounds': '-24.237324317659557;-45.949525292619;-42.98732431765956;-95.230775292619'
     }
     result, content_type = preview_chart(query)
     # print result, content_type
     assert content_type == "application/json; charset=UTF-8"
Ejemplo n.º 3
0
def preview(request):

    form = forms.PreviewForm(request.GET)

    if form.is_valid():

        preferences = request.preferences
        datastream_revision_id  = request.GET.get('datastream_revision_id', None)

        try:
            datastream = DataStreamDBDAO().get(
                request.user.language,
                datastream_revision_id=datastream_revision_id,
                published=False
            )
        except Exception, e:
            logger.error(e)
            raise Http404
        else:
            query = RequestProcessor(request).get_arguments(datastream["parameters"])
            chart_type = form.cleaned_data.get('type')

            query.update({
                'pId': int(datastream_revision_id),
                'pType': chart_type,
                'pNullValueAction': form.cleaned_data.get('nullValueAction'),
                'pNullValuePreset': form.cleaned_data.get('nullValuePreset'),
                'pData': form.cleaned_data.get('data'),
                'pLabelSelection': form.cleaned_data.get('labels'),
                'pHeaderSelection': form.cleaned_data.get('headers'),
                'pInvertedAxis': form.cleaned_data.get('invertedAxis'),
                'pInvertData': form.cleaned_data.get('invertData')
            })

            page = form.cleaned_data.get('page')
            if page is not None:
                query['pPage'] = page

            limit = form.cleaned_data.get('limit')
            if limit is not None:
                query['pLimit'] = form.cleaned_data.get('limit')

            result, content_type = preview_chart(query)

            return HttpResponse(result, mimetype=content_type)
Ejemplo n.º 4
0
def preview_map(request, datastream_revision_id):

    preferences = request.preferences
    form = forms.PreviewMapForm(request.GET)

    if form.is_valid():
        try:
            datastream = DataStreamDBDAO().get(
                request.user.language,
                datastream_revision_id=datastream_revision_id,
                published=False
            )
        except Exception, e:
            logger.error(e)
            raise Http404
        else:
            query = RequestProcessor(request).get_arguments(datastream["parameters"])

            query.update({
                'pId': int(datastream_revision_id),
                'pType': 'mapchart',
                'pNullValueAction': form.cleaned_data.get('nullValueAction', 'exclude'),
                'pNullValuePreset': form.cleaned_data.get('nullValuePreset', ''),
                'pData': form.cleaned_data.get('data', ''),
                'pLatitudSelection': form.cleaned_data.get('lat', ''),
                'pLongitudSelection': form.cleaned_data.get('lon', ''),
                'pHeaderSelection': '',
                'pTraceSelection': '',
            })

            # Optional
            bounds = form.cleaned_data.get('bounds')
            if bounds is not None:
                query['pBounds'] = bounds

            zoom = form.cleaned_data.get('zoom')
            if zoom is not None:
                query['pZoom'] = zoom

            result, content_type = preview_chart(query)

            return HttpResponse(result, mimetype=content_type)