# Path: ref/mql.py
# def __build_grammar():
# def run(query, return_sensitive_data=False):
# def __run(q, return_sensitive_data):
# def __select_compo(q, return_sensitive_data):
# def __to_dict(rs, selector=None, optim=True, use_computed_fields=False, return_sensitive_data=False):


from django.http.response import HttpResponse
from django.shortcuts import render
from django import forms
from ref import mql
import unicodecsv as csv
import json
# coding: utf-8



class MqlTesterForm(forms.Form):
    mql = forms.CharField(max_length=300, initial='SELECT INSTANCES', label='Requête MQL', widget=forms.TextInput(
                 attrs={'size':'200', 'class':'inputText'}))

def mql_tester(request):
    base = request.build_absolute_uri('/')[:-1]
    error = None
    if request.method == 'POST': # If the form has been submitted...
        form = MqlTesterForm(request.POST) # A form bound to the POST data
        if form.is_valid(): # All validation rules pass
            try:

# Path: ref/mql.py
# def __build_grammar():
# def run(query, return_sensitive_data=False):
# def __run(q, return_sensitive_data):
# def __select_compo(q, return_sensitive_data):
# def __to_dict(rs, selector=None, optim=True, use_computed_fields=False, return_sensitive_data=False):


# Path: ref/views/mql.py
from django.http.response import HttpResponse
from django.shortcuts import render
from django import forms
from ref import mql
import unicodecsv as csv
import json

# coding: utf-8



class MqlTesterForm(forms.Form):
    mql = forms.CharField(max_length=300, initial='SELECT INSTANCES', label='Requête MQL', widget=forms.TextInput(
                 attrs={'size':'200', 'class':'inputText'}))

def mql_tester(request):
    base = request.build_absolute_uri('/')[:-1]
    error = None
    if request.method == 'POST': # If the form has been submitted...
        form = MqlTesterForm(request.POST) # A form bound to the POST data
        if form.is_valid(): # All validation rules pass
            try:

                res = mql.run(form.cleaned_data['mql'], return_sensitive_data = request.user.has_perm('ref.allfields_componentinstance'))