diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/admin_public_body_controller.rb | 28 | ||||
-rwxr-xr-x | app/helpers/link_to_helper.rb | 4 | ||||
-rw-r--r-- | app/models/info_request_event.rb | 23 | ||||
-rw-r--r-- | app/models/public_body.rb | 132 | ||||
-rw-r--r-- | app/models/request_mailer.rb | 10 | ||||
-rw-r--r-- | app/views/admin_public_body/_form.rhtml | 82 | ||||
-rw-r--r-- | app/views/admin_public_body/_tag_help.rhtml | 18 | ||||
-rw-r--r-- | app/views/admin_public_body/edit.rhtml | 41 | ||||
-rw-r--r-- | app/views/admin_public_body/import_csv.rhtml | 7 | ||||
-rw-r--r-- | app/views/admin_public_body/new.rhtml | 26 | ||||
-rw-r--r-- | app/views/admin_public_body/show.rhtml | 11 | ||||
-rw-r--r-- | app/views/general/_frontpage_search_examples.es.rhtml | 1 | ||||
-rw-r--r-- | app/views/general/_frontpage_search_examples.rhtml | 1 | ||||
-rw-r--r-- | app/views/general/frontpage.rhtml | 6 | ||||
-rw-r--r-- | app/views/layouts/admin.rhtml | 6 |
15 files changed, 240 insertions, 156 deletions
diff --git a/app/controllers/admin_public_body_controller.rb b/app/controllers/admin_public_body_controller.rb index 021122734..bd85f6eed 100644 --- a/app/controllers/admin_public_body_controller.rb +++ b/app/controllers/admin_public_body_controller.rb @@ -82,16 +82,12 @@ class AdminPublicBodyController < AdminController end def new - @locale = self.locale_from_params() - PublicBody.with_locale(@locale) do - @public_body = PublicBody.new - render - end + @public_body = PublicBody.new + render end - + def create - @locale = self.locale_from_params() - PublicBody.with_locale(@locale) do + PublicBody.with_locale(I18n.default_locale) do params[:public_body][:last_edit_editor] = admin_http_auth_user() @public_body = PublicBody.new(params[:public_body]) if @public_body.save @@ -104,17 +100,13 @@ class AdminPublicBodyController < AdminController end def edit - @locale = self.locale_from_params() - PublicBody.with_locale(@locale) do - @public_body = PublicBody.find(params[:id]) - @public_body.last_edit_comment = "" - render - end + @public_body = PublicBody.find(params[:id]) + @public_body.last_edit_comment = "" + render end def update - @locale = self.locale_from_params() - PublicBody.with_locale(@locale) do + PublicBody.with_locale(I18n.default_locale) do params[:public_body][:last_edit_editor] = admin_http_auth_user() @public_body = PublicBody.find(params[:id]) if @public_body.update_attributes(params[:public_body]) @@ -157,7 +149,7 @@ class AdminPublicBodyController < AdminController # Try with dry run first csv_contents = params[:csv_file].read - en = PublicBody.import_csv(csv_contents, params[:tag], true, admin_http_auth_user(), I18n.available_locales) + en = PublicBody.import_csv(csv_contents, params[:tag], true, admin_http_auth_user(), available_locales) errors = en[0] notes = en[1] @@ -166,7 +158,7 @@ class AdminPublicBodyController < AdminController notes.push("Dry run was successful, real run would do as above.") else # And if OK, with real run - en = PublicBody.import_csv(csv_contents, params[:tag], false, admin_http_auth_user(), available_locales) + en = PublicBody.import_csv(csv_contents, params[:tag], false, admin_http_auth_user(), I18n.available_locales) errors = en[0] notes = en[1] if errors.size != 0 diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb index 444129052..34354a79b 100755 --- a/app/helpers/link_to_helper.rb +++ b/app/helpers/link_to_helper.rb @@ -61,7 +61,7 @@ module LinkToHelper # Public bodies def public_body_url(public_body) - return show_public_body_url(:url_name => public_body.url_name, :only_path => true) + public_body.url_name.nil? ? '' : show_public_body_url(:url_name => public_body.url_name, :only_path => true) end def public_body_link_short(public_body) link_to h(public_body.short_or_long_name), public_body_url(public_body) @@ -187,7 +187,7 @@ module LinkToHelper # Basic date format def simple_date(date) - return date.strftime("%e %B %Y").strip + return I18n.l(date, :format => "%e %B %Y") end def simple_time(date) diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb index d79647c98..1550a4bf5 100644 --- a/app/models/info_request_event.rb +++ b/app/models/info_request_event.rb @@ -57,22 +57,7 @@ class InfoRequestEvent < ActiveRecord::Base ] # user described state (also update in info_request) - validates_inclusion_of :described_state, :in => [ - nil, - 'waiting_response', - 'waiting_clarification', - 'gone_postal', - 'deadline_extended', - 'wrong_response', - 'not_held', - 'rejected', - 'successful', - 'partially_successful', - 'internal_review', - 'error_message', - 'requires_admin', - 'user_withdrawn' - ] + validate :must_be_valid_state # whether event is publicly visible validates_inclusion_of :prominence, :in => [ @@ -81,6 +66,12 @@ class InfoRequestEvent < ActiveRecord::Base 'requester_only' ] + def must_be_valid_state + if !described_state.nil? and !InfoRequest.enumerate_states.include?(described_state) + errors.add(described_state, "is not a valid state") + end + end + def user_can_view?(user) if !self.info_request.user_can_view?(user) raise "internal error, called user_can_view? on event when there is not permission to view entire request" diff --git a/app/models/public_body.rb b/app/models/public_body.rb index b75da4331..c19433704 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -38,7 +38,7 @@ class PublicBody < ActiveRecord::Base validates_uniqueness_of :short_name, :message => N_("Short name is already taken"), :if => Proc.new { |pb| pb.short_name != "" } validates_uniqueness_of :name, :message => N_("Name is already taken") - + has_many :info_requests, :order => 'created_at desc' has_many :track_things, :order => 'created_at desc' @@ -46,6 +46,40 @@ class PublicBody < ActiveRecord::Base translates :name, :short_name, :request_email, :url_name, :notes, :first_letter, :publication_scheme + # Convenience methods for creating/editing translations via forms + def translation(locale) + self.translations.find_by_locale(locale) + end + + # XXX - Don't like repeating this! + def calculate_cached_fields(t) + t.first_letter = t.name.scan(/^./mu)[0].upcase unless t.name.nil? or t.name.empty? + short_long_name = t.name + short_long_name = t.short_name if t.short_name and !t.short_name.empty? + t.url_name = MySociety::Format.simplify_url_part(short_long_name, 'body') + end + + def translated_versions + translations + end + + def translated_versions=(translation_attrs) + if translation_attrs.respond_to? :each_value # Hash => updating + translation_attrs.each_value do |attrs| + t = translation(attrs[:locale]) || PublicBody::Translation.new + t.attributes = attrs + calculate_cached_fields(t) + t.save! + end + else # Array => creating + translation_attrs.each do |attrs| + new_translation = PublicBody::Translation.new(attrs) + calculate_cached_fields(new_translation) + translations << new_translation + end + end + end + # Make sure publication_scheme gets the correct default value. # (This would work automatically, were publication_scheme not a translated attribute) def after_initialize @@ -191,7 +225,6 @@ class PublicBody < ActiveRecord::Base # When name or short name is changed, also change the url name def short_name=(short_name) - globalize.write(self.class.locale || I18n.locale, :short_name, short_name) self[:short_name] = short_name self.update_url_name @@ -204,15 +237,15 @@ class PublicBody < ActiveRecord::Base end def update_url_name - url_name = MySociety::Format.simplify_url_part(self.short_or_long_name, 'body') - self.url_name = url_name + self.url_name = MySociety::Format.simplify_url_part(self.short_or_long_name, 'body') end + # Return the short name if present, or else long name def short_or_long_name - if self.short_name.nil? # can happen during construction + if self.short_name.nil? || self.short_name.empty? # 'nil' can happen during construction self.name else - self.short_name.empty? ? self.name : self.short_name + self.short_name end end @@ -311,9 +344,10 @@ class PublicBody < ActiveRecord::Base # Import from CSV. Just tests things and returns messages if dry_run is true. # Returns an array of [array of errors, array of notes]. If there are errors, # always rolls back (as with dry_run). - def self.import_csv(csv, tag, dry_run, editor, additional_locales = []) + def self.import_csv(csv, tag, dry_run, editor, available_locales = []) errors = [] notes = [] + available_locales = [I18n.default_locale] if available_locales.empty? begin ActiveRecord::Base.transaction do @@ -330,7 +364,7 @@ class PublicBody < ActiveRecord::Base end set_of_importing = Set.new() - field_names = { 'name'=>1, 'email'=>2 } # Default values in case no field list is given + field_names = { 'name'=>1, 'request_email'=>2 } # Default values in case no field list is given line = 0 CSV::Reader.parse(csv) do |row| line = line + 1 @@ -341,57 +375,65 @@ class PublicBody < ActiveRecord::Base row.each_with_index {|field, i| field_names[field] = i} next end + + fields = {} + field_names.each{|name, i| fields[name] = row[i]} name = row[field_names['name']] - email = row[field_names['email']] + email = row[field_names['request_email']] next if name.nil? - if email.nil? - email = '' # unknown/bad contact is empty string - end name.strip! email.strip! - if email != "" && !MySociety::Validate.is_valid_email(email) - errors.push "error: line " + line.to_s + ": invalid email " + email + " for authority '" + name + "'" + if !email.nil? && !email.empty? && !MySociety::Validate.is_valid_email(email) + errors.push "error: line #{line.to_s}: invalid email '#{email}' for authority '#{name}'" next end + + field_list = ['name', 'short_name', 'request_email', 'notes', 'publication_scheme', 'home_page'] + + if public_body = bodies_by_name[name] + available_locales.each do |locale| + PublicBody.with_locale(locale) do + changed = {} + field_list.each do |field_name| + localized_field_name = (locale === I18n.default_locale) ? field_name : "#{field_name}.#{locale}" + localized_value = field_names[localized_field_name] && row[field_names[localized_field_name]] + if !localized_value.nil? and public_body.send(field_name) != localized_value + changed[field_name] = "#{public_body.send(field_name)}: #{localized_value}" + public_body.send("#{field_name}=", localized_value) + end + end - if bodies_by_name[name] - # Already have the public body, just update email - public_body = bodies_by_name[name] - if public_body.request_email != email - notes.push "line " + line.to_s + ": updating email for '" + name + "' from " + public_body.request_email + " to " + email - public_body.request_email = email - public_body.last_edit_editor = editor - public_body.last_edit_comment = 'Updated from spreadsheet' - public_body.save! - end - - additional_locales.each do |locale| - localized_name = field_names["name.#{locale}"] && row[field_names["name.#{locale}"]] - PublicBody.with_locale(locale) do - if !localized_name.nil? and public_body.name != localized_name - notes.push "line " + line.to_s + ": updating name for '#{name}' from '#{public_body.name}' to '#{localized_name}' (locale: #{locale})." - public_body.name = localized_name + unless changed.empty? + notes.push "line #{line.to_s}: updating authority '#{name}' (locale: #{locale}):\n\t#{changed.to_json}" + public_body.last_edit_editor = editor + public_body.last_edit_comment = 'Updated from spreadsheet' public_body.save! end end end - else - # New public body - notes.push "line " + line.to_s + ": new authority '" + name + "' with email " + email - public_body = PublicBody.new(:name => name, :request_email => email, :short_name => "", :home_page => "", :publication_scheme => "", :notes => "", :last_edit_editor => editor, :last_edit_comment => 'Created from spreadsheet') - public_body.tag_string = tag - public_body.save! - - additional_locales.each do |locale| - localized_name = field_names["name.#{locale}"] && row[field_names["name.#{locale}"]] - if !localized_name.nil? - PublicBody.with_locale(locale) do - notes.push "line " + line.to_s + ": (aka '#{localized_name}' in locale #{locale})" - public_body.name = localized_name - public_body.publication_scheme = "" + else # New public body + public_body = PublicBody.new(:name=>name, :short_name=>"", :request_email=>"") + available_locales.each do |locale| + PublicBody.with_locale(locale) do + changed = {} + field_list.each do |field_name| + localized_field_name = (locale === I18n.default_locale) ? field_name : "#{field_name}.#{locale}" + localized_value = field_names[localized_field_name] && row[field_names[localized_field_name]] + if !localized_value.nil? and public_body.send(field_name) != localized_value + changed[field_name] = localized_value + public_body.send("#{field_name}=", localized_value) + end + end + + unless changed.empty? + notes.push "line #{line.to_s}: creating new authority '#{name}' (locale: #{locale}):\n\t#{changed.to_json}" + public_body.publication_scheme = public_body.publication_scheme || "" + public_body.tag_string = tag + public_body.last_edit_editor = editor + public_body.last_edit_comment = 'Created from spreadsheet' public_body.save! end end diff --git a/app/models/request_mailer.rb b/app/models/request_mailer.rb index fc317d20d..e244aaac9 100644 --- a/app/models/request_mailer.rb +++ b/app/models/request_mailer.rb @@ -266,12 +266,12 @@ class RequestMailer < ApplicationMailer end end - # Send email alerts for new responses which haven't been classified. Goes - # out 3 days after last update of event, then after 7, then after 24. + # Send email alerts for new responses which haven't been classified. By default, + # it goes out 3 days after last update of event, then after 10, then after 24. def self.alert_new_response_reminders - self.alert_new_response_reminders_internal(3, 'new_response_reminder_1') - self.alert_new_response_reminders_internal(10, 'new_response_reminder_2') - self.alert_new_response_reminders_internal(24, 'new_response_reminder_3') + MySociety::Config.get("NEW_RESPONSE_REMINDER_AFTER_DAYS", [3, 10, 24]).each_with_index do |days, i| + self.alert_new_response_reminders_internal(days, "new_response_reminder_#{i+1}") + end end def self.alert_new_response_reminders_internal(days_since, type_code) info_requests = InfoRequest.find_old_unclassified(:order => 'info_requests.id', diff --git a/app/views/admin_public_body/_form.rhtml b/app/views/admin_public_body/_form.rhtml index b1516be2e..191b29e89 100644 --- a/app/views/admin_public_body/_form.rhtml +++ b/app/views/admin_public_body/_form.rhtml @@ -2,48 +2,60 @@ <!--[form:public_body]--> -<div id="tag_help"> - <h2>List of tags</h2> - <% first_row = true %> - <% for row in PublicBodyCategories::CATEGORIES_WITH_HEADINGS %> - <% if row.instance_of?(Array) %> - <% if row[0] != 'other' %> - <strong><%= row[0] %></strong>=<%= row[1] %> - <br/> - <% end %> - <% elsif row != 'Miscellaneous' %> - <% if not first_row %> - <% else %> - <% first_row = false %> - <% end %> - <h3><%=h row%></h3> - <% end %> +<div id="div-locales"> + <ul> + <% for locale in I18n.available_locales do %> + <li><a href="#div-locale-<%=locale.to_s%>"><%=locale_name(locale.to_s)%></a></li> <% end %> + </ul> + +<% + for locale in I18n.available_locales do + if locale==I18n.default_locale # The default locale is submitted as part of the bigger object... + prefix = 'public_body' + object = @public_body + else # ...but additional locales go "on the side" + prefix = "public_body[translated_versions][]" + object = @public_body.new_record? ? + PublicBody::Translation.new : + @public_body.translation(locale.to_s) || PublicBody::Translation.new + end + + fields_for prefix, object do |t| +%> + <div id="div-locale-<%=locale.to_s%>"> + <%= t.hidden_field :locale, :value => locale.to_s %> + + <p><label for="public_body_name">Name</label><br/> + <%= t.text_field :name, :size => 60 %></p> + + <p><label for="public_body_short_name">Short name <small>(only put in abbreviations which are really used, otherwise leave blank. Short or long name is used in the URL - don't worry about breaking URLs through renaming, as the history is used to redirect)</small></label><br/> + <%= t.text_field :short_name, :size => 60 %></p> + + <p><label for="public_body_request_email">Request email <small>(set to <strong>blank</strong> (empty string) if can't find an address; these emails are <strong>public</strong> as anyone can view with a CAPTCHA)</small></label><br/> + <%= t.text_field :request_email, :size => 40 %></p> + + <p><label for="public_body_publication_scheme">Publication scheme URL</label><br/> + <%= t.text_field :publication_scheme, :size => 60 %></p> + + <p><label for="public_body_notes">Public notes</label> <small>(HTML, for users to consider when making FOI requests to the authority)</small><br/> + <%= t.text_area :notes, :rows => 3, :cols => 60 %></p> + </div> +<% + end + end +%> </div> -<p><label for="public_body_name">Name</label><br/> -<%= text_field 'public_body', 'name', :size => 60 %></p> - -<p><label for="public_body_short_name">Short name <small>(only put in abbreviations which are really used, otherwise leave blank. Short or long name is used in the URL - don't worry about breaking URLs through renaming, as the history is used to redirect)</small></label><br/> -<%= text_field 'public_body', 'short_name', :size => 60 %></p> - -<p><label for="public_body_request_email">Request email <small>(set to <strong>blank</strong> (empty string) if can't find an address; these emails are <strong>public</strong> as anyone can view with a CAPTCHA)</small></label><br/> -<%= text_field 'public_body', 'request_email', :size => 40 %></p> +<h3>Common Fields</h3> <p><label for="public_body_tag_string">Tags <small>(space separated; see list of tags on the right; also <strong>not_apply</strong> if FOI and EIR no longer apply to authority, <strong>eir_only</strong> if EIR but not FOI applies to authority, <strong>defunct</strong> if the authority no longer exists; charity:NUMBER if a registered charity)</small></label><br/> -<%= text_field 'public_body', 'tag_string', :size => 60 %></p> +<%= f.text_field :tag_string, :size => 60 %></p> <p><label for="public_body_home_page">Home page <small>(of whole authority, not just their FOI page; set to <strong>blank</strong> (empty string) to guess it from the email)</small></label><br/> -<%= text_field 'public_body', 'home_page', :size => 60 %></p> - -<p><label for="public_body_publication_scheme">Publication scheme URL</label><br/> -<%= text_field 'public_body', 'publication_scheme', :size => 60 %></p> - -<p><label for="public_body_notes">Public notes</label> <small>(HTML, for users to consider when making FOI requests to the authority)</small><br/> -<%= text_area 'public_body', 'notes', :rows => 3, :cols => 60 %></p> +<%= f.text_field :home_page, :size => 60 %></p> <p><label for="public_body_last_edit_comment"><strong>Comment</strong> for this edit</label> <small>(put URL or other source of new info)</small><br/> -<%= text_area 'public_body', 'last_edit_comment', :rows => 3, :cols => 60 %></p> -<!--[eoform:public_body]--> - +<%= f.text_area :last_edit_comment, :rows => 3, :cols => 60 %></p> +<!--[eoform:public_body]--> diff --git a/app/views/admin_public_body/_tag_help.rhtml b/app/views/admin_public_body/_tag_help.rhtml new file mode 100644 index 000000000..7954ff992 --- /dev/null +++ b/app/views/admin_public_body/_tag_help.rhtml @@ -0,0 +1,18 @@ +<div id="tag_help"> + <h2>List of tags</h2> + <% first_row = true %> + <% for row in PublicBodyCategories::CATEGORIES_WITH_HEADINGS %> + <% if row.instance_of?(Array) %> + <% if row[0] != 'other' %> + <strong><%= row[0] %></strong>=<%= row[1] %> + <br/> + <% end %> + <% elsif row != 'Miscellaneous' %> + <% if not first_row %> + <% else %> + <% first_row = false %> + <% end %> + <h3><%=h row%></h3> + <% end %> + <% end %> +</div>
\ No newline at end of file diff --git a/app/views/admin_public_body/edit.rhtml b/app/views/admin_public_body/edit.rhtml index 005ec93ce..1883eb083 100644 --- a/app/views/admin_public_body/edit.rhtml +++ b/app/views/admin_public_body/edit.rhtml @@ -1,23 +1,30 @@ - - <h1><%=@title%></h1> -<% form_tag '../update/' + @public_body.id.to_s do %> - <%= render :partial => 'form' %> - <p><%= submit_tag 'Save', :accesskey => 's' %></p> -<% end %> +<script> + $(function() { + $("#div-locales").tabs(); + }); +</script> -<p> -<%= link_to 'Show', '../show/' + @public_body.id.to_s %> | -<%= link_to 'List all', '../list' %> -</p> +<%= render :partial => 'tag_help' %> -<% if @public_body.info_requests.size == 0 %> - <% form_tag('../destroy/' + @public_body.id.to_s) do %> - <p> - <%= hidden_field_tag(:public_body_id, { :value => @public_body.id } ) %> - <%= submit_tag "Destroy " + @public_body.name %> (this is permanent!) - </p> +<div id="public_body_form"> + <% form_for @public_body, :url => {:action => 'update'} do |f| %> + <%= render :partial => 'form', :locals => {:f => f} %> + <p><%= f.submit 'Save', :accesskey => 's' %></p> <% end %> -<% end %> + <p> + <%= link_to 'Show', '../show/' + @public_body.id.to_s %> | + <%= link_to 'List all', '../list' %> + </p> + + <% if @public_body.info_requests.size == 0 %> + <% form_tag('../destroy/' + @public_body.id.to_s) do %> + <p> + <%= hidden_field_tag(:public_body_id, { :value => @public_body.id } ) %> + <%= submit_tag "Destroy " + @public_body.name %> (this is permanent!) + </p> + <% end %> + <% end %> +</div> diff --git a/app/views/admin_public_body/import_csv.rhtml b/app/views/admin_public_body/import_csv.rhtml index 50a4b951a..3bcc4bf41 100644 --- a/app/views/admin_public_body/import_csv.rhtml +++ b/app/views/admin_public_body/import_csv.rhtml @@ -23,16 +23,19 @@ <p><strong>CSV file format:</strong> A first row with the list of fields, starting with '#', is optional but highly recommended. The fields 'name' - and 'email' are required; additionaly, translated values are supported by + and 'request_email' are required; additionaly, translated values are supported by adding the locale name to the field name, e.g. 'name.es', 'name.de'... Example: </p> <blockquote> - #id,name,email,name.es<br/> + #id,name,request_email,name.es<br/> 1,An Authority,a@example.com,Un organismo<br/> 2,Another One,another@example.com,Otro organismo<br/> </blockquote> + <p>Supported files: name (i18n), short_name (i18n), request_email (i18n), notes (i18n), + publication_scheme (i18n), home_page.</p> + <p><strong>Note:</strong> Choose <strong>dry run</strong> to test, without actually altering the database. Choose <strong>upload</strong> to actually make the changes. In either case, you will be shown any errors, or details diff --git a/app/views/admin_public_body/new.rhtml b/app/views/admin_public_body/new.rhtml index 95208b5b3..11186ee47 100644 --- a/app/views/admin_public_body/new.rhtml +++ b/app/views/admin_public_body/new.rhtml @@ -2,11 +2,21 @@ <h1><%=@title%></h1> -<% form_tag 'create' do %> - <%= render :partial => 'form' %> - <p><%= submit_tag "Create" %></p> -<% end %> - -<p> -<%= link_to 'List all', 'list' %> -</p> +<script> + $(function() { + $("#div-locales").tabs(); + }); +</script> + +<%= render :partial => 'tag_help' %> + +<div id="public_body_form"> + <% form_for :public_body, @public_body, :url => {:action => "create"} do |f| %> + <%= render :partial => 'form', :locals => {:f => f} %> + <p><%= f.submit "Create" %></p> + <% end %> + + <p> + <%= link_to 'List all', 'list' %> + </p> +</div> diff --git a/app/views/admin_public_body/show.rhtml b/app/views/admin_public_body/show.rhtml index c1292c63a..643ccf5e8 100644 --- a/app/views/admin_public_body/show.rhtml +++ b/app/views/admin_public_body/show.rhtml @@ -12,7 +12,7 @@ <% 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)) %> + <%= 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 %> @@ -32,7 +32,14 @@ </p> <p> - <%= link_to 'Public page', main_url(public_body_url(@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 %> </p> diff --git a/app/views/general/_frontpage_search_examples.es.rhtml b/app/views/general/_frontpage_search_examples.es.rhtml new file mode 100644 index 000000000..63c7c3c1e --- /dev/null +++ b/app/views/general/_frontpage_search_examples.es.rhtml @@ -0,0 +1 @@ +por ejemplo <a href="/es/search/El%20Geraldine%20Quango">El Geraldine Quango</a>, <a href="/search/fancy%20dog">Fancy Dog</a>. diff --git a/app/views/general/_frontpage_search_examples.rhtml b/app/views/general/_frontpage_search_examples.rhtml new file mode 100644 index 000000000..359a132e2 --- /dev/null +++ b/app/views/general/_frontpage_search_examples.rhtml @@ -0,0 +1 @@ +for example <a href="/search/Geraldine%20Quango">Geraldine Quango</a> or <a href="/search/fancy%20dog">Fancy Dog</a>. diff --git a/app/views/general/frontpage.rhtml b/app/views/general/frontpage.rhtml index abed0294e..44b4980df 100644 --- a/app/views/general/frontpage.rhtml +++ b/app/views/general/frontpage.rhtml @@ -13,11 +13,7 @@ <%= hidden_field_tag 'bodies', 1 %> <%= submit_tag _('Search') %> <br> - <%= _('e.g.') %> - <% @search_examples.each_with_index do |name, i| %> - <%=link_to name, search_url(name, 'bodies')%><% if i < 2 %>, <% else %>. <% break %><% end %> - <% end %> - + <%= render :partial => 'frontpage_search_examples' %> <br> <br> <%= _('OR, <strong>search</strong> for information others have requested using {{site_name}}', :site_name => site_name) %> diff --git a/app/views/layouts/admin.rhtml b/app/views/layouts/admin.rhtml index f0e9a7019..42ca5dbbb 100644 --- a/app/views/layouts/admin.rhtml +++ b/app/views/layouts/admin.rhtml @@ -3,6 +3,10 @@ <head> <meta http-equiv="content-type" content="text/html;charset=UTF-8" > <title><%= site_name %> admin<%= @title ? ":" : "" %> <%=@title%></title> + + <%= javascript_include_tag 'jquery.js', 'jquery-ui.min' %> + + <%= stylesheet_link_tag 'admin-theme/jquery-ui-1.8.15.custom.css', :rel => 'stylesheet'%> <%= stylesheet_link_tag 'admin', :title => "Main", :rel => "stylesheet" %> </head> <body> @@ -30,6 +34,6 @@ <% end %> <%= yield %> - + </body> </html> |