示例#1
0
文件: views.py 项目: ITIDO/gfatm
def summary_trend(request, template_name="graphing/summary_trend.html"):
    """This is just a really really basic trend of total counts for a given set 
       of forms under this domain/organization"""    
    context = {}        
    formname = ''
    formdef_id = -1
    
    for item in request.GET.items():
        if item[0] == 'formdef_id':
            formdef_id=item[1]    
    if formdef_id == -1:
        context['chart_title'] = 'All Data'
        context['dataset'] = {}        
        defs = FormDefModel.objects.all().filter(domain=request.user.selected_domain)
    
        for fdef in defs:            
            d = dbhelper.DbHelper(fdef.element.table_name, fdef.form_display_name)            
            context['dataset'][fdef.form_display_name.__str__()] = d.get_counts_dataset(None,None)                    
    
    else:
        fdef = FormDefModel.objects.all().filter(id=formdef_id)
        context['chart_title'] = fdef[0].form_display_name
        d = dbhelper.DbHelper(fdef[0].element.table_name,fdef[0].form_display_name)        
        context['dataset'] = d.get_integer_series_dataset()
    
    context ['maxdate'] = 0;
    context ['mindate'] = 0;
    return render_to_response(request, template_name, context)
示例#2
0
文件: views.py 项目: ITIDO/gfatm
def inspector(request, table_name, template_name="graphing/table_inspector.html"):
    context = {}
    context['table_name'] = table_name
    
    str_column = None
    str_column_value = None
    datetime_column = None
    data_column = None
    display_mode = None    
    
    for item in request.GET.items():
        if item[0] == 'str_column':
            str_column = item[1]                    
        if item[0] == 'str_column_value':
            str_column_value = item[1] 
        if item[0] == 'datetime_column':
            datetime_column = item[1]   
        if item[0] == 'data_column':
            data_column = item[1]        
        if item[0] == 'display_mode':
            display_mode = item[1]    
            
    context['str_column'] = str_column
    context['str_column_value'] = str_column_value
    context['datetime_column'] = datetime_column
    context['data_column'] = data_column
    context['display_mode'] = display_mode    
    
    return render_to_response(request, template_name, context)
示例#3
0
文件: views.py 项目: ITIDO/gfatm
def view_graph(request, graph_id, template_name="graphing/view_graph.html"):
    context = {}    
    graph = RawGraph.objects.all().get(id=graph_id)
    
    #get the root group
    # inject some stuff into the rawgraph.  we can also do more
    # here but for now we'll just work with the domain and set 
    # some dates.  these can be templated down to the sql
    graph.domain = request.user.selected_domain.name
    startdate, enddate = utils.get_dates(request, graph.default_interval)
    graph.startdate = startdate.strftime("%Y-%m-%d")
    graph.enddate = (enddate + timedelta(days=1)).strftime("%Y-%m-%d")
    
    context['chart_title'] = graph.title
    context['chart_data'] = graph.get_flot_data()
    context['thegraph'] = graph
    
    rootgroup = utils.get_chart_group(request.user)    
    graphtree = get_graphgroup_children(rootgroup)    
    context['graphtree'] = graphtree
    context['view_name'] = 'graphing.views.view_graph'
    context['width'] = graph.width
    context['height'] = graph.height
    context['empty_dict'] = {}
    context['datatable'] = graph.convert_data_to_table(context['chart_data'])
    for item in request.GET.items():
        if item[0] == 'bare':
            template_name = 'graphing/view_graph_bare.html'
        elif item[0] == 'data':
            template_name='graphing/view_graph_data.html'
        elif item[0] == 'csv':             
            return _get_chart_csv(graph)
    return render_to_response(request, template_name, context)
示例#4
0
文件: views.py 项目: ITIDO/gfatm
def view_group(request, group_id, template_name="graphing/view_group.html"):
    context = {}
    group = GraphGroup.objects.all().get(id=group_id)
    context['group'] = group  
    context['group_charts'] = []
    context['width'] = 900
    context['height'] = 350
    
    for thegraph in group.graphs.all():
        if hasattr(thegraph,'rawgraph'):
            context['group_charts'].append(thegraph.rawgraph)
        else:
            context['group_charts'].append(thegraph)    
    
    context['child_groups'] = GraphGroup.objects.all().filter(parent_group=group)
    
    rootgroup = utils.get_chart_group(request.user)    
    graphtree = get_graphgroup_children(rootgroup)
    context['graphtree'] = graphtree
    
    return render_to_response(request, template_name, context)
示例#5
0
文件: views.py 项目: ITIDO/gfatm
def view_groups(request, template_name="graphing/view_groups.html"):
    context = {}    
    context['groups'] = GraphGroup.objects.all()
    return render_to_response(request, template_name, context)

    context = {}
示例#6
0
文件: views.py 项目: ITIDO/gfatm
def show_multi(request, template_name="graphing/multi_graph.html"):
    context = {}    
    context['width'] = 900
    context['height'] = 350
    context['charts_to_show'] = RawGraph.objects.all()
    return render_to_response(request, template_name, context)
示例#7
0
文件: views.py 项目: ITIDO/gfatm
def show_allgraphs(request, template_name="graphing/show_allgraphs.html"):
    context = {}    
    context['allgraphs'] = RawGraph.objects.all()    
    return render_to_response(request, template_name, context)
示例#8
0
文件: views.py 项目: ITIDO/gfatm
def show(request, photo_id, template_name="photos/single.html"):
    p = Photo.objects.get(id=photo_id)
    return render_to_response(request, template_name, {'photo' : p})
示例#9
0
文件: views.py 项目: ITIDO/gfatm
def recent(request, template_name="photos/list.html"):
    photos = Photo.objects.all()
    return render_to_response(request, template_name, {'photos' : photos})