Esempio n. 1
0
def new_import(request):
    """
    import_scenario_id = None
    Renders Lizard-flooding page for verifying the data of a proposed
    scenario import. The administrator has to verify the results.
    """

    if request.method == 'POST':
        return post_new_import(request.POST, request.user)

    post_url = reverse('flooding_tools_import_new')

    legend_html_json = json.dumps(
        Text.get('importnewscenario', request=request))

    breadcrumbs = [
        {'name': _('Import tool'),
         'url': reverse('flooding_tools_import_overview')},
        {'name': _('New import')}]

    return render_to_response(
        'import/import_scenario.html',
        {'fields': InputField.grouped_input_fields(),
         'post_url': post_url,
         'breadcrumbs': breadcrumbs,
         'legend_html_json': legend_html_json,
         })
    def headers_from_inputfields(self):
        """Get the output of InputField.grouped_input_fields and turn
        it into one iterable of header dictionaries."""

        for group in InputField.grouped_input_fields():
            for inputfield in group['fields']:
                yield {'headername': group['title'], 'inputfield': inputfield}
Esempio n. 3
0
def new_import(request):
    """
    import_scenario_id = None
    Renders Lizard-flooding page for verifying the data of a proposed
    scenario import. The administrator has to verify the results.
    """

    if request.method == 'POST':
        return post_new_import(request.POST, request.user)

    post_url = reverse('flooding_tools_import_new')

    legend_html_json = json.dumps(
        Text.get('importnewscenario', request=request))

    breadcrumbs = [{
        'name': _('Import tool'),
        'url': reverse('flooding_tools_import_overview')
    }, {
        'name': _('New import')
    }]

    return render_to_response(
        'import/import_scenario.html', {
            'fields': InputField.grouped_input_fields(),
            'post_url': post_url,
            'breadcrumbs': breadcrumbs,
            'legend_html_json': legend_html_json,
        })
    def headers_from_inputfields(self):
        """Get the output of InputField.grouped_input_fields and turn
        it into one iterable of header dictionaries."""

        for group in InputField.grouped_input_fields():
            for inputfield in group['fields']:
                yield {
                    'headername': group['title'],
                    'inputfield': inputfield
                    }
Esempio n. 5
0
def infowindow_information(scenario):
    """
    - Get the list of headers and fields that the importtool has
    - If the importtool field says that the data is stored in a
      ExtraInfoField, use that to show the data
    - Otherwise, if it's a known field on a known object, getattr it
      from that
    - Only keep fields with a value, only keep headers with fields

    We need to add some fields that the importtool doesn't have;
    scenario.id and attachments come to mind. So we're going to
    manually add some fields to the start and end.

    Some hacks needed:
    - Don't show things from Results
    - Show the old Attachments list instead (more complete)
    - Split Breach's geom field into x and y based on the field name
    - Add in the waterlevel picture that the old version could show
    """

    grouped_input_fields = InputField.grouped_input_fields()

    for header in grouped_input_fields:
        for inputfield in header['fields']:
            value = scenario.value_for_inputfield(inputfield)
            value_str = inputfield.display_unicode(
                value, for_viewing_only=True)

            # Set the value_str on the inputfield object for easy
            # use in the template.
            inputfield.value_str = value_str

        # Only keep fields with a value
        header['fields'] = [f for f in header['fields'] if f.value_str]

    # Hack in some extra fields that aren't in the importtool but
    # belong to "the old way of doing things"
    for header in grouped_input_fields:
        extra_fields = extra_infowindow_information_fields(
            header['title'], scenario)
        # Scenario fields (well, the scenario id) are added at the
        # front, others at the end...
        if header['title'] in ('Scenario', ugettext('Scenario')):
            header['fields'][0:0] = extra_fields
        else:
            header['fields'] += extra_fields

    # Only keep headers with fields
    grouped_input_fields = [h for h in grouped_input_fields if h['fields']]

    return render_to_response(
        'flooding/infowindow_information.html',
        {'grouped_fields': grouped_input_fields,
         'attachment_list': scenario.get_attachment_list(),
         'scenario_id': scenario.id})