def qaqcPage(request, model='none'): viewmodule = importlib.import_module('.views', 'models.'+model) qaqcmodule = importlib.import_module('.'+model+'_qaqc', 'models.'+model) tablesmodule = importlib.import_module('.'+model+'_tables', 'models.'+model) from REST import rest_funcs header = viewmodule.header html = render_to_string('01uberheader.html', {'title': header+' QA/QC'}) html = html + render_to_string('02uberintroblock_wmodellinks.html', {'model':model,'page':'qaqc'}) html = html + linksLeft.linksLeft() html = html + render_to_string('04uberoutput_start.html', { 'model':model, 'model_attributes': header+' QAQC'}) try: modelQAQC_obj = getattr(qaqcmodule, model+'_obj') # Calling model object, e.g. 'sip_obj' html = html + tablesmodule.timestamp(modelQAQC_obj) html = html + tablesmodule.table_all_qaqc(modelQAQC_obj) rest_funcs.save_dic(html, modelQAQC_obj.__dict__, model, 'qaqc') except: pass html = html + render_to_string('export.html', {}) html = html + render_to_string('04uberoutput_end.html', {'sub_title': ''}) html = html + render_to_string('06uberfooter.html', {'links': ''}) response = HttpResponse() response.write(html) return response
def qaqcPage(request, model='none'): viewmodule = importlib.import_module('.views', 'models.'+model) qaqcmodule = importlib.import_module('.'+model+'_qaqc', 'models.'+model) tablesmodule = importlib.import_module('.'+model+'_tables', 'models.'+model) from REST import rest_funcs header = viewmodule.header html = render_to_string('01uberheader.html', { 'site_skin' : os.environ['SITE_SKIN'], 'title': header+' QA/QC'}) html = html + render_to_string('02uberintroblock_wmodellinks.html', { 'site_skin' : os.environ['SITE_SKIN'], 'model':model, 'page':'qaqc'}) html = html + linksLeft.linksLeft() html = html + render_to_string('04uberoutput_start.html', { 'model':model, 'model_attributes': header+' QAQC'}) try: modelQAQC_obj = getattr(qaqcmodule, model+'_obj') # Calling model object, e.g. 'sip_obj' html = html + tablesmodule.timestamp(modelQAQC_obj) html = html + tablesmodule.table_all_qaqc(modelQAQC_obj) rest_funcs.save_dic(html, modelQAQC_obj.__dict__, model, 'qaqc') except: pass html = html + render_to_string('export.html', {}) html = html + render_to_string('04uberoutput_end.html', {'sub_title': ''}) html = html + render_to_string('06uberfooter.html', {'links': ''}) response = HttpResponse() response.write(html) return response
def qaqcRunView(request, model='none', runID=''): """ View to render the QAQC output page HTML """ viewmodule = importlib.import_module('.views', 'models.'+model) tablesmodule = importlib.import_module('.'+model+'_tables', 'models.'+model) from REST import rest_funcs header = viewmodule.header html = render_to_string('01uberheader.html', { 'site_skin' : os.environ['SITE_SKIN'], 'title': header+' QA/QC'}) html = html + render_to_string('02uberintroblock_wmodellinks.html', { 'site_skin' : os.environ['SITE_SKIN'], 'model':model, 'page':'qaqc'}) html = html + links_left.ordered_list() html = html + render_to_string('04uberoutput_start.html', { 'model':model, 'model_attributes': header+' QAQC'}) # Temporary logic to handle Pandas versions, else use old way if model in {'terrplant', 'sip', 'stir', 'trex', 'therps', 'iec', 'agdrift', 'earthworm', 'rice', 'kabam'}: import logging logging.info('=========== New Model Handler - QAQC Run ===========') modelQAQC_obj = qaqcRun(model) html = html + tablesmodule.timestamp(modelQAQC_obj[0]) qaqc_output_html = "" i = 0 for model in modelQAQC_obj: qaqc_output_html += tablesmodule.table_all_qaqc(modelQAQC_obj[i]) i += 1 html = html + qaqc_output_html else: try: modelQAQC_obj = getattr(qaqcmodule, model+'_obj') # Calling model object, e.g. 'sip_obj' html = html + tablesmodule.timestamp(modelQAQC_obj) html = html + tablesmodule.table_all_qaqc(modelQAQC_obj) except: html += "" try: rest_funcs.save_dic(html, modelQAQC_obj.__dict__, model, 'qaqc') except: pass html = html + render_to_string('export.html', {}) html = html + render_to_string('04uberoutput_end.html', {'sub_title': ''}) html = html + render_to_string('06uberfooter.html', {'links': ''}) response = HttpResponse() response.write(html) return response
def outputPageView(request, model='none', header=''): outputmodule = importlib.import_module('.' + model + '_output', 'models.' + model) tablesmodule = importlib.import_module('.' + model + '_tables', 'models.' + model) from REST import rest_funcs outputPageFunc = getattr( outputmodule, model + 'OutputPage' ) # function name = 'model'OutputPage (e.g. 'sipOutputPage') model_obj = outputPageFunc(request) if type(model_obj) is tuple: modelOutputHTML = model_obj[0] model_obj = model_obj[1] else: # logging.info(model_obj.__dict__) modelOutputHTML = tablesmodule.timestamp(model_obj) tables_output = tablesmodule.table_all(model_obj) if type(tables_output) is tuple: modelOutputHTML = modelOutputHTML + tables_output[0] elif type(tables_output) is str or type(tables_output) is unicode: modelOutputHTML = modelOutputHTML + tables_output else: modelOutputHTML = "table_all() Returned Wrong Type" # Render output page view html = render_to_string('01uberheader.html', { 'site_skin': os.environ['SITE_SKIN'], 'title': header + ' Output' }) html = html + render_to_string('02uberintroblock_wmodellinks.html', { 'site_skin': os.environ['SITE_SKIN'], 'model': model, 'page': 'output' }) html = html + linksLeft.linksLeft() html = html + render_to_string('04uberoutput_start.html', {'model_attributes': header + ' Output'}) html = html + modelOutputHTML html = html + render_to_string('export.html', {}) html = html + render_to_string('04uberoutput_end.html', {'model': model}) html = html + render_to_string('06uberfooter.html', {'links': ''}) # Handle Trex, which is not objectified yet if model != 'trex': rest_funcs.save_dic(html, model_obj.__dict__, model, "single") response = HttpResponse() response.write(html) return response
def saveToMongoDB(model_obj): """ Method to check if model run is to be saved to MongoDB. If true, the fest_func method to save the model object instance is called """ from REST import rest_funcs # Handle Trex, which is not objectified yet; therefore, not saved in MongoDB # if model != 'trex': if model not in {'terrplant', 'sip', 'stir', 'trex', }: logging.info("rest_funcs.save_model_object() called") # save_dic() rest_func method saves HTML & model object rest_funcs.save_dic(html, model_obj.__dict__, model, "single")
def outputPageView(request, model='none', header=''): outputmodule = importlib.import_module('.'+model+'_output', 'models.'+model) tablesmodule = importlib.import_module('.'+model+'_tables', 'models.'+model) from REST import rest_funcs outputPageFunc = getattr(outputmodule, model+'OutputPage') # function name = 'model'OutputPage (e.g. 'sipOutputPage') model_obj = outputPageFunc(request) if type(model_obj) is tuple: modelOutputHTML = model_obj[0] model_obj = model_obj[1] else: # logging.info(model_obj.__dict__) modelOutputHTML = tablesmodule.timestamp(model_obj) tables_output = tablesmodule.table_all(model_obj) if type(tables_output) is tuple: modelOutputHTML = modelOutputHTML + tables_output[0] elif type(tables_output) is str or type(tables_output) is unicode: modelOutputHTML = modelOutputHTML + tables_output else: modelOutputHTML = "table_all() Returned Wrong Type" # Render output page view html = render_to_string('01uberheader.html', { 'site_skin' : os.environ['SITE_SKIN'], 'title': header+' Output'}) html = html + render_to_string('02uberintroblock_wmodellinks.html', { 'site_skin' : os.environ['SITE_SKIN'], 'model':model, 'page':'output'}) html = html + linksLeft.linksLeft() html = html + render_to_string('04uberoutput_start.html', { 'model_attributes': header+' Output'}) html = html + modelOutputHTML html = html + render_to_string('export.html', {}) html = html + render_to_string('04uberoutput_end.html', {'model':model}) html = html + render_to_string('06uberfooter.html', {'links': ''}) # Handle Trex, which is not objectified yet if model != 'trex': rest_funcs.save_dic(html, model_obj.__dict__, model, "single") response = HttpResponse() response.write(html) return response
def outputPage(request, model='none'): viewmodule = importlib.import_module('.views', 'models.'+model) tablesmodule = importlib.import_module('.'+model+'_tables', 'models.'+model) from REST import rest_funcs header = viewmodule.header outputPageFunc = getattr(viewmodule, model+'OutputPage') # function name = 'model'OutputPage (e.g. 'sipOutputPage') model_obj = outputPageFunc(request) html = render_to_string('01uberheader.html', {'title': header+' Output'}) html = html + render_to_string('02uberintroblock_wmodellinks.html', {'model':model,'page':'output'}) html = html + linksLeft() html = html + render_to_string('04uberoutput_start.html', { 'model_attributes': header+' Output'}) html = html + tablesmodule.timestamp(model_obj) html = html + tablesmodule.table_all(model_obj) html = html + render_to_string('export.html', {}) html = html + render_to_string('04uberoutput_end.html', {}) html = html + render_to_string('06uberfooter.html', {'links': ''}) rest_funcs.save_dic(html, model_obj.__dict__, model, "single") response = HttpResponse() response.write(html) return response