Example #1
0
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
Example #2
0
def moduleDescriptions(request, module=None):
    logging.info("MODULE: " + module)

    html = render_to_string("01cts_uberheader.html", {"title": "Error"})
    html += render_to_string("02cts_uberintroblock_nomodellinks.html", {"title2": "File not found"})
    html += linksLeft.linksLeft()

    module_text = ""
    if module == "chemedit-description":
        module_text = chemeditDescription()
    elif module == "pchemprop-description":
        module_text = pchempropDescription()
    elif module == "reactsim-description":
        module_text = reactsimDescription()
    elif module == "mamm-metabo":
        module_text = mMetabolismDescription()

        # body of page:
    html += render_to_string("04ubertext_start.html", {"model_attributes": "", "text_paragraph": module_text})

    html += render_to_string("04cts_ubertext_end.html", {})
    html += render_to_string("05cts_ubertext_links_right.html", {})
    html += render_to_string("06cts_uberfooter.html", {"links": ""})

    response = HttpResponse()
    response.write(html)

    return response
Example #3
0
def batchOutputPage(request, model='none', header='none'):
    viewmodule = importlib.import_module('.views', 'models.'+model)
    batchoutputmodule = importlib.import_module('.'+model+'_batchoutput', 'models.'+model)
    from REST import rest_funcs
    header = viewmodule.header
    linksleft = linksLeft.linksLeft()

    html = render_to_string('04uberbatch_start.html', {
            'model': model,
            'model_attributes': header+' Batch Output'})

    batchOutputPageFunc = getattr(batchoutputmodule, model+'BatchOutputPage')  # function name = 'model'BatchOutputPage  (e.g. 'sipBatchOutputPage')
    batchOutputTuple = batchOutputPageFunc(request)
    if model == 'przm':
        logging.info(batchOutputTuple)
        html = html + ''
    else:
        html = html + batchOutputTuple[0]
        html = html + render_to_string('export.html', {})
        html = html + render_to_string('04uberoutput_end.html', {})

        model_all = batchOutputTuple[1]
        jid_batch = batchOutputTuple[2]
        rest_funcs.batch_save_dic(html, [x.__dict__ for x in model_all], model, 'batch', jid_batch[0], linksleft)

    response = HttpResponse()
    response.write(html)
    return response
Example #4
0
def historyPage(request, model='none', header='none'):
    viewmodule = importlib.import_module('.views', 'models.' + model)
    header = viewmodule.header

    html = render_to_string('01uberheader.html',
                            {'title': header + ' History'})
    html = html + render_to_string('02uberintroblock_wmodellinks.html', {
        'model': model,
        'page': 'history'
    })
    html = html + linksLeft.linksLeft()
    html = html + render_to_string(
        '04uberalgorithm_start.html',
        {'model_attributes': header + ' User History'})
    html = html + render_to_string('history_pagination.html', {})

    hist_obj = rest_funcs.user_hist('admin', model)
    html = html + table_all(hist_obj)

    html = html + render_to_string('04ubertext_end.html', {})
    html = html + render_to_string('06uberfooter.html', {'links': ''})

    response = HttpResponse()
    response.write(html)
    return response
Example #5
0
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
Example #6
0
def batchInputPage(request, model='none', header='none'):
    viewmodule = importlib.import_module('.views', 'cts_app.models.'+model)
    inputmodule = importlib.import_module('.'+model+'_batch', 'cts_app.models.'+model)
    header = viewmodule.header
    
    html = render_to_string('01cts_uberheader.html', {'title': header+' Batch'})
    html = html + render_to_string('02cts_uberintroblock_wmodellinks.html', {'model':model,'page':'batchinput'})
    html = html + linksLeft.linksLeft()
    html = html + render_to_string('04cts_uberbatchinput.html', {
            'model': model,
            'model_attributes': header+' Batch Run'})

    html += render_to_string('04cts_uberinput_jquery.html', { 'model': model}) # loads scripts_pchemprop.js


    inputPageFunc = getattr(inputmodule, model+'BatchInputPage')  # function name = 'model'InputPage  (e.g. 'sipInputPage')
    html = html + inputPageFunc(request, model, header)


    html = html + render_to_string('04cts_uberbatchinput_jquery.html', {'model':model, 'header':header})
    
    # html = html + render_to_string('05cts_ubertext_links_right.html', {})
    html = html + render_to_string('06cts_uberfooter.html', {'links': ''})

    response = HttpResponse()
    response.write(html)
    return response
Example #7
0
def descriptionPage(request, model='none', header='none'):
    viewmodule = importlib.import_module('.views', 'models.' + model)
    header = viewmodule.header

    text_file2 = open(
        os.path.join(os.environ['PROJECT_PATH'],
                     'models/' + model + '/' + model + '_text.txt'), 'r')
    xx = text_file2.read()
    html = render_to_string('01uberheader.html', {
        'site_skin': os.environ['SITE_SKIN'],
        'title': header + ' Description'
    })
    html = html + render_to_string(
        '02uberintroblock_wmodellinks.html', {
            'site_skin': os.environ['SITE_SKIN'],
            'model': model,
            'page': 'description'
        })
    html = html + linksLeft.linksLeft()
    html = html + render_to_string('04ubertext_start.html', {
        'model_attributes': header + ' Overview',
        'text_paragraph': xx
    })
    html = html + render_to_string('04ubertext_end.html', {})
    html = html + render_to_string('05ubertext_links_right.html', {})
    html = html + render_to_string('06uberfooter.html', {'links': ''})

    response = HttpResponse()
    response.write(html)
    return response
Example #8
0
def historyPage(request, model='none', header='none'):
    viewmodule = importlib.import_module('.views', 'models.'+model)
    header = viewmodule.header

    html = render_to_string('01uberheader.html', {
            'site_skin' : os.environ['SITE_SKIN'],
            'title': header+' History'})
    html = html + render_to_string('02uberintroblock_wmodellinks.html', {
            'site_skin' : os.environ['SITE_SKIN'],
            'model':model,
            'page':'history'})
    html = html + linksLeft.linksLeft()
    html = html + render_to_string('04uberalgorithm_start.html', {
            'model_attributes': header+' User History'})
    html = html + render_to_string('history_pagination.html', {})   

    hist_obj = rest_funcs.user_hist('admin', model)
    html = html + table_all(hist_obj)

    html = html + render_to_string('04ubertext_end.html', {})
    html = html + render_to_string('06uberfooter.html', {'links': ''})

    response = HttpResponse()
    response.write(html)
    return response
Example #9
0
def batchInputPage(request, model='none', header='none'):
    viewmodule = importlib.import_module('.views', 'models.'+model)
    header = viewmodule.header
    
    html = render_to_string('01uberheader.html', {
            'site_skin' : os.environ['SITE_SKIN'],
            'title': header+' Batch'})
    html = html + render_to_string('02uberintroblock_wmodellinks.html', {
            'site_skin' : os.environ['SITE_SKIN'],
            'model':model,
            'page':'batchinput'})
    html = html + linksLeft.linksLeft()
    html = html + render_to_string('04uberbatchinput.html', {
            'model': model,
            'model_attributes': header+' Batch Run'})
    if model == 'przm':
        html = html + render_to_string('04uberbatchinput_jquery_przm_batch.html', {'model':model, 'header':header})
    else:
        html = html + render_to_string('04uberbatchinput_jquery.html', {'model':model, 'header':header})
    html = html + render_to_string('05ubertext_links_right.html', {})
    html = html + render_to_string('06uberfooter.html', {'links': ''})

    response = HttpResponse()
    response.write(html)
    return response
Example #10
0
def outputPage(request, model='none', header=''):

    viewmodule = importlib.import_module('.views', 'models.' + model)

    header = viewmodule.header

    parametersmodule = importlib.import_module('.' + model + '_parameters',
                                               'models.' + model)

    try:
        # Class name must be ModelInp, e.g. SipInp or TerrplantInp
        inputForm = getattr(parametersmodule, model.title() + 'Inp')
        form = inputForm(request.POST)  # bind user inputs to form object

        # Form validation testing
        if form.is_valid():
            return outputPageView(request, model, header)

        else:
            logging.info(form.errors)
            inputmodule = importlib.import_module('.' + model + '_input',
                                                  'models.' + model)

            # Render input page view with POSTed values and show errors
            html = render_to_string('01uberheader.html', {
                'site_skin': os.environ['SITE_SKIN'],
                'title': header + ' Inputs'
            })
            html = html + render_to_string(
                '02uberintroblock_wmodellinks.html', {
                    'site_skin': os.environ['SITE_SKIN'],
                    'model': model,
                    'page': 'input'
                })
            html = html + linksLeft.linksLeft()

            inputPageFunc = getattr(
                inputmodule, model + 'InputPage'
            )  # function name = 'model'InputPage  (e.g. 'sipInputPage')
            html = html + inputPageFunc(
                request, model, header, formData=request.POST
            )  # formData contains the already POSTed form data

            html = html + render_to_string('06uberfooter.html', {'links': ''})

            response = HttpResponse()
            response.write(html)
            return response

        # end form validation testing

    except Exception, e:
        logging.exception(e)
        logging.info("E X C E P T")

        return outputPageView(request, model, header)
Example #11
0
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
Example #12
0
def outputPage(request, model='none', header=''):
    """
    Django HTTP POST handler for output page.  Receives form data and
    validates it.  If valid it calls method to render the output page
    view.  If invalid, it returns the error to the model input page.
    """

    viewmodule = importlib.import_module('.views', 'models.'+model)

    header = viewmodule.header

    parametersmodule = importlib.import_module('.'+model+'_parameters', 'models.'+model)

    try:
        # Class name must be ModelInp, e.g. SipInp or TerrplantInp
        inputForm = getattr(parametersmodule, model.title() + 'Inp')
        form = inputForm(request.POST) # bind user inputs to form object

        # Form validation testing
        if form.is_valid():
            return outputPageView(request, model, header)

        else:
            logging.info(form.errors)
            inputmodule = importlib.import_module('.'+model+'_input', 'models.'+model)

            # Render input page view with POSTed values and show errors
            html = render_to_string('01uberheader.html', {
                    'site_skin' : os.environ['SITE_SKIN'],
                    'title': header+' Inputs'})
            html = html + render_to_string('02uberintroblock_wmodellinks.html', {
                    'site_skin' : os.environ['SITE_SKIN'],
                    'model':model,
                    'page':'input'})
            html = html + linksLeft.linksLeft()

            inputPageFunc = getattr(inputmodule, model+'InputPage')  # function name = 'model'InputPage  (e.g. 'sipInputPage')
            html = html + inputPageFunc(request, model, header, formData=request.POST)  # formData contains the already POSTed form data

            html = html + render_to_string('06uberfooter.html', {'links': ''})
            
            response = HttpResponse()
            response.write(html)
            return response

        # end form validation testing

    except Exception, e:
        logging.exception(e)
        logging.info("E X C E P T")

        return outputPageView(request, model, header)
Example #13
0
def fileNotFound(request, model=None):
    html = render_to_string("01cts_uberheader.html", {"title": "Error"})
    html = html + render_to_string("02cts_uberintroblock_nomodellinks.html", {"title2": "File not found"})
    html = html + linksLeft.linksLeft()
    html = html + render_to_string(
        "04ubertext_start.html", {"model_attributes": "This page is still under maintenance", "text_paragraph": ""}
    )
    # html = html + """ <img src="/static_qed/cts/images/404error.png" width="300" height="300">"""
    html = html + """<img src="/static_qed/cts/images/fist-with-hammer.jpg" style="display:block; margin:auto;">"""
    html = html + render_to_string("04cts_ubertext_end.html", {})
    html = html + render_to_string("05cts_ubertext_links_right.html", {})
    html = html + render_to_string("06cts_uberfooter.html", {"links": ""})
    response = HttpResponse()
    response.write(html)
    return response
Example #14
0
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
Example #15
0
def fileNotFound(request):
    html = render_to_string('01uberheader.html', {'title': 'Error'})
    html = html + render_to_string('02uberintroblock_nomodellinks.html', {'title2':'File not found'})
    html = html + linksLeft.linksLeft()
    html = html + render_to_string('04ubertext_start.html', {
            'model_attributes': 'File Not Found',
            'text_paragraph': ""})
    html = html + """ <img src="/static/images/404error.png" width="300" height="300">"""
    html = html + render_to_string('04ubertext_end.html', {})
    html = html + render_to_string('05ubertext_links_right.html', {})
    html = html + render_to_string('06uberfooter.html', {'links': ''})

    response = HttpResponse()
    response.write(html)

    return response
Example #16
0
def requestTimeout(request):
    html = render_to_string("01cts_uberheader.html", {"title": "Error"})
    html = html + render_to_string("02cts_uberintroblock_nomodellinks.html", {"title2": "Request timed out"})
    html = html + linksLeft.linksLeft()
    html = (
        html
        + """<div class="articles">
                    <img class="model_header" src="/static_qed/cts/images/408error.png" width="300" height="300">
                    </div>"""
    )
    html = html + render_to_string("05cts_ubertext_links_right.html", {})
    html = html + render_to_string("06cts_uberfooter.html", {"links": ""})

    response = HttpResponse()
    response.write(html)

    return response
Example #17
0
def displayPDF(request, reactionLib=None):
    if "ahydrolysis" in request.path:
        logging.info("ahydrolysis in path!")
        title = "Abiotic Hydrolysis Reaction Library"
        # pdfHTML = '<embed src="file_name.pdf" width=800px height=2100px>'
        pdfHTML = """
		<p>Version 1.6 of the Abiotic Hydrolysis Reaction Library contains 25 reaction schemes.  Left click a reaction scheme to view the generalized reaction scheme, supporting reaction rules for reactivity, selectivity and exclusion, as well as example transformation pathways based on the execution of the reaction scheme.  References to process science on which the reaction scheme was developed are also provided.</p>
		<br>
		<h3> Click <a href="/static_qed/cts/docs/HydrolysisRxnLib_ver1-6.pdf" download="HydrolysisRxnLib_ver1-6.pdf">here</a> to download if file doesn't load</h3>
		<embed src="/static_qed/cts/docs/HydrolysisRxnLib_ver1-6.pdf" class="libPDF">
		"""
    elif "areduction" in request.path:
        logging.info("areduction in path!")
        title = "Abiotic Reduction Reaction Library"
        pdfHTML = """
		<p>Version 1.4 of the Abiotic Reduction Reaction Library contains 8 reaction schemes.  Left click a reaction scheme to view the generalized reaction scheme, supporting reaction rules for reactivity, selectivity and exclusion, as well as example transformation pathways based on the execution of the reaction scheme.  References to process science on which the reaction scheme was developed are also provided.</p>
		<br>
		<h3> Click <a href="/static_qed/cts/docs/AbioticReductionRxnLib_vers1-4.pdf" download="AbioticReductionRxnLib_vers1-4.pdf">here</a> to download if file doesn't load</h3>
		<embed src="/static_qed/cts/docs/AbioticReductionRxnLib_vers1-4.pdf" class="libPDF">
		"""
    elif "guide" in request.path:
        title = "CTS User's Guide"
        pdfHTML = """
		<h3> Click <a href="/static_qed/cts/docs/CTS_USER_Guide_weber_9-14-15.docx" download="CTS_USER_Guide_weber_9-14-15.docx">here</a> to download if the file does not load </h3>
		<embed src="/static_qed/cts/docs/CTS_USER_Guide_weber_9-14-15.docx" class="libPDF">'
		"""
    else:
        logging.info("error")
        fileNotFound(request)
        return

    html = render_to_string("01cts_uberheader.html")
    html += render_to_string("02cts_uberintroblock_nomodellinks.html")
    html += linksLeft.linksLeft()
    html += render_to_string("04ubertext_start.html", {"model_attributes": title, "text_paragraph": pdfHTML})
    # 'text_paragraph': "<br><br>"})
    # html += pdfHTML
    # html = html + """<img src="/static_qed/cts/images/fist-with-hammer.jpg" style="display:block; margin:auto;">"""
    html += render_to_string("04cts_ubertext_end.html", {})
    html += render_to_string("05cts_ubertext_links_right.html", {})
    html += render_to_string("06cts_uberfooter.html", {"links": ""})

    response = HttpResponse()
    response.write(html)

    return response
Example #18
0
def przm5IntermediatePage(request):
    data_all = json.loads(request.body)
    data_html = data_all["data_html"]
    logger.info(data_html)
    jid = str(data_all["jid"])
    html = render_to_string('01uberheader.html', {'title': 'PRZM5'+' Output'})
    html = html + render_to_string('02uberintroblock_wmodellinks.html',  {'model':'przm5','page':'output'})
    html = html + linksLeft.linksLeft()
    html = html + render_to_string('04uberoutput_start.html', {})
    html = html + data_html
    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.update_html(html, jid, 'przm5')
    response = HttpResponse()
    response.write(html)
    return response
Example #19
0
def ecoLandingPage(request):
    text_file2 = open('views/main_text.txt', 'r')
    xx = text_file2.read()

    html = render_to_string('01uberheader_main.html', {})
    html = html + render_to_string('02uberintroblock_nomodellinks.html', {})
    html = html + linksLeft.linksLeft()
    html = html + render_to_string('04ubertext_start_index.html',
                                   {'text_paragraph': xx})
    html = html + render_to_string('04ubertext_end.html', {})
    html = html + render_to_string('05ubertext_links_right.html', {})
    html = html + render_to_string('06uberfooter.html', {'links': ''})

    response = HttpResponse()
    response.write(html)

    return response
Example #20
0
def ctsLandingPage(request):
    text_file2 = open(os.path.join(os.environ['PROJECT_PATH'], 'cts_app/views/main_text.txt'),'r')
    xx = text_file2.read()

    html = render_to_string('01cts_uberheader.html', {})
    html = html + render_to_string('02cts_uberintroblock_nomodellinks.html', {})
    html = html + linksLeft.linksLeft()
    html = html + render_to_string('04cts_ubertext_start_index.html', {
            'text_paragraph':xx
            })
    html = html + render_to_string('04cts_ubertext_end.html',{})
    html = html + render_to_string('05cts_ubertext_links_right.html', {})
    html = html + render_to_string('06cts_uberfooter.html', {'links': ''})

    response = HttpResponse()
    response.write(html)

    return response
Example #21
0
def fileNotFound(request):
    html = render_to_string('01uberheader.html', {'title': 'Error'})
    html = html + render_to_string('02uberintroblock_nomodellinks.html',
                                   {'title2': 'File not found'})
    html = html + linksLeft.linksLeft()
    html = html + render_to_string('04ubertext_start.html', {
        'model_attributes': 'File Not Found',
        'text_paragraph': ""
    })
    html = html + """ <img src="/static/images/404error.png" width="300" height="300">"""
    html = html + render_to_string('04ubertext_end.html', {})
    html = html + render_to_string('05ubertext_links_right.html', {})
    html = html + render_to_string('06uberfooter.html', {'links': ''})

    response = HttpResponse()
    response.write(html)

    return response
Example #22
0
def ecoLandingPage(request):
    text_file2 = open('views/main_text.txt','r')
    xx = text_file2.read()

    html = render_to_string('01uberheader_main.html', {})
    html = html + render_to_string('02uberintroblock_nomodellinks.html', {})
    html = html + linksLeft.linksLeft()
    html = html + render_to_string('04ubertext_start_index.html', {
            'text_paragraph':xx
            })
    html = html + render_to_string('04ubertext_end.html',{})
    html = html + render_to_string('05ubertext_links_right.html', {})
    html = html + render_to_string('06uberfooter.html', {'links': ''})

    response = HttpResponse()
    response.write(html)

    return response
Example #23
0
def batchOutputPage(request, model='none', header='none'):
    viewmodule = importlib.import_module('.views', 'cts_app.models.'+model)
    batchoutputmodule = importlib.import_module('.'+model+'_batch', 'cts_app.models.'+model)
    header = viewmodule.header
    
    # linksleft = linksLeft.linksLeft()

    html = render_to_string('01cts_uberheader.html', {'title': header+' Batch'})
    # html += render_to_string('02cts_uberintroblock_wmodellinks.html', {'model':model,'page':'batchinput'})
    html += render_to_string('02cts_uberintroblock_wmodellinks.html', 
        {'model':model,'page':'output'})
    html += linksLeft.linksLeft()

    html += render_to_string('04cts_uberbatch_start.html', {
            'model': model,
            'model_attributes': header+' Batch Output'})

    # timestamp / version section
    st = datetime.datetime.strptime(cts_rest.gen_jid(), 
        '%Y%m%d%H%M%S%f').strftime('%A, %Y-%B-%d %H:%M:%S')
    html += """
    <div class="out_">
        <b>{} Batch Version 1.0</a> (Beta)<br>
    """.format(header)
    html += st
    html += " (EST)</b>"
    html += """
    </div><br><br>"""

    html = html + render_to_string('cts_export.html', {})

    batchOutputPageFunc = getattr(batchoutputmodule, model+'BatchOutputPage')  # function name = 'model'BatchOutputPage  (e.g. 'sipBatchOutputPage')
    # batchOutputTuple = batchOutputPageFunc(request)

    # html = html + batchOutputTuple[0]

    html += batchOutputPageFunc(request)

    # html = html + render_to_string('export.html', {})
    html = html + render_to_string('04cts_uberoutput_end.html', {})

    response = HttpResponse()
    response.write(html)
    return response
Example #24
0
def referencesPage(request, model='none', header='none'):
    viewmodule = importlib.import_module('.views', 'models.'+model)
    header = viewmodule.header

    text_file1 = open('models/'+model+'/'+model+'_references.txt','r')
    x = text_file1.read()
    html = render_to_string('01uberheader.html', {'title': header+' References'})
    html = html + render_to_string('02uberintroblock_wmodellinks.html', {'model':model,'page':'references'})
    html = html + linksLeft.linksLeft()
    html = html + render_to_string('04uberreferences_start.html', {
            'model_attributes': header+' References', 
            'text_paragraph':x})
    html = html + render_to_string('04ubertext_end.html', {})
    html = html + render_to_string('05ubertext_links_right.html', {})
    html = html + render_to_string('06uberfooter.html', {'links': ''})
    
    response = HttpResponse()
    response.write(html)
    return response
Example #25
0
def outputPage(request, model='none', header=''):

    viewmodule = importlib.import_module('.views', 'cts_app.models.'+model)

    header = viewmodule.header

    parametersmodule = importlib.import_module('.'+model+'_parameters', 'cts_app.models.'+model)

    try:
        # Class name must be ModelInp, e.g. SipInp or TerrplantInp
        inputForm = getattr(parametersmodule, model.title() + 'Inp')
        
        form = inputForm(request.POST) # bind user inputs to form object

        # Form validation testing
        if form.is_valid():
            return outputPageView(request, model, header)

        else:

            inputmodule = importlib.import_module('.'+model+'_input', 'cts_app.models.'+model)

            # Render input page view with POSTed values and show errors
            html = render_to_string('01cts_uberheader.html', {'title': header+' Inputs'})
            html = html + render_to_string('02cts_uberintroblock_wmodellinks.html', {'model':model,'page':'input'})
            html = html + linksLeft.linksLeft()

            inputPageFunc = getattr(inputmodule, model+'InputPage')  # function name = 'model'InputPage  (e.g. 'sipInputPage')
            html = html + inputPageFunc(request, model, header, formData=request.POST)  # formData contains the already POSTed form data

            html = html + render_to_string('06cts_uberfooter.html', {'links': ''})
            
            response = HttpResponse()
            response.write(html)
            return response

        # end form validation testing

    except:
        
        logging.warning("E X C E P T")

        return outputPageView(request, model, header)
Example #26
0
def outputPageHTML(header, model, tables_html):
    """Generates HTML to fill '.articles_output' div on output page"""

    # 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 + tables_html
    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': ''})

    return html
Example #27
0
def unterLandingPage(request):
    text_file2 = open(os.path.join(os.environ['PROJECT_PATH'], 'views/main_text.txt'),'r')
    xx = text_file2.read()

    html = render_to_string('01uberheader_main.html', {
            'site_skin' : os.environ['SITE_SKIN']
            })
    html = html + render_to_string('02uberintroblock_nomodellinks.html', {'site_skin' : os.environ['SITE_SKIN']})
    html = html + linksLeft.linksLeft()
    html = html + render_to_string('04ubertext_start_index.html', {
            'text_paragraph':xx
            })
    html = html + render_to_string('04ubertext_end.html',{})
    html = html + render_to_string('05ubertext_links_right.html', {})
    html = html + render_to_string('06uberfooter.html', {'links': ''})

    response = HttpResponse()
    response.write(html)

    return response
Example #28
0
def webiceOutputPage(request):
    html = render_to_string('01uberheader.html', {
            'site_skin' : os.environ['SITE_SKIN'],
            'title': 'Web-ICE Output'})
    html = html + render_to_string('webice-jqueryOutput.html', {})
    html = html + render_to_string('02uberintroblock_wmodellinks.html',  {
            'site_skin' : os.environ['SITE_SKIN'],
            'model':'webice',
            'page':'output'})
    html = html + linksLeft.linksLeft()
    html = html + render_to_string('04uberoutput_start.html', {
            'model':'webice', 
            'model_attributes':'Web-ICE v3.2.1 Output'})
    html = html + render_to_string('webiceOutput.html', {})
    html = html + render_to_string('04uberwebice_end.html', {})
    html = html + render_to_string('06uberfooter.html', {'links': ''})
    
    response = HttpResponse()
    response.write(html)
    return response
Example #29
0
def outputPageView(request, model='none', header=''):

    outputmodule = importlib.import_module('.'+model+'_output', 'cts_app.models.'+model)
    tablesmodule = importlib.import_module('.'+model+'_tables', 'cts_app.models.'+model)

    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('01cts_uberheader.html', {'title': header+' Output'})
    html += render_to_string('02cts_uberintroblock_wmodellinks.html', {'model':model,'page':'output'})
    html += linksLeft.linksLeft()
    html += render_to_string('cts_export.html', {})
    html += render_to_string('04cts_uberoutput_start.html', {
            'model_attributes': header+' Output'})

    html += modelOutputHTML
    # html = html + render_to_string('export.html', {})
    html += render_to_string('04cts_uberoutput_end.html', {'model':model})
    html += render_to_string('06cts_uberfooter.html', {'links': ''})

    response = HttpResponse()
    response.write(html)
    return response
Example #30
0
def descriptionPage(request, model='none', header='none'):
    viewmodule = importlib.import_module('.views', 'cts_app.models.'+model)
    header = viewmodule.header

    text_file2 = open(os.path.join(os.environ['PROJECT_PATH'], 'cts_app/models/'+model+'/'+model+'_text.txt'),'r')
    xx = text_file2.read()
    html = render_to_string('01cts_uberheader.html', {'title': header+' Description'})
    html = html + render_to_string('02cts_uberintroblock_wmodellinks.html', {'model':model,'page':'description'})
    html = html + linksLeft.linksLeft()
    html = html + render_to_string('04cts_ubertext_start.html', {
            'model_attributes': header+' Overview',
            'text_paragraph':xx})

    html = html + render_to_string('04cts_ubertext_nav.html', {'model':model})

    html = html + render_to_string('04cts_ubertext_end.html', {})
    html = html + render_to_string('05cts_ubertext_links_right.html', {})
    html = html + render_to_string('06cts_uberfooter.html', {'links': ''})
    
    response = HttpResponse()
    response.write(html)
    return response
Example #31
0
def inputPage(request, model='none', header='none'):
    viewmodule = importlib.import_module('.views', 'models.' + model)
    inputmodule = importlib.import_module('.' + model + '_input',
                                          'models.' + model)
    header = viewmodule.header

    html = render_to_string('01uberheader.html', {'title': header + ' Inputs'})
    html = html + render_to_string('02uberintroblock_wmodellinks.html', {
        'model': model,
        'page': 'input'
    })
    html = html + linksLeft.linksLeft()

    inputPageFunc = getattr(
        inputmodule, model +
        'InputPage')  # function name = 'model'InputPage  (e.g. 'sipInputPage')
    html = html + inputPageFunc(request, model, header)

    html = html + render_to_string('06uberfooter.html', {'links': ''})

    response = HttpResponse()
    response.write(html)
    return response
Example #32
0
def algorithmPage(request, model='none', header='none'):
    viewmodule = importlib.import_module('.views', 'models.'+model)
    header = viewmodule.header

    text_file1 = open(os.path.join(os.environ['PROJECT_PATH'], 'models/'+model+'/'+model+'_algorithm.txt'),'r')
    x = text_file1.read()
    html = render_to_string('01uberheader.html', {
            'site_skin' : os.environ['SITE_SKIN'],
            'title': header+' Algorithms'})
    html = html + render_to_string('02uberintroblock_wmodellinks.html', {
            'site_skin' : os.environ['SITE_SKIN'],
            'model':model,
            'page':'algorithm'})
    html = html + linksLeft.linksLeft()
    html = html + render_to_string('04uberalgorithm_start.html', {
            'model_attributes': header+' Algorithms', 
            'text_paragraph':x})
    html = html + render_to_string('04ubertext_end.html', {})
    html = html + render_to_string('05ubertext_links_right.html', {})
    html = html + render_to_string('06uberfooter.html', {'links': ''})
    
    response = HttpResponse()
    response.write(html)
    return response
Example #33
0
def algorithmPage(request, model='none', header='none'):
    viewmodule = importlib.import_module('.views', 'models.' + model)
    header = viewmodule.header

    text_file1 = open('models/' + model + '/' + model + '_algorithm.txt', 'r')
    x = text_file1.read()
    html = render_to_string('01uberheader.html',
                            {'title': header + ' Algorithms'})
    html = html + render_to_string('02uberintroblock_wmodellinks.html', {
        'model': model,
        'page': 'algorithm'
    })
    html = html + linksLeft.linksLeft()
    html = html + render_to_string('04uberalgorithm_start.html', {
        'model_attributes': header + ' Algorithms',
        'text_paragraph': x
    })
    html = html + render_to_string('04ubertext_end.html', {})
    html = html + render_to_string('05ubertext_links_right.html', {})
    html = html + render_to_string('06uberfooter.html', {'links': ''})

    response = HttpResponse()
    response.write(html)
    return response
Example #34
0
def historyPage(request, model='none', header='none'):
    """
    Django view render method for model's history page, showing 
    all of the user's previously saved model runs.
    """

    viewmodule = importlib.import_module('.views', 'models.'+model)
    header = viewmodule.header

    html = render_to_string('01uberheader.html', {
            'site_skin' : os.environ['SITE_SKIN'],
            'title': header+' History'})
    html = html + render_to_string('02uberintroblock_wmodellinks.html', {
            'site_skin' : os.environ['SITE_SKIN'],
            'model':model,
            'page':'history'})
    html = html + linksLeft.linksLeft()
    html = html + render_to_string('04uberalgorithm_start.html', {
            'model_attributes': header+' User History'})
    html = html + render_to_string('history_query.html', {'model' : model})

    # """
    # rest_func method call to return user's model runs for the current model
    # rest_funcs.user_hist('user_id', 'model_name')
    #
    # Use this approach if you don't want to use AJAX to query MongoDB
    # """
    # hist_obj = rest_funcs.user_hist('admin', model)
    # html = html + table_all(hist_obj)

    html = html + render_to_string('04ubertext_end.html', {})
    html = html + render_to_string('06uberfooter.html', {'links': ''})

    response = HttpResponse()
    response.write(html)
    return response
Example #35
0
def inputPage(request, model='none', header='none'):
    viewmodule = importlib.import_module('.views', 'models.'+model)
    inputmodule = importlib.import_module('.'+model+'_input', 'models.'+model)
    header = viewmodule.header

    # import logging

    # if formData != None:
    #     logging.info("===================== N O N E ==========================")
    #     html = render_to_string('01uberheader.html', {'title': header+' Inputs'})
    #     html = html + render_to_string('02uberintroblock_wmodellinks.html', {'model':model,'page':'input'})
    #     html = html + linksLeft.linksLeft()

    #     inputPageFunc = getattr(inputmodule, model+'InputPage')  # function name = 'model'InputPage  (e.g. 'sipInputPage')
    #     html = html + inputPageFunc(request, model, header, formData)

    #     html = html + render_to_string('06uberfooter.html', {'links': ''})
        
    #     response = HttpResponse()
    #     response.write(html)
    #     return response

    # VALIDATE FORM HERE IF FORM IS POSTED TO THIS VIEW
    # if request.method == "POST":
    #     parametersmodule = importlib.import_module('.'+model+'_parameters', 'models.'+model)
    #     inputForm = getattr(parametersmodule, model.upper() + 'Inp')
        
    #     logging.info(inputForm)
    #     form = inputForm(request.POST)
        
    #     logging.info(form)
        
    #     if form.is_valid():
    #         outputmodule = importlib.import_module('.'+model+'_output', 'models.'+model)
    #         return outputmodule(request)
    #     else:
    #         html = render_to_string('01uberheader.html', {'title': header+' Inputs'})
    #         html = html + render_to_string('02uberintroblock_wmodellinks.html', {'model':model,'page':'input'})
    #         html = html + linksLeft.linksLeft()

    #         inputPageFunc = getattr(inputmodule, model+'InputPage')  # function name = 'model'InputPage  (e.g. 'sipInputPage')
    #         html = html + inputPageFunc(request, model, header, formData=request.POST)

    #         html = html + render_to_string('06uberfooter.html', {'links': ''})
            
    #         response = HttpResponse()
    #         response.write(html)
    #         return response
    
    # else:
    html = render_to_string('01uberheader.html', {
            'site_skin' : os.environ['SITE_SKIN'],
            'title': header+' Inputs'})
    html = html + render_to_string('02uberintroblock_wmodellinks.html', {
            'site_skin' : os.environ['SITE_SKIN'],
            'model':model,
            'page':'input'})
    html = html + linksLeft.linksLeft()

    inputPageFunc = getattr(inputmodule, model+'InputPage')  # function name = 'model'InputPage  (e.g. 'sipInputPage')
    html = html + inputPageFunc(request, model, header)

    html = html + render_to_string('06uberfooter.html', {'links': ''})
    
    response = HttpResponse()
    response.write(html)
    return response