diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ability.rb | 13 | ||||
-rw-r--r-- | lib/message_prominence.rb | 26 | ||||
-rw-r--r-- | lib/tasks/gettext.rake | 42 |
3 files changed, 61 insertions, 20 deletions
diff --git a/lib/ability.rb b/lib/ability.rb index 2865ccb1c..f63845e84 100644 --- a/lib/ability.rb +++ b/lib/ability.rb @@ -2,4 +2,15 @@ module Ability def self.can_update_request_state?(user, request) (user && request.is_old_unclassified?) || request.is_owning_user?(user) end -end
\ No newline at end of file + + def self.can_view_with_prominence?(prominence, info_request, user) + if prominence == 'hidden' + return User.view_hidden?(user) + end + if prominence == 'requester_only' + return info_request.is_owning_user?(user) + end + return true + end + +end diff --git a/lib/message_prominence.rb b/lib/message_prominence.rb new file mode 100644 index 000000000..8f54fcc95 --- /dev/null +++ b/lib/message_prominence.rb @@ -0,0 +1,26 @@ +module MessageProminence + + def has_prominence + send :include, InstanceMethods + cattr_accessor :prominence_states + self.prominence_states = ['normal', 'hidden','requester_only'] + validates_inclusion_of :prominence, :in => self.prominence_states + end + + module InstanceMethods + + def user_can_view?(user) + Ability.can_view_with_prominence?(self.prominence, self.info_request, user) + end + + def indexed_by_search? + self.prominence == 'normal' + end + + def all_can_view? + self.prominence == 'normal' + end + + end +end + diff --git a/lib/tasks/gettext.rake b/lib/tasks/gettext.rake index ace7205ae..366dfbe88 100644 --- a/lib/tasks/gettext.rake +++ b/lib/tasks/gettext.rake @@ -9,27 +9,31 @@ namespace :gettext do end end - desc "Update pot file only, without fuzzy guesses (these are done by Transifex)" - task :findpot => :environment do + desc "Update pot/po files for a theme." + task :find_theme => :environment do + theme = ENV['THEME'] + unless theme + puts "Usage: Specify an Alaveteli-theme with THEME=[theme directory name]" + exit(0) + end load_gettext - $LOAD_PATH << File.join(File.dirname(__FILE__),'..','..','lib') - require 'gettext_i18n_rails/haml_parser' - files = files_to_translate + msgmerge = Rails.application.config.gettext_i18n_rails.msgmerge + msgmerge ||= %w[--sort-output --no-location --no-wrap] + GetText.update_pofiles_org( + text_domain, + theme_files_to_translate(theme), + "version 0.0.1", + :po_root => theme_locale_path(theme), + :msgmerge => msgmerge + ) + end - #write found messages to tmp.pot - temp_pot = "tmp.pot" - GetText::rgettext(files, temp_pot) + def theme_files_to_translate(theme) + Dir.glob("{vendor/plugins/#{theme}/lib}/**/*.{rb,erb}") + end - #merge tmp.pot and existing pot - FileUtils.mkdir_p('locale') - GetText::msgmerge("locale/app.pot", temp_pot, "alaveteli", :po_root => 'locale', :msgmerge=>[ :no_wrap, :sort_output ]) - Dir.glob("locale/*/app.po") do |po_file| - GetText::msgmerge(po_file, temp_pot, "alaveteli", :po_root => 'locale', :msgmerge=>[ :no_wrap, :sort_output ]) - end - File.delete(temp_pot) - end + def theme_locale_path(theme) + File.join(Rails.root, "vendor", "plugins", theme, "locale-theme") + end - def files_to_translate - Dir.glob("{app,lib,config,locale}/**/*.{rb,erb,haml,rhtml}") - end end |