Skip to content

Commit

Permalink
Closes edavis10#5: added user option to enable/disable stuff to do pl…
Browse files Browse the repository at this point in the history
…ugin
  • Loading branch information
ande3577 committed Sep 7, 2012
1 parent d6b2c70 commit bada79e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
8 changes: 8 additions & 0 deletions app/views/users/_preferences.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<%= labelled_fields_for :pref, @user.pref do |pref_fields| %>
<p><%= pref_fields.check_box :hide_mail %></p>
<p><%= pref_fields.select :time_zone, ActiveSupport::TimeZone.all.collect {|z| [ z.to_s, z.name ]}, :include_blank => true %></p>
<p><%= pref_fields.select :comments_sorting, [[l(:label_chronological_order), 'asc'], [l(:label_reverse_chronological_order), 'desc']] %></p>
<p><%= pref_fields.check_box :warn_on_leaving_unsaved %></p>
<p><%= pref_fields.check_box :stuff_to_do_enabled %></p>
<% end %>

1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ en:
stuff_to_do_time_grid_save_error: "{{count}} time entries could not be saved."
stuff_to_do_time_grid_save_notice: "{{count}} time entries saved."
stuff_to_do_use_time_grid: "Use Time Grid"
field_stuff_to_do_enabled: "Stuff to Do enabled"

9 changes: 9 additions & 0 deletions db/migrate/007_add_enable_stuff_to_do_to_user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class AddEnableStuffToDoToUser < ActiveRecord::Migration
def self.up
add_column :user_preferences, :stuff_to_do_enabled, :boolean, :default => false
end

def self.down
remove_column :user_preferences, :stuff_to_do_enabled
end
end
2 changes: 1 addition & 1 deletion init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
end

menu(:top_menu, :stuff_to_do, {:controller => "stuff_to_do", :action => 'index'}, :caption => :stuff_to_do_title, :if => Proc.new{
User.current.allowed_to?({:controller => 'stuff_to_do', :action => 'index'},nil, :global => true)
User.current.allowed_to?({:controller => 'stuff_to_do', :action => 'index'} ,nil, :global => true) && !User.current.nil? && User.current.pref[:stuff_to_do_enabled]
})

end

0 comments on commit bada79e

Please sign in to comment.