diff options
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/admin_helper.rb | 1 | ||||
-rw-r--r-- | app/helpers/admin_public_body_category_helper.rb | 1 | ||||
-rw-r--r-- | app/helpers/application_helper.rb | 1 | ||||
-rw-r--r-- | app/helpers/config_helper.rb | 1 | ||||
-rw-r--r-- | app/helpers/date_time_helper.rb | 1 | ||||
-rw-r--r-- | app/helpers/health_checks_helper.rb | 3 | ||||
-rwxr-xr-x | app/helpers/link_to_helper.rb | 27 | ||||
-rw-r--r-- | app/helpers/mailer_helper.rb | 1 | ||||
-rw-r--r-- | app/helpers/public_body_helper.rb | 22 | ||||
-rw-r--r-- | app/helpers/track_helper.rb | 1 | ||||
-rw-r--r-- | app/helpers/widget_helper.rb | 47 |
11 files changed, 67 insertions, 39 deletions
diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb index d13fea79b..9d63b1cad 100644 --- a/app/helpers/admin_helper.rb +++ b/app/helpers/admin_helper.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- module AdminHelper def icon(name) content_tag(:i, "", :class => "icon-#{name}") diff --git a/app/helpers/admin_public_body_category_helper.rb b/app/helpers/admin_public_body_category_helper.rb index 9c5e5cc5e..2d8842562 100644 --- a/app/helpers/admin_public_body_category_helper.rb +++ b/app/helpers/admin_public_body_category_helper.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- module AdminPublicBodyCategoryHelper def heading_is_selected?(heading) if params[:headings] diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 49ce94951..2f51f5684 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # app/helpers/application_helper.rb: # Methods added to this helper will be available to all views (i.e. templates) # in the application. diff --git a/app/helpers/config_helper.rb b/app/helpers/config_helper.rb index 026600ff1..9953c4fe0 100644 --- a/app/helpers/config_helper.rb +++ b/app/helpers/config_helper.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- module ConfigHelper def site_name AlaveteliConfiguration::site_name diff --git a/app/helpers/date_time_helper.rb b/app/helpers/date_time_helper.rb index 5f129e590..09b5b2a76 100644 --- a/app/helpers/date_time_helper.rb +++ b/app/helpers/date_time_helper.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- module DateTimeHelper # Public: Usually-correct format for a DateTime-ish object # To define a new new format define the `simple_date_{FORMAT}` method diff --git a/app/helpers/health_checks_helper.rb b/app/helpers/health_checks_helper.rb index f5769a9ba..b2f1f9de5 100644 --- a/app/helpers/health_checks_helper.rb +++ b/app/helpers/health_checks_helper.rb @@ -1,7 +1,8 @@ +# -*- encoding : utf-8 -*- module HealthChecksHelper def check_status(check) - style = check.ok? ? {} : "color: red" + style = check.ok? ? '' : 'color: red' content_tag(:b, check.message, :style => style) end diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb index 44d6c6f5f..a47dd94ea 100755 --- a/app/helpers/link_to_helper.rb +++ b/app/helpers/link_to_helper.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- # app/helpers/link_to_helper.rb: # This module is included into all controllers via controllers/application.rb # - @@ -240,32 +241,6 @@ module LinkToHelper link_to h(query), search_url(query) end - # Deprecated helper - # TODO: Remove in next release - def admin_url(relative_path) - warn "[DEPRECATION] admin_url is deprecated. Please remove it from your theme." - relative_path - end - - # Deprecated helper - # TODO: Remove in next release - def main_url(relative_path, append = nil) - warn "[DEPRECATION] main_url is deprecated. Please remove it from your theme." - url_prefix = "http://" + AlaveteliConfiguration::domain - url = url_prefix + relative_path - if !append.nil? - begin - env = Rack::MockRequest.env_for(url) - req = Rack::Request.new(env) - req.path_info += append - url = req.url - rescue URI::InvalidURIError - # don't append to it - end - end - return url - end - # About page URLs def about_url return help_general_url(:action => 'about') diff --git a/app/helpers/mailer_helper.rb b/app/helpers/mailer_helper.rb index 3d4bbac71..573f7d8a8 100644 --- a/app/helpers/mailer_helper.rb +++ b/app/helpers/mailer_helper.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- module MailerHelper def contact_from_name_and_email "#{AlaveteliConfiguration::contact_name} <#{AlaveteliConfiguration::contact_email}>" diff --git a/app/helpers/public_body_helper.rb b/app/helpers/public_body_helper.rb index 57c90a9ba..b8e59a341 100644 --- a/app/helpers/public_body_helper.rb +++ b/app/helpers/public_body_helper.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- module PublicBodyHelper # Public: The reasons a request can't be made to a PublicBody @@ -36,22 +37,19 @@ module PublicBodyHelper # # public_body - Instance of a PublicBody # - # Returns a string + # Returns a String def type_of_authority(public_body) - first = true - types = public_body.tags.each.map do |tag| - if PublicBodyCategory.get().by_tag().include?(tag.name) - desc = PublicBodyCategory.get().singular_by_tag()[tag.name] - if first - desc = desc.sub(/\S/) { |m| Unicode.upcase(m) } - first = false - end - link_to(desc, list_public_bodies_path(tag.name)) + categories = PublicBodyCategory. + where(:category_tag => public_body.tag_string.split) + + types = categories.each_with_index.map do |category, index| + desc = category.description + if index.zero? + desc = desc.sub(/\S/) { |m| Unicode.upcase(m) } end + link_to(desc, list_public_bodies_path(category.category_tag)) end - types.compact! - if types.any? types.to_sentence(:last_word_connector => ' and ').html_safe else diff --git a/app/helpers/track_helper.rb b/app/helpers/track_helper.rb index ca698926c..75ff784f3 100644 --- a/app/helpers/track_helper.rb +++ b/app/helpers/track_helper.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- module TrackHelper def already_subscribed_notice(track_thing) diff --git a/app/helpers/widget_helper.rb b/app/helpers/widget_helper.rb new file mode 100644 index 000000000..70353ea7c --- /dev/null +++ b/app/helpers/widget_helper.rb @@ -0,0 +1,47 @@ +# -*- encoding : utf-8 -*- +module WidgetHelper + def status_description(info_request, status) + case status + when 'waiting_classification' + _('Awaiting classification') + when 'waiting_response' + _('Awaiting response') + when 'waiting_response_overdue' + _('Delayed') + when 'waiting_response_very_overdue' + _('Long overdue') + when 'not_held' + _('Not held') + when 'rejected' + _('Rejected') + when 'successful' + _('Successful') + when 'partially_successful' + _('Partial success') + when 'waiting_clarification' + _('Awaiting clarification') + when 'gone_postal' + _('Handled by post') + when 'internal_review' + _('Internal review') + when 'error_message' + _('Delivery error') + when 'requires_admin' + _('Unusual response') + when 'user_withdrawn' + _('Withdrawn') + when 'attention_requested' + _('Needs admin attention') + when 'vexatious' + _('Vexatious') + when 'not_foi' + _('Not an FOI request') + else + if info_request.respond_to?(:theme_display_status) + info_request.theme_display_status(status) + else + _('Unknown') + end + end + end +end |