<commit_before>__author__ = '<NAME>'
from mezzanine.pages.page_processors import processor_for
from hs_swat_modelinstance.models import SWATModelInstanceResource
from crispy_forms.layout import Layout, Fieldset, ButtonHolder, Submit, HTML
from hs_modelinstance.forms import *
from forms import *
from hs_core import page_processors
from hs_core.views import *

@processor_for(SWATModelInstanceResource)
def landing_page(request, page):
    content_model = page.get_content_model()
    edit_resource = page_processors.check_resource_mode(request)

    if not edit_resource:
        # get the context from hs_core
        context = page_processors.get_page_context(page, request.user, resource_edit=edit_resource, extended_metadata_layout=None)
        extended_metadata_exists = False
        if content_model.metadata.model_output or \
                content_model.metadata.executed_by or \
                content_model.metadata.model_objective or \
                content_model.metadata.swat_model_parameters:
            extended_metadata_exists = True

        context['extended_metadata_exists'] = extended_metadata_exists
        context['model_output'] = content_model.metadata.model_output
        context['executed_by'] = content_model.metadata.executed_by
        context['model_objective'] = content_model.metadata.model_objective
        context['swat_model_parameters'] = content_model.metadata.swat_model_parameters

        #add SWAT Model parameters context
    else:
        model_output_form = ModelOutputForm(instance=content_model.metadata.model_output, res_short_id=content_model.short_id,
                             element_id=content_model.metadata.model_output.id if content_model.metadata.model_output else None)

        executed_by_form = ExecutedByForm(instance=content_model.metadata.executed_by, res_short_id=content_model.short_id,
                             element_id=content_model.metadata.executed_by.id if content_model.metadata.executed_by else None)

        model_objective_form = modelObjectiveForm(instance=content_model.metadata.model_objective, res_short_id=content_model.short_id,
                             element_id=content_model.metadata.model_objective.id if content_model.metadata.model_objective else None)

        swat_model_parameters_form = SWATmodelParametersForm(instance=content_model.metadata.swat_model_parameters, res_short_id=content_model.short_id,
                             element_id=content_model.metadata.swat_model_parameters.id if content_model.metadata.swat_model_parameters else None)

        ext_md_layout = Layout(
                                AccordionGroup('Model Output (required)',
                                    HTML("<div class='form-group' id='modeloutput'> "
                                        '{% load crispy_forms_tags %} '
                                        '{% crispy model_output_form %} '
                                     '</div>'),
                                ),<commit_msg>[#303] modify the resource html file and did some cleanup for the file before continue implementations<commit_after>__author__ = '<NAME>'
from mezzanine.pages.page_processors import processor_for
from hs_swat_modelinstance.models import SWATModelInstanceResource
from crispy_forms.layout import Layout, Fieldset, ButtonHolder, Submit, HTML
from hs_modelinstance.forms import *
from forms import *
from hs_core import page_processors
from hs_core.views import *

@processor_for(SWATModelInstanceResource)
def landing_page(request, page):
    content_model = page.get_content_model()
    edit_resource = page_processors.check_resource_mode(request)

    if not edit_resource:
        # get the context from hs_core
        context = page_processors.get_page_context(page, request.user, resource_edit=edit_resource, extended_metadata_layout=None)
        extended_metadata_exists = False
        if content_model.metadata.model_output or \
                content_model.metadata.executed_by or \
                content_model.metadata.model_objective or \
                content_model.metadata.swat_model_parameters:
            extended_metadata_exists = True

        context['extended_metadata_exists'] = extended_metadata_exists
        context['model_output'] = content_model.metadata.model_output
        context['executed_by'] = content_model.metadata.executed_by
        context['model_objective'] = content_model.metadata.model_objective
        context['swat_model_parameters'] = content_model.metadata.swat_model_parameters

        #add SWAT Model parameters context
    else:
        model_output_form = ModelOutputForm(instance=content_model.metadata.model_output, res_short_id=content_model.short_id,
                             element_id=content_model.metadata.model_output.id if content_model.metadata.model_output else None)

        executed_by_form = ExecutedByForm(instance=content_model.metadata.executed_by, res_short_id=content_model.short_id,
                             element_id=content_model.metadata.executed_by.id if content_model.metadata.executed_by else None)

        model_objective_form = modelObjectiveForm(instance=content_model.metadata.model_objective, res_short_id=content_model.short_id,
                             element_id=content_model.metadata.model_objective.id if content_model.metadata.model_objective else None)
        swat_model_parameters_form = SWATmodelParametersForm(instance=content_model.metadata.swat_model_parameters, res_short_id=content_model.short_id,
                             element_id=content_model.metadata.swat_model_parameters.id if content_model.metadata.swat_model_parameters else None)

        ext_md_layout = Layout(
                                AccordionGroup('Model Output (required)',
                                    HTML("<div class='form-group' id='modeloutput'> "
                                        '{% load crispy_forms_tags %} '
                                        '{% crispy model_output_form %} '
                                     '</div>'),
                                ),
{'fraction_non_alphanumeric': 0.06685282522996058, 'fraction_numerical': 0.0004927726675427069, 'mean_word_length': 2.9927868852459016, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4541484', 'n_tokens_mistral': 1617, 'n_tokens_neox': 1571, 'n_words': 265}