Adding trace link to logged in user's profile too.

<%= @this_user.display_name %>

<%= simple_format(@this_user.description) %>

<% if @user and @this_user.id == @user.id %>

Your diary

<%= link_to 'View your diary', :controller => 'user', :action=>'diary', :display_name => @user.display_name %>

<%= link_to 'New diary post', :controller => 'diary_entry', :action=>'new', :display_name => @user.display_name %>

Your traces

<%= link_to 'View your traces', :controller => 'trace', :action=>'mine' %>

Your account

<%= link_to 'Edit your settings', :controller => 'user', :action => 'account', :display_name => @user.display_name %>

<% else %>
<%= link_to 'Send message', :controller => 'message', :action => 'new', :user_id => @this_user.id %>

<%= link_to 'Add as friend', :controller => 'user', :action => 'make_friend', :display_name => @this_user.display_name %>

<%= link_to 'View diary', :controller => 'user', :action=>'diary', :display_name => @this_user.display_name %>

<%= link_to 'View traces', :controller => 'trace', :action=>'view', :display_name => @this_user.display_name %>

<% end %>

Nearby users

<% if @this_user.home_lat and @this_user.home_lon %>
  <% if @this_user.nearby.empty? %>
    There are no users who admit to mapping nearby.
  <% else %>

    <% @this_user.nearby.each do |nearby| %>

    <%= link_to nearby.display_name, :controller => 'user', :action => 'view',  :display_name => nearby.display_name %>
    <%= @this_user.distance(nearby).round %>km away
    (<%= link_to 'send message', :controller => 'message', :action => 'new', :user_id => nearby.id %>)

    <%end%>

  <%end%>
<% else %>
  No home location has been set.
  <% if @user and @this_user.id == @user.id %>
  You can set your home location on your <%= link_to 'settings', :controller => 'user', :action => 'account', :display_name => @user.display_name %> page.
  <% end %>
<% end %>

<%= @this_user.display_name %>

<%= simple_format(@this_user.description) %>

<% if @user and @this_user.id == @user.id %>

Your diary

<%= link_to 'View your diary', :controller => 'user', :action=>'diary', :display_name => @user.display_name %>

<%= link_to 'New diary post', :controller => 'diary_entry', :action=>'new', :display_name => @user.display_name %>

Your account

<%= link_to 'Edit your settings', :controller => 'user', :action => 'account', :display_name => @user.display_name %>

<% else %>
<%= link_to 'Send message', :controller => 'message', :action => 'new', :user_id => @this_user.id %>

<%= link_to 'Add as friend', :controller => 'user', :action => 'make_friend', :display_name => @this_user.display_name %>

<%= link_to 'View diary', :controller => 'user', :action=>'diary', :display_name => @this_user.display_name %>

<%= link_to 'View traces', :controller => 'trace', :action=>'view', :display_name => @this_user.display_name %>

<% end %>

Nearby users

<% if @this_user.home_lat and @this_user.home_lon %>
  <% if @this_user.nearby.empty? %>
    There are no users who admit to mapping nearby.
  <% else %>

    <% @this_user.nearby.each do |nearby| %>

    <%= link_to nearby.display_name, :controller => 'user', :action => 'view',  :display_name => nearby.display_name %>
    <%= @this_user.distance(nearby).round %>km away
    (<%= link_to 'send message', :controller => 'message', :action => 'new', :user_id => nearby.id %>)

    <%end%>

  <%end%>
<% else %>
  No home location has been set.
  <% if @user and @this_user.id == @user.id %>
  You can set your home location on your <%= link_to 'settings', :controller => 'user', :action => 'account', :display_name => @user.display_name %> page.
  <% end %>
<% end %>


Close tag properly.

Close tag properly.

<% @this_user = User.find_by_display_name(@this_user.display_name) %>

<%= @this_user.display_name %>

<% if @user and @this_user.id == @user.id %>
<%= link_to 'my diary', :controller => 'diary_entry', :action => 'list', :display_name => @user.display_name %>
| <%= link_to 'new diary post', :controller => 'diary_entry', :action => 'new', :display_name => @user.display_name %>
| <%= link_to 'my traces', :controller => 'trace', :action=>'mine' %>
| <%= link_to 'my settings', :controller => 'user', :action => 'account', :display_name => @user.display_name %>
<% else %>
<%= link_to 'send message', :controller => 'message', :action => 'new', :user_id => @this_user.id %>
| <%= link_to 'diary', :controller => 'diary_entry', :action => 'list', :display_name => @this_user.display_name %>
| <%= link_to 'traces', :controller => 'trace', :action => 'view', :display_name => @this_user.display_name %>
| <% if @user and @user.is_friends_with?(@this_user) %>
  <%= link_to 'remove as friend', :controller => 'user', :action => 'remove_friend', :display_name => @this_user.display_name %>
<% else %>
  <%= link_to 'add as friend', :controller => 'user', :action => 'make_friend', :display_name => @this_user.display_name %>
<% end %>
<% end %>

User image

<% if @this_user.image %>
 <%= image_tag url_for_file_column(@this_user, "image") %>
<% end %>

<% if @user and @this_user.id == @user.id %>
  Upload an image

  <%= form_tag({:action=>'upload_image'}, :multipart => true)%>
    <%= file_column_field 'user', 'image' %>
    <input type="submit" name="Upload" />
  </form>
<% end %>

Description

<%= simple_format(@this_user.description) %>

<% if @this_user.home_lat.nil? or @this_user.home_lon.nil? %>

User location

  No home location has been set.
  <% if @user and @this_user.id == @user.id %>
  If you set your location, a pretty map and stuff will appear below. You can set your home location on your <%= link_to 'settings', :controller => 'user', :action => 'account', :display_name => @user.display_name %> page.
  <% end %>
<% else %>

  <% if @user and @this_user.id == @user.id %>

Your friends

    <% if @this_user.friends.empty? %>
      You have not added any friends yet.
    <% else %>

      <% @this_user.friends.each do |friend| %>
      <% @friend = User.find_by_id(friend.friend_user_id) %>

      <% if @friend.image %>
        <%= image_tag url_for_file_column(@friend, "image") %>
      <% end %>

      <%= link_to @friend.display_name, :controller => 'user', :action => 'view',  :display_name => @friend.display_name %>
      <% if @friend.home_lon and @friend.home_lat %><%= @this_user.distance(@friend).round %>km away<% end %>
      (<%= link_to 'send message', :controller => 'message', :action => 'new', :user_id => @friend.id %>)

      <%end%>

    <%end%>

  <%end%>

  <% if @user and @this_user.id == @user.id %>

Nearby users:

    <% if @this_user.nearby.empty? %>
      There are no users who admit to mapping nearby yet.
    <% else %>

    <%= render :partial => 'friend_map' %>

      <% @this_user.nearby.each do |nearby| %>

      <%= link_to nearby.display_name, :controller => 'user', :action => 'view',  :display_name => nearby.display_name %>
      <%= @this_user.distance(nearby).round %>km away
      (<%= link_to 'send message', :controller => 'message', :action => 'new', :user_id => nearby.id %>)

      <% end %>

    <% end %>
  <% end %>
<% end %>

<% @this_user = User.find_by_display_name(@this_user.display_name) %>

<%= @this_user.display_name %>

<% if @user and @this_user.id == @user.id %>
<%= link_to 'my diary', :controller => 'diary_entry', :action => 'list', :display_name => @user.display_name %>
| <%= link_to 'new diary post', :controller => 'diary_entry', :action => 'new', :display_name => @user.display_name %>
| <%= link_to 'my traces', :controller => 'trace', :action=>'mine' %>
| <%= link_to 'my settings', :controller => 'user', :action => 'account', :display_name => @user.display_name %>
<% else %>
<%= link_to 'send message', :controller => 'message', :action => 'new', :user_id => @this_user.id %>
| <%= link_to 'diary', :controller => 'diary_entry', :action => 'list', :display_name => @this_user.display_name %>
| <%= link_to 'traces', :controller => 'trace', :action => 'view', :display_name => @this_user.display_name %>
| <% if @user and @user.is_friends_with?(@this_user) %>
  <%= link_to 'remove as friend', :controller => 'user', :action => 'remove_friend', :display_name => @this_user.display_name %>
<% else %>
  <%= link_to 'add as friend', :controller => 'user', :action => 'make_friend', :display_name => @this_user.display_name %>
<% end %>
<% end %>

User image

<% if @this_user.image %>
 <%= image_tag url_for_file_column(@this_user, "image") %>
<% end %>

<% if @user and @this_user.id == @user.id %>
  Upload an image

  <%= form_tag({:action=>'upload_image'}, :multipart => true)%>
    <%= file_column_field 'user', 'image' %>
    <input type="submit" name="Upload" />
  </form>
<% end %>

Description</h3?

<%= simple_format(@this_user.description) %>

<% if @this_user.home_lat.nil? or @this_user.home_lon.nil? %>

User location

  No home location has been set.
  <% if @user and @this_user.id == @user.id %>
  If you set your location, a pretty map and stuff will appear below. You can set your home location on your <%= link_to 'settings', :controller => 'user', :action => 'account', :display_name => @user.display_name %> page.
  <% end %>
<% else %>

  <% if @user and @this_user.id == @user.id %>

Your friends

    <% if @this_user.friends.empty? %>
      You have not added any friends yet.
    <% else %>

      <% @this_user.friends.each do |friend| %>
      <% @friend = User.find_by_id(friend.friend_user_id) %>

      <% if @friend.image %>
        <%= image_tag url_for_file_column(@friend, "image") %>
      <% end %>

      <%= link_to @friend.display_name, :controller => 'user', :action => 'view',  :display_name => @friend.display_name %>
      <% if @friend.home_lon and @friend.home_lat %><%= @this_user.distance(@friend).round %>km away<% end %>
      (<%= link_to 'send message', :controller => 'message', :action => 'new', :user_id => @friend.id %>)

      <%end%>

    <%end%>

  <%end%>

  <% if @user and @this_user.id == @user.id %>

Nearby users:

    <% if @this_user.nearby.empty? %>
      There are no users who admit to mapping nearby yet.
    <% else %>

    <%= render :partial => 'friend_map' %>

      <% @this_user.nearby.each do |nearby| %>

      <%= link_to nearby.display_name, :controller => 'user', :action => 'view',  :display_name => nearby.display_name %>
      <%= @this_user.distance(nearby).round %>km away
      (<%= link_to 'send message', :controller => 'message', :action => 'new', :user_id => nearby.id %>)

      <% end %>

    <% end %>
  <% end %>
<% end %>


Don't show email to be sent to requester when external request hidden via admin - no email will be sent.

<% @title = _("FOI request – {{title}}", :title => h(@info_request.title)) %>

<%=@title%>

<% form_tag '../move_request', { :class => "form form-horizontal" } do %>
  <%= hidden_field_tag 'info_request_id', @info_request.id %>

        <a href="#metadata_<%=@info_request.id%>" data-toggle="collapse" data-parent="#info_request">Request metadata

    <div id="metadata_<%=@info_request.id%>" class="accordion-body collapse in">

          <%= link_to 'Edit metadata', '../edit/' + @info_request.id.to_s, :class => "btn" %>

        Public page:
        <%= link_to main_url(request_url(@info_request)), main_url(request_url(@info_request)) %>

          <% @info_request.for_admin_column do |name, value, type, column_name|%>

                <%= name %>:

                <% if type == 'datetime' %>
                  <%= I18n.l(value, :format => "%e %B %Y %H:%M:%S") %>
                  (<%= _('{{length_of_time}} ago', :length_of_time => time_ago_in_words(value)) %>)
                <% else %>
                  <%= h value %>
                <% end %>
                <% if column_name == 'described_state' %>

Initial request last sent at: <%= @info_request.calculate_status %>

Initial request last sent at: <%=@info_request.date_initial_request_last_sent_at.to_date %>

Date response required by: <%= @info_request.date_response_required_by %>

Very overdue after: <%= @info_request.date_very_overdue_after %>

                <% end %>

          <% end %>

              Created by

          <% if @info_request.is_external? %>
                <%= link_to("".html_safe, @info_request.external_url, :title => "view URL of original request on external website") %>
                <%= @info_request.public_body.name %> on behalf of <%= @info_request.user_name %> (using API)
          <% else %>
                <%= link_to("".html_safe, user_url(@info_request.user), :title => "view user's page on public website") %>
                <%= link_to(@info_request.user.name, user_admin_url(@info_request.user)) %>
                <%= link_to _("move..."), "#", :class => "btn btn-mini btn-warning toggle-hidden" %>

                  url_name of new user:
                  <%= text_field_tag 'user_url_name', "", { :size => 20 } %>
                  <%= submit_tag "Move request to user", :class => "btn btn-info" %>

          <% end %>

              Public authority:

              <%= link_to("".html_safe, main_url(public_body_url(@info_request.public_body)), :title => "view authority on public website") %>
              <%= link_to(@info_request.public_body.name, public_body_admin_url(@info_request.public_body)) %>
              <%= link_to "move...", "#", :class => "btn btn-mini btn-warning toggle-hidden" %>

                url_name of new authority:
                <%= text_field_tag 'public_body_url_name', "", { :size => 20 } %>
                <%= submit_tag "Move request to authority", :class => "btn btn-info" %>

              <%=_("Incoming email address")%>

              <%= link_to h(@info_request.incoming_email), "mailto:#{@info_request.incoming_email}" %>

              <%=_("Tags")%>

              <%= render :partial => 'tags', :locals => { :info_request => @info_request} %>

          <%= link_to 'Edit metadata', '../edit/' + @info_request.id.to_s, :class => "btn" %>

<% end %>
<formset class="form-horizontal">
  <legend>Actions</legend>

      FOI officer upload URL

      <%= link_to 'Generate URL', '../generate_upload_url/' + @info_request.id.to_s, :class => "btn" %>

(see also option to general URLs for individual incoming messages below)

  <% form_tag '../hide/' + @info_request.id.to_s, :class => "form form-inline", :info_request_id => @info_request.id.to_s, :id => "hide_request_form" do %>

        <% if  @info_request.is_external? %>
          Hide the request:
        <% else %>
          Hide the request and notify the user:
        <% end %>

        <% if ['hidden', 'requester_only'].include? @info_request.prominence %>

This request has already been hidden

        <% else %>

            <%= radio_button_tag "reason", "not_foi" %> <%= _("Not a valid FOI request") %>

            <%= radio_button_tag "reason", "vexatious" %> <%= _("A vexatious request") %>

        <% end %>

    <% if !['hidden', 'requester_only'].include? @info_request.prominence %>
        <% if ! @info_request.is_external? %>

            Subject of email:

              <%= text_field_tag "subject", "Your request on WhatDoTheyKnow.com hidden", {:id => "request_hidden_user_subject_field", :cols => 100} %>

            Reason for hiding the request (will be emailed to user):

              <%= text_area_tag "explanation", h(@request_hidden_user_explanation), {:id => "request_hidden_user_explanation_field"} %>

         <% end %>

        <%= submit_tag _("Hide request"), :class => "btn" %>

    <% end %>
  <% end %>
</formset>

Events

  <% for info_request_event in @info_request.info_request_events.find(:all, :order => "created_at, id") %>

        <a href="#event_<%=info_request_event.id%>" data-toggle="collapse" data-parent="#events">
          <%= _("Event {{id}}", :id => info_request_event.id) %>:

            <%=h info_request_event.event_type.humanize %><% if !info_request_event.calculated_state.nil? %>; state: <%= info_request_event.calculated_state %><% end %>

            <%= info_request_event.created_at%>

      <div id="event_<%=info_request_event.id%>" class="accordion-body collapse">

                <% if info_request_event.described_state != 'waiting_clarification' and info_request_event.event_type == 'response' %>
                  <% form_tag '../mark_event_as_clarification', :class => "form form-inline admin-table-form admin-inline-form" do %>
                    <%= hidden_field_tag 'info_request_event_id', info_request_event.id %>
                    <%= submit_tag "Was clarification request", :class => "btn btn-mini btn-primary" %>
                  <% end %>
                <% end %>

            <% info_request_event.for_admin_column do |name, value, type, column_name| %>

                  <%=h name%>

                  <% if column_name == 'params_yaml' %>
                    <%= info_request_event.params_yaml_as_html %>
                  <% elsif value.nil? %>
                    nil
                  <% elsif %w(text string).include?(type) %>
                    <%=h value.humanize %>
                  <% elsif type == 'datetime' %>
                    <%= admin_date value %>
                  <% else %>
                    <%=h value %>
                  <% end %>

            <% end %>

  <% end %>

Outgoing messages

  <% for outgoing_message in @info_request.outgoing_messages.find(:all, :order => 'created_at') %>

        <a href="#outgoing_<%=outgoing_message.id%>" data-toggle="collapse" data-parent="#outgoing_messages">
        <a href="../edit_outgoing/<%= outgoing_message.id %>">
          #<%= outgoing_message.id %> -- <%= outgoing_message.status.humanize %> <%= outgoing_message.message_type.humanize %>

          <%= truncate(outgoing_message.body, :length => 400) %>

      <div id="outgoing_<%=outgoing_message.id%>" class="accordion-body collapse">

                <% form_tag '../resend', :class => "admin-table-form" do %>
                  <%= hidden_field_tag 'outgoing_message_id', outgoing_message.id %>
                  <%= submit_tag "Resend", :class => "btn" %>
                <% end %>

            <% outgoing_message.for_admin_column do |name, value, type, column_name| %>

                  <%=name%>

                  <% if column_name == 'body' %>
                    <%= simple_format(truncate(outgoing_message.body, :length => 400, :omission => link_to("...", "#", :class => "toggle-hidden" ))) %>

<%= simple_format( outgoing_message.body ) %>

                  <% else %>
                    <%= admin_value(value) %>
                  <% end %>

            <% end %>

  <% end %>

Incoming messages

  <% for incoming_message in @info_request.incoming_messages.find(:all, :order => 'created_at') %>

        <a href="#incoming_<%=incoming_message.id%>" data-toggle="collapse" data-parent="#incoming_messages">
        <%=incoming_message.id%> -- <%= h(incoming_message.mail_from) %> <%=_("at")%> <%=admin_value(incoming_message.sent_at)%>

          <% if !incoming_message.cached_main_body_text_folded.nil? %>
            <%= truncate(incoming_message.cached_main_body_text_folded.gsub('FOLDED_QUOTED_SECTION', ''), :length => 400) %>
          <% end %>

      <div id="incoming_<%=incoming_message.id%>" class="accordion-body collapse">

                <%= render :partial => 'incoming_message_actions', :locals => { :incoming_message => incoming_message } %>

            <% incoming_message.for_admin_column do |name, value, type, column_name| %>

                  <%=name%>

                  <% if column_name =~ /^cached_.*?$/ %>
                    <%= simple_format( truncate(value, :length => 400, :omission => link_to("...", "#", :class => "toggle-hidden"))) %>

<%= simple_format(value) %>

                  <% else %>
                    <%= simple_format(value) %>
                  <% end %>

            <% end %>

  <% end %>

Annotations

<% if @info_request.comments.size > 0 %>

    <% for comment in @info_request.comments %>

         <a href="#comment_<%=comment.id%>" data-toggle="collapse" data-parent="#comments">
          <a href="../edit_comment/<%= comment.id %>">
            #<%=comment.id%>
            --
            <%=h(comment.user.name)%>
            <%=admin_value(comment.created_at)%>

            <%= truncate(comment.body, :length => 400) %>

        <div id="comment_<%=comment.id%>" class="accordion-body collapse">

                 By <%= link_to("".html_safe, user_url(comment.user), :title => "view user's page on public website") %>

                  <%= link_to(h(comment.user.name), user_admin_url(comment.user)) %>

              <% comment.for_admin_column do |name, value, type, column_name |%>

                    <%=name%>

                    <% if column_name == 'body' && !comment.visible %>
                      <s><%=h comment.send(column_name) %></s>
                    <% else %>
                      <%=h comment.send(column_name) %>
                    <% end %>

              <% end %>

    <% end %>

<% else %>

None yet.

<% end %>

Exim delivery logs

(Lines containing the request incoming email address, updated hourly.)

<% for exim_log_done_id, exim_logs in @info_request.exim_logs.group_by(&:exim_log_done_id) %>

<% for exim_log in exim_logs %><%=h exim_log.line%><% end %>

<% end %>
<% if @info_request.exim_logs.size == 0 %>

None (perhaps this is an old or a very new request)

<% end %>

Censor rules

<%= render :partial => 'admin_censor_rule/show', :locals => { :censor_rules => @info_request.censor_rules, :info_request => @info_request } %>

<% @title = _("FOI request – {{title}}", :title => h(@info_request.title)) %>

<%=@title%>

<% form_tag '../move_request', { :class => "form form-horizontal" } do %>
  <%= hidden_field_tag 'info_request_id', @info_request.id %>

        <a href="#metadata_<%=@info_request.id%>" data-toggle="collapse" data-parent="#info_request">Request metadata

    <div id="metadata_<%=@info_request.id%>" class="accordion-body collapse in">

	      <%= link_to 'Edit metadata', '../edit/' + @info_request.id.to_s, :class => "btn" %>

	    Public page:
	    <%= link_to main_url(request_url(@info_request)), main_url(request_url(@info_request)) %>

          <% @info_request.for_admin_column do |name, value, type, column_name|%>

                <%= name %>:

                <% if type == 'datetime' %>
                  <%= I18n.l(value, :format => "%e %B %Y %H:%M:%S") %>
                  (<%= _('{{length_of_time}} ago', :length_of_time => time_ago_in_words(value)) %>)
                <% else %>
                  <%= h value %>
                <% end %>
                <% if column_name == 'described_state' %>

Initial request last sent at: <%= @info_request.calculate_status %>

Initial request last sent at: <%=@info_request.date_initial_request_last_sent_at.to_date %>

Date response required by: <%= @info_request.date_response_required_by %>

Very overdue after: <%= @info_request.date_very_overdue_after %>

                <% end %>

          <% end %>

              Created by

	      <% if @info_request.is_external? %>
                <%= link_to("".html_safe, @info_request.external_url, :title => "view URL of original request on external website") %>
                <%= @info_request.public_body.name %> on behalf of <%= @info_request.user_name %> (using API)
	      <% else %>
                <%= link_to("".html_safe, user_url(@info_request.user), :title => "view user's page on public website") %>
                <%= link_to(@info_request.user.name, user_admin_url(@info_request.user)) %>
                <%= link_to _("move..."), "#", :class => "btn btn-mini btn-warning toggle-hidden" %>

                  url_name of new user:
                  <%= text_field_tag 'user_url_name', "", { :size => 20 } %>
                  <%= submit_tag "Move request to user", :class => "btn btn-info" %>

	      <% end %>

              Public authority:

              <%= link_to("".html_safe, main_url(public_body_url(@info_request.public_body)), :title => "view authority on public website") %>
              <%= link_to(@info_request.public_body.name, public_body_admin_url(@info_request.public_body)) %>
              <%= link_to "move...", "#", :class => "btn btn-mini btn-warning toggle-hidden" %>

                url_name of new authority:
                <%= text_field_tag 'public_body_url_name', "", { :size => 20 } %>
                <%= submit_tag "Move request to authority", :class => "btn btn-info" %>

              <%=_("Incoming email address")%>

              <%= link_to h(@info_request.incoming_email), "mailto:#{@info_request.incoming_email}" %>

              <%=_("Tags")%>

              <%= render :partial => 'tags', :locals => { :info_request => @info_request} %>

	      <%= link_to 'Edit metadata', '../edit/' + @info_request.id.to_s, :class => "btn" %>

<% end %>
<formset class="form-horizontal">
  <legend>Actions</legend>

      FOI officer upload URL

      <%= link_to 'Generate URL', '../generate_upload_url/' + @info_request.id.to_s, :class => "btn" %>

(see also option to general URLs for individual incoming messages below)

  <% form_tag '../hide/' + @info_request.id.to_s, :class => "form form-inline", :info_request_id => @info_request.id.to_s, :id => "hide_request_form" do %>

      Hide the request and notify the user:

        <% if ['hidden', 'requester_only'].include? @info_request.prominence %>

This request has already been hidden

        <% else %>

            <%= radio_button_tag "reason", "not_foi" %> <%= _("Not a valid FOI request") %>

            <%= radio_button_tag "reason", "vexatious" %> <%= _("A vexatious request") %>

        <% end %>

    <% if !['hidden', 'requester_only'].include? @info_request.prominence %>

        Subject of email:

          <%= text_field_tag "subject", "Your request on WhatDoTheyKnow.com hidden", {:id => "request_hidden_user_subject_field", :cols => 100} %>

        Reason for hiding the request (will be emailed to user):

          <%= text_area_tag "explanation", h(@request_hidden_user_explanation), {:id => "request_hidden_user_explanation_field"} %>

        <%= submit_tag _("Hide request"), :class => "btn" %>

    <% end %>
  <% end %>
</formset>

Events

  <% for info_request_event in @info_request.info_request_events.find(:all, :order => "created_at, id") %>

        <a href="#event_<%=info_request_event.id%>" data-toggle="collapse" data-parent="#events">
          <%= _("Event {{id}}", :id => info_request_event.id) %>:

            <%=h info_request_event.event_type.humanize %><% if !info_request_event.calculated_state.nil? %>; state: <%= info_request_event.calculated_state %><% end %>

            <%= info_request_event.created_at%>

      <div id="event_<%=info_request_event.id%>" class="accordion-body collapse">

                <% if info_request_event.described_state != 'waiting_clarification' and info_request_event.event_type == 'response' %>
                  <% form_tag '../mark_event_as_clarification', :class => "form form-inline admin-table-form admin-inline-form" do %>
                    <%= hidden_field_tag 'info_request_event_id', info_request_event.id %>
                    <%= submit_tag "Was clarification request", :class => "btn btn-mini btn-primary" %>
                  <% end %>
                <% end %>

            <% info_request_event.for_admin_column do |name, value, type, column_name| %>

                  <%=h name%>

                  <% if column_name == 'params_yaml' %>
                    <%= info_request_event.params_yaml_as_html %>
                  <% elsif value.nil? %>
                    nil
                  <% elsif %w(text string).include?(type) %>
                    <%=h value.humanize %>
                  <% elsif type == 'datetime' %>
                    <%= admin_date value %>
                  <% else %>
                    <%=h value %>
                  <% end %>

            <% end %>

  <% end %>

Outgoing messages

  <% for outgoing_message in @info_request.outgoing_messages.find(:all, :order => 'created_at') %>

        <a href="#outgoing_<%=outgoing_message.id%>" data-toggle="collapse" data-parent="#outgoing_messages">
        <a href="../edit_outgoing/<%= outgoing_message.id %>">
          #<%= outgoing_message.id %> -- <%= outgoing_message.status.humanize %> <%= outgoing_message.message_type.humanize %>

          <%= truncate(outgoing_message.body, :length => 400) %>

      <div id="outgoing_<%=outgoing_message.id%>" class="accordion-body collapse">

                <% form_tag '../resend', :class => "admin-table-form" do %>
                  <%= hidden_field_tag 'outgoing_message_id', outgoing_message.id %>
                  <%= submit_tag "Resend", :class => "btn" %>
                <% end %>

            <% outgoing_message.for_admin_column do |name, value, type, column_name| %>

                  <%=name%>

                  <% if column_name == 'body' %>
                    <%= simple_format(truncate(outgoing_message.body, :length => 400, :omission => link_to("...", "#", :class => "toggle-hidden" ))) %>

<%= simple_format( outgoing_message.body ) %>

                  <% else %>
                    <%= admin_value(value) %>
                  <% end %>

            <% end %>

  <% end %>

Incoming messages

  <% for incoming_message in @info_request.incoming_messages.find(:all, :order => 'created_at') %>

        <a href="#incoming_<%=incoming_message.id%>" data-toggle="collapse" data-parent="#incoming_messages">
        <%=incoming_message.id%> -- <%= h(incoming_message.mail_from) %> <%=_("at")%> <%=admin_value(incoming_message.sent_at)%>

          <% if !incoming_message.cached_main_body_text_folded.nil? %>
            <%= truncate(incoming_message.cached_main_body_text_folded.gsub('FOLDED_QUOTED_SECTION', ''), :length => 400) %>
          <% end %>

      <div id="incoming_<%=incoming_message.id%>" class="accordion-body collapse">

                <%= render :partial => 'incoming_message_actions', :locals => { :incoming_message => incoming_message } %>

            <% incoming_message.for_admin_column do |name, value, type, column_name| %>

                  <%=name%>

                  <% if column_name =~ /^cached_.*?$/ %>
                    <%= simple_format( truncate(value, :length => 400, :omission => link_to("...", "#", :class => "toggle-hidden"))) %>

<%= simple_format(value) %>

                  <% else %>
                    <%= simple_format(value) %>
                  <% end %>

            <% end %>

  <% end %>

Annotations

<% if @info_request.comments.size > 0 %>

    <% for comment in @info_request.comments %>

         <a href="#comment_<%=comment.id%>" data-toggle="collapse" data-parent="#comments">
          <a href="../edit_comment/<%= comment.id %>">
            #<%=comment.id%>
            --
            <%=h(comment.user.name)%>
            <%=admin_value(comment.created_at)%>

            <%= truncate(comment.body, :length => 400) %>

        <div id="comment_<%=comment.id%>" class="accordion-body collapse">

                 By <%= link_to("".html_safe, user_url(comment.user), :title => "view user's page on public website") %>

                  <%= link_to(h(comment.user.name), user_admin_url(comment.user)) %>

              <% comment.for_admin_column do |name, value, type, column_name |%>

                    <%=name%>

                    <% if column_name == 'body' && !comment.visible %>
                      <s><%=h comment.send(column_name) %></s>
                    <% else %>
                      <%=h comment.send(column_name) %>
                    <% end %>

              <% end %>

    <% end %>

<% else %>

None yet.

<% end %>

Exim delivery logs

(Lines containing the request incoming email address, updated hourly.)

<% for exim_log_done_id, exim_logs in @info_request.exim_logs.group_by(&:exim_log_done_id) %>

<% for exim_log in exim_logs %><%=h exim_log.line%><% end %>

<% end %>
<% if @info_request.exim_logs.size == 0 %>

None (perhaps this is an old or a very new request)

<% end %>

Censor rules

<%= render :partial => 'admin_censor_rule/show', :locals => { :censor_rules => @info_request.censor_rules, :info_request => @info_request } %>


removed unused layout.rhml from generator

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
   <head>
      <title></title>
      <%%= theme_stylesheet_link_tag '<%= file_name %>' %>
   </head>
   <body>
      <%%= @content_for_layout %>
   </body>
</html>


don't inline css into application layout

<?xml version="1.0" encoding="iso-8859-15"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">

    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta name="author" content="Simon Huerlimann <simon.huerlimann@cyt.ch>" />
    <meta name="keywords" content="finance CyT Agrabah" />
    <meta name="description" content="Accounting for Agrabah GmbH" />
    <%= stylesheet_link_tag 'noprobs' %>
    <%= javascript_include_tag :defaults %>

    <title>Accounting for Agrabah GmbH - <%= controller.action_name %></title>

          <%= image_tag 'logo-left-small' %>
          <%= image_tag 'logo-right-small' %>

<%= link_to "Clients", :controller => "clients"%>

<%= link_to "Balance Sheet", :controller => "balance"%>

<%= link_to "Profit Sheet", :controller => "profit"%>

<%= link_to "Accounts", :controller => "accounts"%>

<%= link_to "Bookings", :controller => "bookings"%>

            <%= @content_for_layout %>


Bug fix

Bug fix

<% req  = @user.request_for_project(@project) %>
<% rank = req ? req.rank : nil %>

<% if (rank == 1 && req.role == 'L') %>
  Favorite
<% elsif (rank == 2) %>
  ✓
<% else %>
  <% link = url_for(:action=>'set_req_rank', :rank=>2, :id=>@project) %>
  <a href="#" onclick="return update_tr('<%= @project.id %>', '<%= link %>', 4);">+
<% end %>

<% if (rank == 1 && req.role == 'H') %>
  Favorite
<% elsif (rank == 3) %>
  ✓
<% else %>
  <% link = url_for(:action=>'set_req_rank', :rank=>3, :id=>@project) %>
  <a href="#" onclick="return update_tr('<%= @project.id %>', '<%= link %>', 4);">+
<% end %>

<% if (rank == 4) %>
  ✓
<% else %>
  <% link = url_for(:action=>'set_req_rank', :rank=>4, :id=>@project) %>
  <a href="#" onclick="return update_tr('<%= @project.id %>', '<%= link %>', 4);">+
<% end %>

  <%= link_to @project.name, {:action=>'project_popup', :id=>@project}, pop_opts %>

<% req  = @user.request_for_project(@project) %>
<% rank = req.rank %>

<% if (rank == 1 && req.role == 'L') %>
  Favorite
<% elsif (rank == 2) %>
  ✓
<% else %>
  <% link = url_for(:action=>'set_req_rank', :rank=>2, :id=>@project) %>
  <a href="#" onclick="return update_tr('<%= @project.id %>', '<%= link %>', 4);">+
<% end %>

<% if (rank == 1 && req.role == 'H') %>
  Favorite
<% elsif (rank == 3) %>
  ✓
<% else %>
  <% link = url_for(:action=>'set_req_rank', :rank=>3, :id=>@project) %>
  <a href="#" onclick="return update_tr('<%= @project.id %>', '<%= link %>', 4);">+
<% end %>

<% if (rank == 4) %>
  ✓
<% else %>
  <% link = url_for(:action=>'set_req_rank', :rank=>4, :id=>@project) %>
  <a href="#" onclick="return update_tr('<%= @project.id %>', '<%= link %>', 4);">+
<% end %>

  <%= link_to @project.name, {:action=>'project_popup', :id=>@project}, pop_opts %>


git-svn-id: https://svn.csc.ncsu.edu:8443/svn/research-expertiza/trunk@349 392d7b7b-3f31-0410-9dc3-c95a9635ea79

 Pending Course Evaluations

<% if (@surveys.size > 0) %>

 Course
 Due Date

<% i=0 %>
<% @surveys.each do |s| %>

<%= link_to Course.find_by_id(s[3]).title ,:controller=>'survey_response',:action=>'create' ,:id=> s[1],:questionnaire_id=>s[0].id, :course_eval=>'1', :course_id=> s[3] %>&nbsp &nbsp
<%= s[2].strftime('%A %B %d %Y, %I:%M%p') %>

<% end %>
<% else %>

There exist no pending course evaluations.

<%end%>

 Pending Course Evaluations

<% if @surveys.size > 0 %>

 Course
 Due Date

<% i=0 %>
<% @surveys.each do |s| %>

<%= link_to Course.find_by_id(s[3]).title ,:controller=>'survey_response',:action=>'create' ,:id=> s[1],:questionnaire_id=>s[0].id, :course_eval=>'1', :course_id=> s[3] %>&nbsp &nbsp
<%= s[2].strftime('%A %B %d %Y, %I:%M%p') %>

<% end %>
<% else %>

There exists no pending course evaluations.

<%end%>


Fix theme page. (closes #276)

Fix theme page. (closes #276)

git-svn-id: 70ab0960c3db1cbf656efd6df54a8f3de72dc710@510 820eb932-12ee-0310-9ca8-eeb645f39767

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

		<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
		<title>Typo Administration:  <%= controller.controller_name %></title>
		<meta http-equiv="imagetoolbar" content="no" />
		<%= stylesheet_link_tag "administration.css" %>
		<%= javascript_include_tag "prototype", "effects", "dragdrop", "controls", "typo" %>

	    <%= link_to "settings", :controller=>"/admin/general", :action => 'index' %> |
	    <%= current_user_notice rescue nil %> |
	    <%= link_to 'your blog »', :controller => "/" %>

<%= link_to "Typo admin - #{config_value('blog_name')}", :controller => "/admin/" %>

  	    <%= tab "Articles", :controller=>"/admin/content", :action => 'index' %>
  	    <%= tab "Pages", :controller=>"/admin/pages", :action => 'index' %>
  	    <%= tab "Categories", :controller=>"/admin/categories", :action => 'index' %>
  	    <%= tab "Blacklist", :controller=>"/admin/blacklist", :action => 'index' %>
  	    <%= tab "Sidebar", :controller=>"/admin/sidebar", :action => 'index' %>
  	    <%= tab "Themes", :controller=>"/admin/themes", :action => 'index' %>
  	    <%= tab "Users", :controller=>"/admin/users", :action => 'index' %>

	  <% if @flash["notice"] %>

  	  <%= render_flash rescue nil %>

  	<% end %>

<%= @page_heading %>

  	    <% if not first_render =~ /general|login|signup|logout|sidebar|themes/ %>

Things you can do

	        <%= @content_for_tasks %>
          <%= task_overview unless first_render =~ /\/list$/ %>

       <% end %>
       <%= @content_for_layout %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

		<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
		<title>Typo Administration:  <%= controller.controller_name %></title>
		<meta http-equiv="imagetoolbar" content="no" />
		<%= stylesheet_link_tag "administration.css" %>
		<%= javascript_include_tag "prototype", "effects", "dragdrop", "controls", "typo" %>

	    <%= link_to "settings", :controller=>"/admin/general", :action => 'index' %> |
	    <%= current_user_notice rescue nil %> |
	    <%= link_to 'your blog »', :controller => "/" %>

<%= link_to "Typo admin - #{config_value('blog_name')}", :controller => "/admin/" %>

  	    <%= tab "Articles", :controller=>"/admin/content", :action => 'index' %>
  	    <%= tab "Pages", :controller=>"/admin/pages", :action => 'index' %>
  	    <%= tab "Categories", :controller=>"/admin/categories", :action => 'index' %>
  	    <%= tab "Blacklist", :controller=>"/admin/blacklist", :action => 'index' %>
  	    <%= tab "Sidebar", :controller=>"/admin/sidebar", :action => 'index' %>
  	    <%= tab "Themes", :controller=>"/admin/themes", :action => 'index' %>
  	    <%= tab "Users", :controller=>"/admin/users", :action => 'index' %>

	  <% if @flash["notice"] %>

  	  <%= render_flash rescue nil %>

  	<% end %>

<%= @page_heading %>

  	    <% if not first_render =~ /general|login|signup|logout|sidebar/ %>

Things you can do

	        <%= @content_for_tasks %>
          <%= task_overview unless first_render =~ /\/list$/ %>

       <% end %>
       <%= @content_for_layout %>


ensrue matching open/close div tags please

<%
   search_providers = search_inside
%>

  <%
      # We don't show this block until ALL possible search inside tools
      # have been found. Too hard to deal with AJAX update of a DIV
      # that has a text input box in it otherwise.
      if ( search_providers.length > 0 &&
         ! service_type_in_progress?('search_inside') ) %>

Search inside this
          <%=
           thing = @user_request.referent.type_of_thing
           thing = 'journal' if thing == 'article'
           thing
       %>

    <% # We don't show the search box unless we have a search provider AND
        # we're completely done loading search providers. Too hard
        # to deal with AJAX updating of search providers without
        # interrupting user.
        %>

    <form target="_blank" action="<%= url_for(:controller=>'link_router', :action=>'index') %>">

      via
    <% if search_providers.length > 1 %>
      <select name="id">
      <% search_providers.each do |st| %>
        <option value="<%= st.id %>"><%= st.view_data[:display_text] %></option>
      <% end %>
      </select>
    <% else  %>
      <input type="hidden" name="id" value="<%= search_providers[0].id %>">
      <%= search_providers[0].view_data[:display_text] %>:
    <% end %>

    <input name="query" type="text" /> <input value="search" type="submit">
    </form>

<%end%>

  <%
  if ( @user_request.referent.format == 'book' && service_type_in_progress?('search_inside')) %>

    <%= render(:partial => "background_progress",
           :locals => {
            :svc_type => "search_inside",
            :progress_message => "Looking for tools to search inside this #{@user_request.referent.type_of_thing}" }) %>

  <% end %>


now its called user_summary_page

now its called user_summary_page

Summary page for <%= session[:person].name %>

<% if @mycages.count > 0 %>

Your cages

<%= render_partial 'cages/cage_list', @mycages %>
<% else %>

You have no cages

<% end %>

<% if @mymedicalproblems.length > 0 %>

Current Medical Problems For Which You Are Responsible

Band
Medical Problem
User
Date Opened
<% if @list_all %>
Date Closed
<% else %>

<% end %>

Treatment
<% @show_bat = true %>
<% for cage in @mycages %>
<% for bat in cage.bats %>
<%= render_partial 'medical_problems/medical_problem_for_bat', bat %>
<% end %>
<% end %>

<% else %>
You are responsible for no medical problems.
<% end %>


Fix error in Admin page when showing body with missing name (closes #140)

<% @title = "Public authority - " + h(@public_body.name) %>

<%=@title%>

<%
   columns = PublicBody.content_columns + [] # force dup
   columns.delete_if {|c| ['last_edit_comment'].include?(c.name)}

   for column in columns %>
  <%= column.human_name %>:
  <% if column.name == 'home_page' and !column.name.empty? %>
    <%= link_to(h(@public_body.send(column.name)), @public_body.send(column.name))  %>
  <% elsif column.name == 'request_email' and !column.name.empty? %>
    <%= link_to(h(@public_body.send(column.name)), "mailto:#{@public_body.send(column.name)}")  %>
      <% if !@public_body.is_requestable? %>
          (not requestable due to: <%=h @public_body.not_requestable_reason %><% if @public_body.is_followupable? %>; but followupable<% end %>)
      <% end %>
  <% else %>
      <%=h @public_body.send(column.name) %>
  <% end %>

<% end %>
Calculated home page:
<% if !@public_body.calculated_home_page.nil? %>
    <%= link_to(h(@public_body.calculated_home_page), @public_body.calculated_home_page) %>
<% else %>
    *unknown*
<% end %>

Tags: <%= render :partial => 'tags', :locals => { :body => @public_body} %>

    <%=
        # url_name can be missing if the name hasn't been set for this locale
        if !@public_body.url_name.nil?
            link_to 'Public page', main_url(public_body_url(@public_body))
        else
            'Public page not available'
        end
    %>
    | <%= link_to 'Edit', '../edit/' + @public_body.id.to_s %>

History

Updated at
<%
    history_columns = PublicBody.content_columns + [] # force dup
    history_columns.delete_if {|c| ['created_at', 'updated_at', 'first_letter'].include?(c.name)}
    for column in history_columns %>
  <%= column.human_name %>
<% end %>

<%# There may be an option to versions() to specify order, but I can't find it. TB 2009-03-09 %>
<% for historic_public_body in @public_body.reverse_sorted_versions %>
      <tr class="<%= cycle('odd', 'even') %>">
      <%=h historic_public_body.updated_at %>
    <% for column in history_columns %>
      <%
        value = h(historic_public_body.send(column.name))
        if column.name == 'last_edit_comment'
            value = historic_public_body.last_edit_comment_for_html_display
        end
        # Highlight entries which have changed since previous version
        changed = (!['version', 'last_edit_editor', 'last_edit_comment'].include?(column.name)) && ((historic_public_body.send(column.name) != @public_body.sorted_versions[historic_public_body.version - 2].send(column.name)) || (historic_public_body.version == 1)) %>
      <td <%= changed ? ' class="entry_changed" ': '' %> >
      <%=value%>

    <% end %>

<% end %>

Requests

<%= render :partial => 'admin_request/some_requests', :locals => { :info_requests => @public_body.info_requests } %>

Track things

<%= render :partial => 'admin_track/some_tracks', :locals => { :track_things => @public_body.track_things } %>

<% @title = "Public authority - " + h(@public_body.name) %>

<%=@title%>

<%
   columns = PublicBody.content_columns + [] # force dup
   columns.delete_if {|c| ['last_edit_comment'].include?(c.name)}

   for column in columns %>
  <%= column.human_name %>:
  <% if column.name == 'home_page' and !column.name.empty? %>
    <%= link_to(h(@public_body.send(column.name)), @public_body.send(column.name))  %>
  <% elsif column.name == 'request_email' and !column.name.empty? %>
    <%= link_to(h(@public_body.send(column.name)), "mailto:" + @public_body.send(column.name))  %>
      <% if !@public_body.is_requestable? %>
          (not requestable due to: <%=h @public_body.not_requestable_reason %><% if @public_body.is_followupable? %>; but followupable<% end %>)
      <% end %>
  <% else %>
      <%=h @public_body.send(column.name) %>
  <% end %>

<% end %>
Calculated home page:
<% if !@public_body.calculated_home_page.nil? %>
    <%= link_to(h(@public_body.calculated_home_page), @public_body.calculated_home_page) %>
<% else %>
    *unknown*
<% end %>

Tags: <%= render :partial => 'tags', :locals => { :body => @public_body} %>

    <%= link_to 'Public page', main_url(public_body_url(@public_body)) %>
    | <%= link_to 'Edit', '../edit/' + @public_body.id.to_s %>

History

Updated at
<%
    history_columns = PublicBody.content_columns + [] # force dup
    history_columns.delete_if {|c| ['created_at', 'updated_at', 'first_letter'].include?(c.name)}
    for column in history_columns %>
  <%= column.human_name %>
<% end %>

<%# There may be an option to versions() to specify order, but I can't find it. TB 2009-03-09 %>
<% for historic_public_body in @public_body.reverse_sorted_versions %>
      <tr class="<%= cycle('odd', 'even') %>">
      <%=h historic_public_body.updated_at %>
    <% for column in history_columns %>
      <%
        value = h(historic_public_body.send(column.name))
        if column.name == 'last_edit_comment'
            value = historic_public_body.last_edit_comment_for_html_display
        end
        # Highlight entries which have changed since previous version
        changed = (!['version', 'last_edit_editor', 'last_edit_comment'].include?(column.name)) && ((historic_public_body.send(column.name) != @public_body.sorted_versions[historic_public_body.version - 2].send(column.name)) || (historic_public_body.version == 1)) %>
      <td <%= changed ? ' class="entry_changed" ': '' %> >
      <%=value%>

    <% end %>

<% end %>

Requests

<%= render :partial => 'admin_request/some_requests', :locals => { :info_requests => @public_body.info_requests } %>

Track things

<%= render :partial => 'admin_track/some_tracks', :locals => { :track_things => @public_body.track_things } %>


git-svn-id: http://seta.dit.upm.es/svn/ging/sir2.0/trunk@13745 3f47a204-8049-4147-aab0-d444c64e7564

		<%if session[:current_tab]=="Manage"%>
			<%= link_to "Spaces", :controller=>'spaces', :action=>'index', :container_id => @space.id %> |
			<%= link_to "Roles", :controller=>'roles', :action=>'index', :container_id => @space.id %> |
			<%= link_to "Users", manage_users_path(:container_id => @space.id, :container_type => :spaces) %> |
			<%= link_to "Resources", :controller=>'machines', :action=>'manage_resources', :container_id => @space.id %>
		<%elsif session[:current_tab]=="Events"%>
			<%= link_to "New Event", :controller=>'events', :action=>'new', :container_id => @space.id %> |
			<%= link_to "Show Calendar", :controller=>'events', :action=>'show_calendar', :container_id => @space.id %>
		<%elsif session[:current_tab]=="Groups"%>
			<%if @space.manage_groups_by?(current_user)%>
			<%= link_to 'Create Group', create_group_path(:space,@container.id)%>
			<%end%>
		<%end%>

		<%if session[:current_tab]=="Manage"%>
			<%= link_to "Spaces", :controller=>'spaces', :action=>'index', :container_id => @space.id %> |
			<%= link_to "Roles", :controller=>'roles', :action=>'index', :container_id => @space.id %> |
			<%= link_to "Users", manage_users_path(:container_id => @space.id, :container_type => :spaces) %> |
			<%= link_to "Resources", :controller=>'machines', :action=>'manage_resources', :container_id => @space.id %>
		<%elsif session[:current_tab]=="Events"%>
			<%= link_to "New Event", :controller=>'events', :action=>'new', :container_id => @space.id %> |
			<%= link_to "Show Calendar", :controller=>'events', :action=>'show_calendar', :container_id => @space.id %>
		<%elsif session[:current_tab]=="Groups"%>
			<%= link_to 'Create Group', create_group_path(:space,@container.id)%>
		<%end%>


Better wording

Better wording

<% if @incoming_message.nil? %>
    <% @title = "Send follow up to '" + h(@info_request.title) + "'" %>
<% elsif @incoming_message.recently_arrived %>
    <% @title = "New response to '" + h(@info_request.title) + "'" %>
<% else %>
    <% @title = "Response to '" + h(@info_request.title) + "'" %>
<% end %>

<%= foi_error_messages_for :incoming_message, :outgoing_message %>

<% if @gone_postal %>

Which of these is happening?

            The authority say that they need a postal
            address, not just an email, for it to be a valid FOI request

            The law, the Ministry of Justice and the Information Commissioner
            all say that an email is sufficient (more details).
            At the bottom of this page, write a reply to the authority explaining this to them.

            The authority only has a paper copy of the information.

            At the bottom of this page, write a reply to them trying to persuade them to scan it in
            (more details).

            You want to give your postal address to the authority in private.

            To do that please send a private email to <%=h(@postal_email_name)%>
            <<%=link_to h(@postal_email), "mailto:" + @postal_email%>>
            containing your postal address, and asking them to reply to this request.
            Or you could phone them.

            When you receive the paper response, please help
            others find out what it says:

Add an annotation to your request with choice quotes, or
                a summary of the response.

If you can, scan in or photograph the response, and send us
                    a copy to upload.

<% end %>

    <% if !@incoming_message.nil? %>
        <% if @is_owning_user %>
            <% if @incoming_message.recently_arrived %>

New response to your request '<%= request_link @info_request %>'

            <% else %>

Response to your request '<%= request_link @info_request %>'

            <% end %>
        <% else %>
            <% if @incoming_message.recently_arrived %>

New response to <%=h(@info_request.law_used_short)%> request '<%= request_link @info_request %>'

            <% else %>

Response to <%=h(@info_request.law_used_short)%> request '<%= request_link @info_request %>'

            <% end %>
        <% end %>

        <% if @incoming_message.nil? %>
            <%= render :partial => 'correspondence', :locals => { :info_request_event => @info_request.get_last_outgoing_event, :incoming_message => nil } %>
        <% else %>
            <%= render :partial => 'correspondence', :locals => { :info_request_event => nil, :incoming_message => @incoming_message } %>
        <% end %>
    <% end %>

    <%= render :partial => 'followup', :locals => { :incoming_message => @incoming_message } %>

<% if @incoming_message.nil? %>
    <% @title = "Send follow up to '" + h(@info_request.title) + "'" %>
<% elsif @incoming_message.recently_arrived %>
    <% @title = "New response to '" + h(@info_request.title) + "'" %>
<% else %>
    <% @title = "Response to '" + h(@info_request.title) + "'" %>
<% end %>

<%= foi_error_messages_for :incoming_message, :outgoing_message %>

<% if @gone_postal %>

What exactly is happening?

            The authority say that they need a postal
            address, not just an email, for it to be a valid FOI request

            The law, the Ministry of Justice and the Information Commissioner
            all say that an email is sufficient (more details).
            At the bottom of this page, write a reply to the authority explaining this to them.

            The authority only has a paper copy of the information.

            At the bottom of this page, write a reply to them trying to persuade them to scan it in
            (more details).

            You want to give your postal address to the authority in private.

            To do that please send a private email to <%=h(@postal_email_name)%>
            <<%=link_to h(@postal_email), "mailto:" + @postal_email%>>
            containing your postal address, and asking them to reply to this request.
            Or you could phone them.

            When you receive the paper response, please help
            others find out what it says:

Add an annotation to your request with choice quotes, or
                a summary of the response.

If you can, scan in or photograph the response, and send us
                    a copy to upload.

<% end %>

    <% if !@incoming_message.nil? %>
        <% if @is_owning_user %>
            <% if @incoming_message.recently_arrived %>

New response to your request '<%= request_link @info_request %>'

            <% else %>

Response to your request '<%= request_link @info_request %>'

            <% end %>
        <% else %>
            <% if @incoming_message.recently_arrived %>

New response to <%=h(@info_request.law_used_short)%> request '<%= request_link @info_request %>'

            <% else %>

Response to <%=h(@info_request.law_used_short)%> request '<%= request_link @info_request %>'

            <% end %>
        <% end %>

        <% if @incoming_message.nil? %>
            <%= render :partial => 'correspondence', :locals => { :info_request_event => @info_request.get_last_outgoing_event, :incoming_message => nil } %>
        <% else %>
            <%= render :partial => 'correspondence', :locals => { :info_request_event => nil, :incoming_message => @incoming_message } %>
        <% end %>
    <% end %>

    <%= render :partial => 'followup', :locals => { :incoming_message => @incoming_message } %>


fix test now that records do not show up in collections unless added to the store

<% # ========================================================================
   # SC.ObjectController Unit Test
   # ========================================================================
%>
<% content_for('final') do %>

<script>

// An ObjectController will make a content object or an array of content objects
Test.context("SC.ObjectController", {

    "hasNoContent should be true when content != null and false otherwise": function() {
      this.c.set('content', null) ;
      this.c.get('hasNoContent').shouldEqual(YES) ;

      this.c.set('content', this.single) ;
      this.c.get('hasNoContent').shouldEqual(NO) ;
    },

    "hasSingleContent should be true only when content is a single object": function() {
      this.c.set('content', null) ;
      this.c.get('hasSingleContent').shouldEqual(NO) ;

      this.c.set('content', this.single) ;
      this.c.get('hasSingleContent').shouldEqual(YES) ;

      this.c.set('content', this.single_a) ;
      this.c.get('hasSingleContent').shouldEqual(YES) ;

      this.c.set('content', this.multiple) ;
      this.c.get('hasSingleContent').shouldEqual(NO) ;
    },

    "hasMultipleContent should be true when content = array with multiple items": function() {
      this.c.set('content', null) ;
      this.c.get('hasMultipleContent').shouldEqual(NO) ;

      this.c.set('content', this.single) ;
      this.c.get('hasMultipleContent').shouldEqual(NO) ;

      this.c.set('content', this.single_a) ;
      this.c.get('hasMultipleContent').shouldEqual(NO) ;

      this.c.set('content', this.multiple) ;
      this.c.get('hasMultipleContent').shouldEqual(YES) ;
    },

    "GET EMPTY: properties should return null": function() {
      this.c.set('content', null) ;
      (this.c.get('test') == null).shouldEqual(YES) ;
      (this.c.get('value') == null).shouldEqual(YES) ;
      (this.c.get('flag') == null).shouldEqual(YES) ;
      (this.c.get('array') == null).shouldEqual(YES) ;
    },

    "GET EMPTY ARRAY: properties should return null": function() {
      this.c.set('content', this.empty_a) ;
      (this.c.get('test') == null).shouldEqual(YES) ;
      (this.c.get('value') == null).shouldEqual(YES) ;
      (this.c.get('flag') == null).shouldEqual(YES) ;
      (this.c.get('array') == null).shouldEqual(YES) ;
    },

    "GET SINGLE: should return properties of content": function() {
      this.c.set('content', this.single) ;

      this.c.get('test').shouldEqual('NAME0') ;
      this.c.get('value').shouldEqual(0) ;
      this.c.get('flag').shouldEqual(YES) ;
      this.c.get('array').shouldEqualEnum([0,0,0]) ;
    },

    "GET SINGLE ARRAY: should return properties of first content object": function() {
      this.c.set('content', this.single_a) ;

      this.c.get('test').shouldEqual('NAME0') ;
      this.c.get('value').shouldEqual(0) ;
      this.c.get('flag').shouldEqual(YES) ;
      this.c.get('array').shouldEqualEnum([0,0,0]) ;
    },

    "GET MULTIPLE: should return arrays with values from each content object": function() {
      this.c.set('content', this.multiple) ;

      this.c.get('test').shouldEqualEnum(['NAME0', 'NAME1']) ;
      this.c.get('value').shouldEqualEnum([0,1]) ;
      this.c.get('flag').shouldEqualEnum([YES, NO]) ;

      // get('array').shouldEqual() [ [0,0,0], [1,1,1] ];
      var ar = this.c.get('array') ;
      ar.length.shouldEqual(2) ;
      ar[0].shouldEqualEnum([0,0,0]) ;
      ar[1].shouldEqualEnum([1,1,1]) ;
    },

    "GET CONTROLLER FOR VALUE: should return a controller for the requested value if one exists": function()
    {
      this.c.set('content', this.single);

      this.c.get('test').shouldEqual('NAME0');
      this.c.get('testController').shouldEqual('NAME0');

      this.c.get('value').shouldEqual(0);
      this.c.get('valueController').shouldEqual(0);

      this.c.get('flag').shouldEqual(YES);
      this.c.get('flagController').shouldEqual(YES);

      this.c.get('array').shouldEqualEnum([0,0,0]);
      this.c.get('arrayController').instanceOf( SC.ArrayController ).shouldEqual(YES);

      this.c.get('object').instanceOf( SC.Object ).shouldEqual(YES);
      this.c.get('objectController').instanceOf( SC.ObjectController ).shouldEqual(YES);
    },

    "SET should notify observers of valueController properties": function()
    {
      this.c.set('content', this.single);

      var observer = new Test.Observer;
      this.c.addObserver( 'objectController', observer );
      this.c.set('object', SC.Object.create({ test: "NAME12" }));
      observer.notified.shouldEqual(1);
    },

    "SET value should reset the valueController property": function()
    {
      this.c.set('content', this.single);

      this.c.set('array', this.single_a);
      this.c.get('arrayController').get('length').shouldEqual(1);
      this.c.set('array', this.empty_a);
      this.c.get('arrayController').get('length').shouldEqual(0);
    },

    "SET controller content should reset all valueController properties": function()
    {
      this.c.set('content', SC.Object.create({ array: [1,2,3] }));
      this.c.get('arrayController').get('length').shouldEqual(3);

      this.c.set('content', SC.Object.create({ array: [1] }));
      this.c.get('arrayController').get('length').shouldEqual(1);
    },

    "SET with no autocommit should store in controller, but not in source object": function() {

      this.c.set('content', this.single) ;
      this.c.get('test').shouldEqual('NAME0') ;

      // edit the content, but don't save.
      this.c.set('test', 'NAME1') ;

      this.c.get('hasChanges').shouldEqual(YES) ;
      this.c.get('test').shouldEqual('NAME1') ;
      this.single.get('test').shouldEqual('NAME0') ;

      // save content.
      $ok(this.c.commitChanges()).shouldEqual(YES) ;

      this.c.get('hasChanges').shouldEqual(NO) ;
      this.c.get('test').shouldEqual('NAME1') ;
      this.single.get('test').shouldEqual('NAME1') ;
     },

    "SET on null content should allow set but return error on commit": function() {
      this.c.set('content', null) ;
      this.c.set('test', 'NAME1') ;

      $ok(this.c.commitChanges()).shouldEqual(NO) ;
    },

    "SET on empty array content should allow set but return error on commit": function() {
      this.c.set('content', this.empty_a) ;
      this.c.set('test', 'NAME1') ;

      $ok(this.c.commitChanges()).shouldEqual(NO) ;

    },

    "SET on single array should copy values to object on commit": function() {
      this.c.set('content', this.single) ;
      this.c.set('test','NAME1') ;

      $ok(this.c.commitChanges()).shouldEqual(YES) ;
      this.single.get('test').shouldEqual('NAME1') ;
    },

    "SET on single-item array should copy values to object on commit": function() {
      this.c.set('content', this.single_a) ;
      this.c.set('test','NAME1') ;

      $ok(this.c.commitChanges()).shouldEqual(YES) ;
      this.single_a[0].get('test').shouldEqual('NAME1') ;
    },

    "SET on multiple with array values should copy value to content object at the same index": function() {
      this.c.set('content', this.multiple) ;
      this.c.set('test', ['NAME2','NAME3'] ) ;

      $ok(this.c.commitChanges()).shouldEqual(YES) ;
      this.multiple[0].get('test').shouldEqual('NAME2') ;
      this.multiple[1].get('test').shouldEqual('NAME3') ;
    },

    "SET on multiple with a non-array value should copy same value to each content object": function() {
      this.c.set('content', this.multiple) ;
      this.c.set('test', 'NAME2') ;

      $ok(this.c.commitChanges()).shouldEqual(YES) ;
      this.multiple[0].get('test').shouldEqual('NAME2') ;
      this.multiple[1].get('test').shouldEqual('NAME2') ;
    },

    "Calling performDiscardChanges() should notify property observers of a change": function()
    {
      var observer = new Test.Observer;

      this.c.set('content', this.single);
      this.c.addObserver( 'test', observer );

      // set the property
      this.c.set('test', 'NAME2');
      this.c.get('hasChanges').shouldEqual(YES);
      observer.notified.shouldEqual(1);

      this.c.performDiscardChanges();
      this.c.get('hasChanges').shouldEqual(NO);
      observer.notified.shouldEqual(2);
    },

    "Support commitChanges() on content objects": function() {
      this.c.set('content', this.single) ;
      this.c.set('test', 'NAME2') ;

      $ok(this.c.commitChanges()).shouldEqual(YES) ;
      this.single.didCommitChanges.shouldEqual(YES) ;
    },

    "Should update both values when commitChanges() on content objects" : function() {
      cc = SC.CollectionController.create({
        allowsEmptySelection: false,
        allowsMultipleSelection: false
      });
      var oc = SC.ObjectController.create({
        contentBinding: 'cc.selection',
        commitChangesImmediately: false
      });
      var Contact = SC.Record.extend({});

      var rcrds = Contact.collection();
      cc.set('content', rcrds);
      rcrds.refresh();
      var single = Contact.newRecord({'test' : 'NAME1', 'value' : 0});

      rcrds.count().shouldEqual(1);

      oc.set('test', 'NAME2');
      oc.set('value', 123);

      $ok(oc.commitChanges()).shouldEqual(YES);
      single.get('test').shouldEqual('NAME2');
      single.get('value').shouldEqual(123);
    },

    "Support content objects that implement SC.Array but are not arrays": function() {
      this.c.set('content', this.dummy_a) ;

      // test initial content
      this.c.get('test').shouldEqualEnum(['NAME0', 'NAME1']) ;
      this.c.get('value').shouldEqualEnum([0,1]) ;
      this.c.get('flag').shouldEqualEnum([YES, NO]) ;

      // get('array').shouldEqual(): [ [0,0,0], [1,1,1] ];
      var ar = this.c.get('array') ;
      ar.length.shouldEqual(2) ;
      ar[0].shouldEqualEnum([0,0,0]) ;
      ar[1].shouldEqualEnum([1,1,1]) ;

      // test changing contents
      this.c.set('test', 'NAME2') ;
      $ok(this.c.commitChanges()).shouldEqual(YES) ;
      this.dummy_a.objectAt(0).get('test').shouldEqual('NAME2') ;
      this.dummy_a.objectAt(0).get('test').shouldEqual('NAME2') ;
     },

    "Support content objects that are not Observable": function() {
      var obj = {
        test: 'NAME0', value: 0, flag: YES, array: [0,0,0],

        commitChanges: function() {
          this.didCommitChanges = YES ;
        },

        didCommitChanges: NO
      } ;

      this.c.set('content', obj);
      this.c.get('test').shouldEqual('NAME0') ;

      this.c.set('test', 'NAME1') ;
      $ok(this.c.commitChanges()).shouldEqual(YES) ;

      obj.test.shouldEqual('NAME1') ;
      obj.didCommitChanges.shouldEqual(YES) ;
    },

    setup: function() {
      this.c = SC.ObjectController.create() ;

      this.single = SC.Object.create({
        test: 'NAME0', value: 0, flag: YES, array: [0,0,0],
        object: SC.Object.create({ test: 'NAME1', value: 1, flag: NO, array: [1,1,1] }),

        commitChanges: function() {
          this.didCommitChanges = YES ;
        },

        didCommitChanges: NO
      }) ;

      this.multiple = [
        SC.Object.create({ test: 'NAME0', value: 0, flag: YES, array: [0,0,0] }),
        SC.Object.create({ test: 'NAME1', value: 1, flag: NO, array: [1,1,1] })
      ] ;

      this.single_a = [
        SC.Object.create({ test: 'NAME0', value: 0, flag: YES, array: [0,0,0] })
      ] ;

      this.empty_a = [] ;

      this.dummy_a = SC.Object.create(SC.Array, {
        length: 2,

        replace: function(idx, amt, objects) {
          this._items.replace(idx,amt,objects) ;
          this.set('length', this._items.length) ;
        },

        objectAt: function(idx) {
          return this._items.objectAt(idx) ;
        },

        _items: this.multiple
      }) ;

    }
}) ;

</script>

<% end %>

<% # ========================================================================
   # SC.ObjectController Unit Test
   # ========================================================================
%>
<% content_for('final') do %>

<script>

// An ObjectController will make a content object or an array of content objects
Test.context("SC.ObjectController", {

    "hasNoContent should be true when content != null and false otherwise": function() {
      this.c.set('content', null) ;
      this.c.get('hasNoContent').shouldEqual(YES) ;

      this.c.set('content', this.single) ;
      this.c.get('hasNoContent').shouldEqual(NO) ;
    },

    "hasSingleContent should be true only when content is a single object": function() {
      this.c.set('content', null) ;
      this.c.get('hasSingleContent').shouldEqual(NO) ;

      this.c.set('content', this.single) ;
      this.c.get('hasSingleContent').shouldEqual(YES) ;

      this.c.set('content', this.single_a) ;
      this.c.get('hasSingleContent').shouldEqual(YES) ;

      this.c.set('content', this.multiple) ;
      this.c.get('hasSingleContent').shouldEqual(NO) ;
    },

    "hasMultipleContent should be true when content = array with multiple items": function() {
      this.c.set('content', null) ;
      this.c.get('hasMultipleContent').shouldEqual(NO) ;

      this.c.set('content', this.single) ;
      this.c.get('hasMultipleContent').shouldEqual(NO) ;

      this.c.set('content', this.single_a) ;
      this.c.get('hasMultipleContent').shouldEqual(NO) ;

      this.c.set('content', this.multiple) ;
      this.c.get('hasMultipleContent').shouldEqual(YES) ;
    },

    "GET EMPTY: properties should return null": function() {
      this.c.set('content', null) ;
      (this.c.get('test') == null).shouldEqual(YES) ;
      (this.c.get('value') == null).shouldEqual(YES) ;
      (this.c.get('flag') == null).shouldEqual(YES) ;
      (this.c.get('array') == null).shouldEqual(YES) ;
    },

    "GET EMPTY ARRAY: properties should return null": function() {
      this.c.set('content', this.empty_a) ;
      (this.c.get('test') == null).shouldEqual(YES) ;
      (this.c.get('value') == null).shouldEqual(YES) ;
      (this.c.get('flag') == null).shouldEqual(YES) ;
      (this.c.get('array') == null).shouldEqual(YES) ;
    },

    "GET SINGLE: should return properties of content": function() {
      this.c.set('content', this.single) ;

      this.c.get('test').shouldEqual('NAME0') ;
      this.c.get('value').shouldEqual(0) ;
      this.c.get('flag').shouldEqual(YES) ;
      this.c.get('array').shouldEqualEnum([0,0,0]) ;
    },

    "GET SINGLE ARRAY: should return properties of first content object": function() {
      this.c.set('content', this.single_a) ;

      this.c.get('test').shouldEqual('NAME0') ;
      this.c.get('value').shouldEqual(0) ;
      this.c.get('flag').shouldEqual(YES) ;
      this.c.get('array').shouldEqualEnum([0,0,0]) ;
    },

    "GET MULTIPLE: should return arrays with values from each content object": function() {
      this.c.set('content', this.multiple) ;

      this.c.get('test').shouldEqualEnum(['NAME0', 'NAME1']) ;
      this.c.get('value').shouldEqualEnum([0,1]) ;
      this.c.get('flag').shouldEqualEnum([YES, NO]) ;

      // get('array').shouldEqual() [ [0,0,0], [1,1,1] ];
      var ar = this.c.get('array') ;
      ar.length.shouldEqual(2) ;
      ar[0].shouldEqualEnum([0,0,0]) ;
      ar[1].shouldEqualEnum([1,1,1]) ;
    },

    "GET CONTROLLER FOR VALUE: should return a controller for the requested value if one exists": function()
    {
      this.c.set('content', this.single);

      this.c.get('test').shouldEqual('NAME0');
      this.c.get('testController').shouldEqual('NAME0');

      this.c.get('value').shouldEqual(0);
      this.c.get('valueController').shouldEqual(0);

      this.c.get('flag').shouldEqual(YES);
      this.c.get('flagController').shouldEqual(YES);

      this.c.get('array').shouldEqualEnum([0,0,0]);
      this.c.get('arrayController').instanceOf( SC.ArrayController ).shouldEqual(YES);

      this.c.get('object').instanceOf( SC.Object ).shouldEqual(YES);
      this.c.get('objectController').instanceOf( SC.ObjectController ).shouldEqual(YES);
    },

    "SET should notify observers of valueController properties": function()
    {
      this.c.set('content', this.single);

      var observer = new Test.Observer;
      this.c.addObserver( 'objectController', observer );
      this.c.set('object', SC.Object.create({ test: "NAME12" }));
      observer.notified.shouldEqual(1);
    },

    "SET value should reset the valueController property": function()
    {
      this.c.set('content', this.single);

      this.c.set('array', this.single_a);
      this.c.get('arrayController').get('length').shouldEqual(1);
      this.c.set('array', this.empty_a);
      this.c.get('arrayController').get('length').shouldEqual(0);
    },

    "SET controller content should reset all valueController properties": function()
    {
      this.c.set('content', SC.Object.create({ array: [1,2,3] }));
      this.c.get('arrayController').get('length').shouldEqual(3);

      this.c.set('content', SC.Object.create({ array: [1] }));
      this.c.get('arrayController').get('length').shouldEqual(1);
    },

    "SET with no autocommit should store in controller, but not in source object": function() {

      this.c.set('content', this.single) ;
      this.c.get('test').shouldEqual('NAME0') ;

      // edit the content, but don't save.
      this.c.set('test', 'NAME1') ;

      this.c.get('hasChanges').shouldEqual(YES) ;
      this.c.get('test').shouldEqual('NAME1') ;
      this.single.get('test').shouldEqual('NAME0') ;

      // save content.
      $ok(this.c.commitChanges()).shouldEqual(YES) ;

      this.c.get('hasChanges').shouldEqual(NO) ;
      this.c.get('test').shouldEqual('NAME1') ;
      this.single.get('test').shouldEqual('NAME1') ;
     },

    "SET on null content should allow set but return error on commit": function() {
      this.c.set('content', null) ;
      this.c.set('test', 'NAME1') ;

      $ok(this.c.commitChanges()).shouldEqual(NO) ;
    },

    "SET on empty array content should allow set but return error on commit": function() {
      this.c.set('content', this.empty_a) ;
      this.c.set('test', 'NAME1') ;

      $ok(this.c.commitChanges()).shouldEqual(NO) ;

    },

    "SET on single array should copy values to object on commit": function() {
      this.c.set('content', this.single) ;
      this.c.set('test','NAME1') ;

      $ok(this.c.commitChanges()).shouldEqual(YES) ;
      this.single.get('test').shouldEqual('NAME1') ;
    },

    "SET on single-item array should copy values to object on commit": function() {
      this.c.set('content', this.single_a) ;
      this.c.set('test','NAME1') ;

      $ok(this.c.commitChanges()).shouldEqual(YES) ;
      this.single_a[0].get('test').shouldEqual('NAME1') ;
    },

    "SET on multiple with array values should copy value to content object at the same index": function() {
      this.c.set('content', this.multiple) ;
      this.c.set('test', ['NAME2','NAME3'] ) ;

      $ok(this.c.commitChanges()).shouldEqual(YES) ;
      this.multiple[0].get('test').shouldEqual('NAME2') ;
      this.multiple[1].get('test').shouldEqual('NAME3') ;
    },

    "SET on multiple with a non-array value should copy same value to each content object": function() {
      this.c.set('content', this.multiple) ;
      this.c.set('test', 'NAME2') ;

      $ok(this.c.commitChanges()).shouldEqual(YES) ;
      this.multiple[0].get('test').shouldEqual('NAME2') ;
      this.multiple[1].get('test').shouldEqual('NAME2') ;
    },

    "Calling performDiscardChanges() should notify property observers of a change": function()
    {
      var observer = new Test.Observer;

      this.c.set('content', this.single);
      this.c.addObserver( 'test', observer );

      // set the property
      this.c.set('test', 'NAME2');
      this.c.get('hasChanges').shouldEqual(YES);
      observer.notified.shouldEqual(1);

      this.c.performDiscardChanges();
      this.c.get('hasChanges').shouldEqual(NO);
      observer.notified.shouldEqual(2);
    },

    "Support commitChanges() on content objects": function() {
      this.c.set('content', this.single) ;
      this.c.set('test', 'NAME2') ;

      $ok(this.c.commitChanges()).shouldEqual(YES) ;
      this.single.didCommitChanges.shouldEqual(YES) ;
    },

    "Should update both values when commitChanges() on content objects" : function() {
      cc = SC.CollectionController.create({
        allowsEmptySelection: false,
        allowsMultipleSelection: false
      });
      var oc = SC.ObjectController.create({
        contentBinding: 'cc.selection',
        commitChangesImmediately: false
      });
      var Contact = SC.Record.extend({});

      var rcrds = Contact.collection();
      cc.set('content', rcrds);
      rcrds.refresh();
      var single = Contact.create({'test' : 'NAME1', 'value' : 0});

      rcrds.count().shouldEqual(1);

      oc.set('test', 'NAME2');
      oc.set('value', 123);

      $ok(oc.commitChanges()).shouldEqual(YES);
      single.get('test').shouldEqual('NAME2');
      single.get('value').shouldEqual(123);
    },

    "Support content objects that implement SC.Array but are not arrays": function() {
      this.c.set('content', this.dummy_a) ;

      // test initial content
      this.c.get('test').shouldEqualEnum(['NAME0', 'NAME1']) ;
      this.c.get('value').shouldEqualEnum([0,1]) ;
      this.c.get('flag').shouldEqualEnum([YES, NO]) ;

      // get('array').shouldEqual(): [ [0,0,0], [1,1,1] ];
      var ar = this.c.get('array') ;
      ar.length.shouldEqual(2) ;
      ar[0].shouldEqualEnum([0,0,0]) ;
      ar[1].shouldEqualEnum([1,1,1]) ;

      // test changing contents
      this.c.set('test', 'NAME2') ;
      $ok(this.c.commitChanges()).shouldEqual(YES) ;
      this.dummy_a.objectAt(0).get('test').shouldEqual('NAME2') ;
      this.dummy_a.objectAt(0).get('test').shouldEqual('NAME2') ;
     },

    "Support content objects that are not Observable": function() {
      var obj = {
        test: 'NAME0', value: 0, flag: YES, array: [0,0,0],

        commitChanges: function() {
          this.didCommitChanges = YES ;
        },

        didCommitChanges: NO
      } ;

      this.c.set('content', obj);
      this.c.get('test').shouldEqual('NAME0') ;

      this.c.set('test', 'NAME1') ;
      $ok(this.c.commitChanges()).shouldEqual(YES) ;

      obj.test.shouldEqual('NAME1') ;
      obj.didCommitChanges.shouldEqual(YES) ;
    },

    setup: function() {
      this.c = SC.ObjectController.create() ;

      this.single = SC.Object.create({
        test: 'NAME0', value: 0, flag: YES, array: [0,0,0],
        object: SC.Object.create({ test: 'NAME1', value: 1, flag: NO, array: [1,1,1] }),

        commitChanges: function() {
          this.didCommitChanges = YES ;
        },

        didCommitChanges: NO
      }) ;

      this.multiple = [
        SC.Object.create({ test: 'NAME0', value: 0, flag: YES, array: [0,0,0] }),
        SC.Object.create({ test: 'NAME1', value: 1, flag: NO, array: [1,1,1] })
      ] ;

      this.single_a = [
        SC.Object.create({ test: 'NAME0', value: 0, flag: YES, array: [0,0,0] })
      ] ;

      this.empty_a = [] ;

      this.dummy_a = SC.Object.create(SC.Array, {
        length: 2,

        replace: function(idx, amt, objects) {
          this._items.replace(idx,amt,objects) ;
          this.set('length', this._items.length) ;
        },

        objectAt: function(idx) {
          return this._items.objectAt(idx) ;
        },

        _items: this.multiple
      }) ;

    }
}) ;

</script>

<% end %>


ActionItem158: linking to public URL instead of just showing

git-svn-id: 43659daf80e124e0b603d67096418e58e4f21099@1292 3f533792-8f58-4932-b0fe-aaf55b0a4547

<% if @article %>

    <%= icon('cms') %>
    <%= link_to profile.identifier, :action => 'index' %>
    <%= @article.hierarchy.map {|item| " / " + ((item == @article) ? item.name : link_to(item.name, :id => item.id)) } %>

<% else %>

    <%= icon('cms') %>
    <%= _('Content management') %>

  <% button_bar(:style => 'margin-bottom: 1em;') do %>
    <%= lightbox_button('new', _('New article'), :action => 'new') %>
  <% end %>

<% end %>

<%# subitem %>
<% if !@subitems.empty? && @article %>
  <%= toggle_panel(_('Hide subitems'), _('Show subitems'), 'article-subitems') %>
<% end %>

<%= @article ? _('Subitems') : _('Articles') %>

    <% unless @subitems.empty? %>

        <% @subitems.each do |item| %>

          <%= file_manager_button(item.name, icon_for_article(item), :action => 'view', :id => item.id) %>

        <% end %>

    <% end %>

    <% if @article %>
      <% button_bar(:class => 'file-manager-controls') do %>
        <% if @article.allow_children? %>
          <%= lightbox_button('new',  _('New subitem'), :action => 'new', :parent_id => @article.id) %>
        <% end %>
        <%= button('up', _('Go up one level'), :action => (@article.parent ? 'view' : 'index'), :id => @article.parent) %>
      <% end %>
    <% end %>

<%# display the article content %>

  <% if @article %>

      <%= @article.name %>
      <%= image_tag(icon_for_article(@article)) %>

    <% button_bar(:id => 'article-controls') do %>

        <%= _('"%{article}", last changed by %{author}') % { :article => @article.name, :author => (@article.last_changed_by ? @article.last_changed_by.name : _('Unknown User')) } %>

        <%= _('Public address of this article: %s') % link_to(@article.public_path, @article.public_path) %>

        <%= _('Tags:') %> <%= @article.tag_list %>

        <%= _('Categories:') %> <%= @article.categories.map { |item| item.name }.join(', ') %>

      <%= button('edit', _('Edit'), { :action => 'edit', :id => @article}) %>
      <%= button('home', _('Use as homepage'), { :action => 'set_home_page', :id => @article }, { :method => :post  }) %>
      <%= button('delete', _('Delete'), { :action => 'destroy', :id => @article }, :method => :post, :confirm => _('Are you sure you wan to remove this article?')) %>
    <% end %>
    <%= @article.to_html %>
  <% end %>

<% if @article %>

    <%= icon('cms') %>
    <%= link_to profile.identifier, :action => 'index' %>
    <%= @article.hierarchy.map {|item| " / " + ((item == @article) ? item.name : link_to(item.name, :id => item.id)) } %>

<% else %>

    <%= icon('cms') %>
    <%= _('Content management') %>

  <% button_bar(:style => 'margin-bottom: 1em;') do %>
    <%= lightbox_button('new', _('New article'), :action => 'new') %>
  <% end %>

<% end %>

<%# subitem %>
<% if !@subitems.empty? && @article %>
  <%= toggle_panel(_('Hide subitems'), _('Show subitems'), 'article-subitems') %>
<% end %>

<%= @article ? _('Subitems') : _('Articles') %>

    <% unless @subitems.empty? %>

        <% @subitems.each do |item| %>

          <%= file_manager_button(item.name, icon_for_article(item), :action => 'view', :id => item.id) %>

        <% end %>

    <% end %>

    <% if @article %>
      <% button_bar(:class => 'file-manager-controls') do %>
        <% if @article.allow_children? %>
          <%= lightbox_button('new',  _('New subitem'), :action => 'new', :parent_id => @article.id) %>
        <% end %>
        <%= button('up', _('Go up one level'), :action => (@article.parent ? 'view' : 'index'), :id => @article.parent) %>
      <% end %>
    <% end %>

<%# display the article content %>

  <% if @article %>

      <%= @article.name %>
      <%= image_tag(icon_for_article(@article)) %>

    <% button_bar(:id => 'article-controls') do %>

        <%= _('"%{article}", last changed by %{author}') % { :article => @article.name, :author => (@article.last_changed_by ? @article.last_changed_by.name : _('Unknown User')) } %>

        <%= _('Public address of this article: %s') % (@article.public_path) %>

        <%= _('Tags:') %> <%= @article.tag_list %>

        <%= _('Categories:') %> <%= @article.categories.map { |item| item.name }.join(', ') %>

      <%= button('edit', _('Edit'), { :action => 'edit', :id => @article}) %>
      <%= button('home', _('Use as homepage'), { :action => 'set_home_page', :id => @article }, { :method => :post  }) %>
      <%= button('delete', _('Delete'), { :action => 'destroy', :id => @article }, :method => :post, :confirm => _('Are you sure you wan to remove this article?')) %>
    <% end %>
    <%= @article.to_html %>
  <% end %>


search box on search results page

search box on search results page

<%
if (params["action"] == "journal_list")
  @page_title = "Browse by Journal Title: #{params['id']}"
else
  @page_title = 'Journal titles that '

  @page_title +=
  (params["umlaut.title_search_type"] == "begins") ?
  'begin with ' : 'contain '

  @page_title += "'" + params['rft.jtitle'] + "'"
end

%>

<%= @page_title %>

  <%= form_tag({:controller=>'search', :action=>'journal_search'}, {:method=>'get', :name=>'OpenURL', :id=>'OpenURL'}, nil)  %>
      <input type=hidden name="rfr_id" value="info:sid/sfxit.com:citation">

      <input type="hidden" id="rft_title" name="rft.title">
      <input type="hidden" id="rft_object_id" name="rft.object_id">
      <input type="hidden" id="date" name="rft.date">

      Journal Title:
      <%= text_field_with_auto_complete :journal, :title, {:name=>'rft.jtitle', :onchange=>'clearObjectId();',:autocomplete=>'off', :size=>'40', :value=>params['rft.jtitle']}, {:after_update_element=>'updateObjectId', :min_chars => 4}
      %>

      <select name="umlaut.title_search_type" id="sfx_title_search">
          <option value="contains">contains</option>
          <option value="begins">begins
          with</option>
          <option value="exact">exact match</option>
      </select>

      <input type=hidden name="rft.issn">
      <input type="submit" name="Generate_OpenURL2" value="Search">
      <%= link_to('More search options', :controller=>'search') %>
  </form>

<% if params["action"] == "journal_list" %>
  <%= render :partial=>"a_to_z" %>

<% end %>

<% unless @hits == 0%>

Showing results <%= @start_result_num %> through <%= @end_result_num %> of <%= @hits %>

<% end %>
<% if params["rft.jtitle"] %>

Note: Alternate titles might have matched your search terms

<% end %>

  <%= render :partial=>'pager' %>

<% @display_results.each do | co |
@current_context_object = co
%>
  <% partial_name = @citation_partial || 'citation' %>
  <%= render :partial=>partial_name %>

<% end %>

  <%= render :partial=>'pager' %>

<% if params["action"] == "journal_list" %>

  <%= render :partial=>"a_to_z" %>
<% end %>

<%
if (params["action"] == "journal_list")
  @page_title = "Browse by Journal Title: #{params['id']}"
else

  debugger
  @page_title = 'Journal titles that '

  @page_title +=
  (params["umlaut.title_search_type"] == "begins") ?
  'begin with ' : 'contain '

  @page_title += "'" + params['rft.jtitle'] + "'"
end

%>

<%= @page_title %>

<%= form_tag({:controller=>'search', :action=>'journal_search'}, {:method=>'get', :name=>'OpenURL', :id=>'OpenURL'}, nil)  %>
  <input type="hidden" id="rft_title" name="rft.title">
  <input type="hidden" id="rft_object_id" name="rft.object_id">
  <input type=hidden name="rfr_id" value="info:sid/sfxit.com:citation">
  Journal title: <%= text_field_with_auto_complete :journal, :title, {:name=>'rft.jtitle', :onchange=>'clearObjectId();',:autocomplete=>'off', :size=>'40', :value=>params['rft.jtitle']}, {:after_update_element=>'updateObjectId', :min_chars => 4}
  %>
  <select name="umlaut.title_search_type" id="sfx_title_search">
    <option value="contains">contains</option>
    <option value="begins">begins with</option>
    <option value="exact">exact match</option>
  </select>

  <input type="submit" name="Generate_OpenURL2" value="Search">
  <%= link_to('More search options', :controller => 'search') %>
</form>

<% if params["action"] == "journal_list" %>
  <%= render :partial=>"a_to_z" %>

<% end %>

<% unless @hits == 0%>

Showing results <%= @start_result_num %> through <%= @end_result_num %> of <%= @hits %>

<% end %>
<% if params["sfx.title_search"] == "begins"%>

Note: Alternate titles might have begun with your search terms

<% end %>

  <%= render :partial=>'pager' %>

<% @display_results.each do | co |
@current_context_object = co
%>
  <% partial_name = @citation_partial || 'citation' %>
  <%= render :partial=>partial_name %>

<% end %>

  <%= render :partial=>'pager' %>

<% if params["action"] == "journal_list" %>

  <%= render :partial=>"a_to_z" %>
<% end %>


Fixing redirect uri to match new port number.

Signup for Acme Projects

<% if @call && !@call.errors.empty? %>

Could not complete signup. Please correct the following problems:

    <% @call.errors.each do |error| %>

<%= error.message %>

    <% end %>

<% end %>

<% if @flash %>

<%= @flash %>

<% end %>

<form method="post" action="<%= chargify.base_uri %>/signups">
  <%= chargify.direct.secure_parameters(
    :data => {
      :redirect_uri => "http://localhost:9292/verify"
    }
  ).to_form_inputs %>
  <fieldset>
    <legend>Select Plan</legend>

      <input type="radio" name="signup[product][handle]" id="signup_product_handle_basic" value="basic" <%= 'checked' if original_params.signup.product[:handle] == 'basic' %>/>Basic

      <input type="radio" name="signup[product][handle]" id="signup_product_handle_pro" value="pro" <%= 'checked' if original_params.signup.product[:handle] == 'pro' %>/>Pro

  </fieldset>

  <fieldset>
    <legend>Coupon</legend>

      Coupon Code

      <input type="text" name="signup[coupon_code]" id="signup_coupon_code" value="<%= h(original_params.signup[:coupon_code]) %>" />

  </fieldset>

  <fieldset>
    <legend>About You</legend>

      First Name

      <input type="text" name="signup[customer][first_name]" id="signup_customer_first_name" value="<%= h(original_params.signup.customer[:first_name]) %>" />

      Last Name

      <input type="text" name="signup[customer][last_name]" id="signup_customer_last_name" value="<%= h(original_params.signup.customer[:last_name]) %>"/>

      Email

      <input type="text" name="signup[customer][email]" id="signup_customer_email" value="<%= h(original_params.signup.customer[:email]) %>"/>

  </fieldset>

  <fieldset>
    <legend>Payment Profile</legend>

      First Name on Card

      <input type="text" name="signup[payment_profile][first_name]" id="signup_payment_profile_first_name" value="<%= h(original_params.signup.payment_profile[:first_name]) %>" />

      Last Name on Card

      <input type="text" name="signup[payment_profile][last_name]" id="signup_payment_profile_last_name" value="<%= h(original_params.signup.payment_profile[:last_name]) %>" />

      Card Number

      <input type="text" name="signup[payment_profile][card_number]" id="signup_payment_profile_card_number" value="<%= h(original_params.signup.payment_profile[:card_number]) %>" />

      Expiration Month / Year

      <select name="signup[payment_profile][expiration_month]" id="signup_payment_profile_expiration_month">
        <% for i in 1..12 do %>
        <option value="<%= i %>"<%= ' selected' if original_params.signup.payment_profile[:expiration_month] == i.to_s %>><%= "%02d" % i.to_s %></option>
        <% end %>
      </select>
      /
      <select name="signup[payment_profile][expiration_year]" id="signup_payment_profile_expiration_year">
        <% t = Time.now.year; for i in t..(t+10) %>
        <option value="<%= i %>"<%= ' selected' if original_params.signup.payment_profile[:expiration_year] == i.to_s %>><%= i %></option>
        <% end %>
      </select>

  </fieldset>

    <input type="submit" value="Sign Up" />
    or
    Go Back

</form>

Signup for Acme Projects

<% if @call && !@call.errors.empty? %>

Could not complete signup. Please correct the following problems:

    <% @call.errors.each do |error| %>

<%= error.message %>

    <% end %>

<% end %>

<% if @flash %>

<%= @flash %>

<% end %>

<form method="post" action="<%= chargify.base_uri %>/signups">
  <%= chargify.direct.secure_parameters(
    :data => {
      :redirect_uri => "http://localhost:4567/verify"
    }
  ).to_form_inputs %>
  <fieldset>
    <legend>Select Plan</legend>

      <input type="radio" name="signup[product][handle]" id="signup_product_handle_basic" value="basic" <%= 'checked' if original_params.signup.product[:handle] == 'basic' %>/>Basic

      <input type="radio" name="signup[product][handle]" id="signup_product_handle_pro" value="pro" <%= 'checked' if original_params.signup.product[:handle] == 'pro' %>/>Pro

  </fieldset>

  <fieldset>
    <legend>Coupon</legend>

      Coupon Code

      <input type="text" name="signup[coupon_code]" id="signup_coupon_code" value="<%= h(original_params.signup[:coupon_code]) %>" />

  </fieldset>

  <fieldset>
    <legend>About You</legend>

      First Name

      <input type="text" name="signup[customer][first_name]" id="signup_customer_first_name" value="<%= h(original_params.signup.customer[:first_name]) %>" />

      Last Name

      <input type="text" name="signup[customer][last_name]" id="signup_customer_last_name" value="<%= h(original_params.signup.customer[:last_name]) %>"/>

      Email

      <input type="text" name="signup[customer][email]" id="signup_customer_email" value="<%= h(original_params.signup.customer[:email]) %>"/>

  </fieldset>

  <fieldset>
    <legend>Payment Profile</legend>

      First Name on Card

      <input type="text" name="signup[payment_profile][first_name]" id="signup_payment_profile_first_name" value="<%= h(original_params.signup.payment_profile[:first_name]) %>" />

      Last Name on Card

      <input type="text" name="signup[payment_profile][last_name]" id="signup_payment_profile_last_name" value="<%= h(original_params.signup.payment_profile[:last_name]) %>" />

      Card Number

      <input type="text" name="signup[payment_profile][card_number]" id="signup_payment_profile_card_number" value="<%= h(original_params.signup.payment_profile[:card_number]) %>" />

      Expiration Month / Year

      <select name="signup[payment_profile][expiration_month]" id="signup_payment_profile_expiration_month">
        <% for i in 1..12 do %>
        <option value="<%= i %>"<%= ' selected' if original_params.signup.payment_profile[:expiration_month] == i.to_s %>><%= "%02d" % i.to_s %></option>
        <% end %>
      </select>
      /
      <select name="signup[payment_profile][expiration_year]" id="signup_payment_profile_expiration_year">
        <% t = Time.now.year; for i in t..(t+10) %>
        <option value="<%= i %>"<%= ' selected' if original_params.signup.payment_profile[:expiration_year] == i.to_s %>><%= i %></option>
        <% end %>
      </select>

  </fieldset>

    <input type="submit" value="Sign Up" />
    or
    Go Back

</form>


disable calendar tab until it works

disable calendar tab until it works

<%= Formy.tabs do |f|
  f.tab do |t|
    t.label 'Dashboard'
    t.link me_url(:action => 'dash')
    t.selected params[:controller] == 'me' && (params[:action] == 'dash' || params[:action] == 'index')
  end
  f.tab do |t|
    t.label 'Inbox'
    t.link url_for(:controller => 'inbox', :action => 'index', :path => '')
    t.selected params[:controller] == 'inbox'
  end
  f.tab do |t|
    t.label 'Tasks'
    t.link me_url(:action => 'tasks')
    t.selected params[:action] == 'tasks'
  end
# f.tab do |t|
#   t.label 'Calendar'
#   t.link url_for(:controller => 'my_calendar', :action => 'index')
#   t.selected params[:controller] == 'my_calendar'
# end
  f.tab do |t|
    t.label 'Search'
    t.link me_url(:action => 'search')
    t.selected params[:action] == 'search'
  end
  f.tab do |t|
    t.label 'Requests'
    t.link url_for(:controller => 'requests', :action => '')
    t.selected params[:controller] == 'requests'
  end

  f.tab do |t|
    t.label 'My Profile'
    t.link me_url(:action => 'edit')
    t.selected params[:action] == 'edit'
  end
end
%>

<%= Formy.tabs do |f|
  f.tab do |t|
    t.label 'Dashboard'
    t.link me_url(:action => 'dash')
    t.selected params[:controller] == 'me' && (params[:action] == 'dash' || params[:action] == 'index')
  end
  f.tab do |t|
    t.label 'Inbox'
    t.link url_for(:controller => 'inbox', :action => 'index', :path => '')
    t.selected params[:controller] == 'inbox'
  end
  f.tab do |t|
    t.label 'Tasks'
    t.link me_url(:action => 'tasks')
    t.selected params[:action] == 'tasks'
  end
 f.tab do |t|
   t.label 'Calendar'
   t.link url_for(:controller => 'my_calendar', :action => 'index')
   t.selected params[:controller] == 'my_calendar'
 end
  f.tab do |t|
    t.label 'Search'
    t.link me_url(:action => 'search')
    t.selected params[:action] == 'search'
  end
  f.tab do |t|
    t.label 'Requests'
    t.link url_for(:controller => 'requests', :action => '')
    t.selected params[:controller] == 'requests'
  end

  f.tab do |t|
    t.label 'My Profile'
    t.link me_url(:action => 'edit')
    t.selected params[:action] == 'edit'
  end
end
%>


Add article_tags to the bottom of read.rhtml.  closes #333

git-svn-id: 70ab0960c3db1cbf656efd6df54a8f3de72dc710@545 820eb932-12ee-0310-9ca8-eeb645f39767

<div class="post"<%= onhover_show_admin_tools(:article) %>>
  <%= link_to("edit", { :controller => "admin/content", :action => "edit", :id => @article },
        :class => "admintools", :style => "display: none", :id => "admin_article") %>

<%= @article.title %>

Posted by <%= author_link(@article) %>
  <%= js_distance_of_time_in_words_to_now @article.created_at.utc %>

  <%= @article.full_html %>

  <%= article_links @article %>

<% if @article.allow_comments? or @article.comments.size > 0 -%>

Comments

<% if @article.allow_comments? -%>

    Leave a response

<% end -%>
  <%= content_tag(:ol, render(:partial => "comment", :collection => @article.comments), :id => 'commentList', :class => 'comment-list') %>
<% end -%>

<% if @article.allow_pings? -%>

Trackbacks

    Use the following link to trackback from your own site:

    <%= server_url_for :controller=>"articles", :action=>"trackback", :id=>@article.id %>

  <%= content_tag(:ol, render(:partial => "trackback", :collection => @article.trackbacks), :id => 'trackbackList', :class => 'trackback-list') %>
<% end -%>

  <a href="<%= xml_url(:action=>'articlerss', :id=>@article) %>" title="RSS Feed">RSS feed for this post
  <a href="<%= server_url_for :controller=>"articles", :action=>"trackback", :id=>@article.id %>">trackback uri

<% if @article.allow_comments? -%>
  <%= render :partial => 'comment_box' %>
<% else -%>

Comments are disabled

<% end -%>

<div class="post"<%= onhover_show_admin_tools(:article) %>>
  <%= link_to("edit", { :controller => "admin/content", :action => "edit", :id => @article },
        :class => "admintools", :style => "display: none", :id => "admin_article") %>

<%= @article.title %>

Posted by <%= author_link(@article) %>
  <%= js_distance_of_time_in_words_to_now @article.created_at.utc %>

  <%= @article.full_html %>

<% if @article.allow_comments? or @article.comments.size > 0 -%>

Comments

<% if @article.allow_comments? -%>

    Leave a response

<% end -%>
  <%= content_tag(:ol, render(:partial => "comment", :collection => @article.comments), :id => 'commentList', :class => 'comment-list') %>
<% end -%>

<% if @article.allow_pings? -%>

Trackbacks

    Use the following link to trackback from your own site:

    <%= server_url_for :controller=>"articles", :action=>"trackback", :id=>@article.id %>

  <%= content_tag(:ol, render(:partial => "trackback", :collection => @article.trackbacks), :id => 'trackbackList', :class => 'trackback-list') %>
<% end -%>

  <a href="<%= xml_url(:action=>'articlerss', :id=>@article) %>" title="RSS Feed">RSS feed for this post
  <a href="<%= server_url_for :controller=>"articles", :action=>"trackback", :id=>@article.id %>">trackback uri

<% if @article.allow_comments? -%>
  <%= render :partial => 'comment_box' %>
<% else -%>

Comments are disabled

<% end -%>