mysociety/alaveteli

View on GitHub
app/views/followups/_followup.html.erb

Summary

Maintainability
Test Coverage
<div id="followup" class="followup">
  <% if (incoming_message.nil? || !incoming_message.valid_to_reply_to?)
    # TRANSLATORS: This phrase completes the following sentences:
    # Request an internal review from...
    # Send a public follow up message to...
    # Send a public reply to...
    # Don't want to address your message to... ?
    name_for_followup =
      _("the main FOI contact at {{public_body}}",
        public_body: h(OutgoingMailer.name_for_followup(@info_request, nil))) %>
  <% else %>
    <% name_for_followup =
         h(OutgoingMailer.name_for_followup(@info_request, incoming_message)) %>
  <% end %>

  <% if @info_request.allow_new_responses_from != 'nobody' %>
    <% if @info_request.embargo %>
      <%= render partial: 'alaveteli_pro/followups/embargoed_form_title',
                 locals: { incoming_message: incoming_message,
                           name_for_followup: name_for_followup } %>
    <% else %>
      <%= render partial: 'form_title',
                 locals: { incoming_message: incoming_message,
                           name_for_followup: name_for_followup } %>
    <% end %>

    <% if incoming_message &&
          @info_request.who_can_followup_to(incoming_message).any? %>
      <%= render partial: 'choose_recipient',
                 locals: { incoming_message: incoming_message,
                           name_for_followup: name_for_followup } %>
    <% end %>

  <% end %>

  <% if @info_request.allow_new_responses_from == 'nobody' %>
    <p>
      <%= # TRANSLATORS: "Follow ups" in this context means further
          # messages sent by the requester to the authority after
          # the initial request
          _('Follow ups and new responses to this request have been stopped ' \
            'to prevent spam. Please <a href="{{url}}">contact us</a> if you ' \
            'are {{user_link}} and need to send a follow up.',
            user_link: user_link(@info_request.user),
            url: help_contact_path) %>
    </p>
  <% else %>
    <% if @internal_review %>
      <p>
        <%= _('If you are dissatisfied by the response you got from the ' \
              'public authority, you have the right to complain ' \
              '(<a href="{{url}}">details</a>).',
              url: help_unhappy_path(
                     anchor: 'internal_review',
                     url_title: @info_request.url_title)) %>
      </p>
    <% end %>

    <p>
    <%= _('Please <strong>only</strong> write messages directly relating ' \
          'to your request {{request_link}}. If you would like to ask for ' \
          'information that was not in your original request, then <a ' \
          'href="{{new_request_link}}">file a new request</a>.',
          request_link: request_link(@info_request),
          new_request_link: new_request_to_body_url(
                              url_name: @info_request.public_body.url_name)) %>
    </p>

    <% status = @info_request.calculate_status %>
    <% if status == 'waiting_response_overdue' %>
      <p>
        <% if @info_request.public_body.not_subject_to_law? %>
          <%= _('The response to your request has been <strong>delayed' \
                '</strong>. Although the authority has no legal obligation ' \
                'to reply, they should normally have responded by ' \
                '<strong>{{date}}</strong>',
                date: simple_date(@info_request.date_response_required_by)) %>
        <% else %>
          <%= _('The response to your request has been <strong>delayed' \
                '</strong>. You can say that, by law, the authority should ' \
                'normally have responded <strong>promptly</strong> and by ' \
                '<strong>{{date}}</strong>',
                date: simple_date(@info_request.date_response_required_by)) %>
        <% end %>

        (<%= details_help_link(@info_request.public_body) %>).
      </p>
    <% elsif status == 'waiting_response_very_overdue' %>
      <p>
        <% if @info_request.public_body.not_subject_to_law? %>
          <%= _('The response to your request is <strong>long overdue' \
                '</strong>. Although the authority has no legal obligation ' \
                'to reply, they should have responded by now') %>
        <% else %>
          <%= _('The response to your request is <strong>long overdue' \
                '</strong>. You can say that, by law, under all ' \
                'circumstances, the authority should have responded by now') %>
        <% end %>

        (<%= details_help_link(@info_request.public_body) %>).
      </p>
    <% end %>

    <% if feature_enabled?(:refusal_snippets) %>
      <% if @info_request.reason_to_be_unhappy? %>
        <%= render partial: 'snippets' %>
      <% end %>
    <% end %>

    <% if @info_request.from_name != @info_request.user_name %>
      <div class="warning">
        <%= _('Your name has been changed since your last message in this ' \
              'request. Please consider mentioning this to the authority ' \
              'and explain that you are the original requester.') %>
      </div>
    <% end %>

    <% form_url =
         if incoming_message.nil?
           preview_request_followups_url(
             request_url_title: @info_request.url_title
           )
         else
           preview_request_followups_url(
             request_url_title: @info_request.url_title,
             incoming_message_id: incoming_message.id
           )
         end -%>
    <%= form_for @outgoing_message,
                 html: { id: 'followup_form' },
                 url: form_url do |o| %>
      <p>
        <%= o.text_area :body, rows: 15, cols: 55 %>
      </p>

      <% if @internal_review %>
        <%= hidden_field_tag 'outgoing_message[what_doing]',
                             'internal_review' %>
      <% else %>
        <h3><%= _('What are you doing?') %></h3>

        <% if !@outgoing_message.errors[:what_doing_dummy].nil? %>
          <div class="fieldWithErrors">
        <% else %>
          <div>
        <% end %>
          <!--
            <div>
            <%= radio_button 'outgoing_message',
                             'what_doing',
                             'new_information',
                             id: 'new_information' %>
            <label for="new_information">
              <%= _('I am asking for <strong>new information</strong>') %>
            </label>
            </div>
          -->
          <div>
            <%= radio_button 'outgoing_message',
                             'what_doing',
                             'internal_review',
                             id: 'internal_review' %>
            <label for="internal_review">
              <%= _('I am requesting an <strong>internal review</strong>') %>
              <%= link_to _("what's that?"), '/help/unhappy' %>
            </label>
          </div>

          <div>
            <%= radio_button 'outgoing_message',
                             'what_doing',
                             'normal_sort',
                             id: 'sort_normal' %>
            <label for="sort_normal">
              <%= _('<strong>Anything else</strong>, such as clarifying, ' \
                    'prompting, thanking') %>
            </label>
          </div>
        </div>
      <% end %>

      <% if @internal_review %>
        <p>
          <%= _('Edit and add <strong>more details</strong> to the message ' \
                'above, explaining why you are dissatisfied with their ' \
                'response.') %>
        </p>
      <% end %>

      <p>
        <%= hidden_field_tag 'submitted_followup', 1 %>
        <% if @internal_review %>
          <%= hidden_field_tag(:internal_review, 1 ) %>
        <% end %>
        <%= submit_tag _('Preview your message') %>
      </p>
    <% end %>

    <p>
      <% if not @is_owning_user %>
        <%= _('(You will be asked to sign in as {{user_name}})',
              user_name: user_link(@info_request.user)) %>
      <% end %>
    </p>
  <% end %>
</div>