Merge branch 'feature/3.0.0-pre/impaired_flag' into feature/2.4.0/accessibility-master

Conflicts:
	app/views/layouts/base.rhtml
pull/41/head
Gregor Schmidt 13 years ago
commit 095ca5aec5
  1. 10
      app/controllers/account_controller.rb
  2. 14
      app/controllers/my_controller.rb
  3. 12
      app/helpers/application_helper.rb
  4. 13
      app/models/user.rb
  5. 4
      app/views/layouts/base.rhtml
  6. 5
      app/views/my/account.rhtml
  7. 8
      app/views/my/first_login.rhtml
  8. 5
      app/views/users/_form.rhtml
  9. 3
      app/views/users/_impaired_settings.rhtml
  10. 4
      config/locales/de.yml
  11. 3
      config/locales/en.yml
  12. 11
      db/migrate/20111114124552_add_user_first_logged_in_and_impaired_fields.rb
  13. 4
      test/exemplars/user_exemplar.rb
  14. 9
      test/fixtures/users.yml
  15. 2
      test/functional/account_controller_test.rb
  16. 2
      test/integration/account_test.rb

@ -202,7 +202,15 @@ class AccountController < ApplicationController
set_autologin_cookie(user)
end
call_hook(:controller_account_success_authentication_after, {:user => user })
redirect_back_or_default :controller => 'my', :action => 'page'
if user.first_login
user.update_attribute(:first_login, false)
redirect_to :controller => "my", :action => "first_login", :back_url => params[:back_url]
else
redirect_back_or_default :controller => 'my', :action => 'page'
end
end
def set_autologin_cookie(user)

@ -85,6 +85,20 @@ class MyController < ApplicationController
end
end
def first_login
if request.get?
@user = User.current
@back_url = url_for(params[:back_url])
elsif request.post? || request.put?
User.current.pref.attributes = params[:pref]
User.current.pref.save
flash[:notice] = l(:notice_account_updated)
redirect_back_or_default(:controller => 'my', :action => 'page')
end
end
# Create a new feeds key
def reset_rss_key
if request.post?

@ -250,11 +250,13 @@ module ApplicationHelper
def render_project_jump_box(projects = [], html_options = {})
projects ||= User.current.memberships.collect(&:project).compact.uniq
if projects.any?
# option_tags = content_tag :option, l(:label_jump_to_a_project), :value => ""
option_tags = (content_tag :option, "", :value => "" )
option_tags << project_tree_options_for_select(projects, :selected => @project) do |p|
{ :value => url_for(:controller => 'projects', :action => 'show', :id => p, :jump => current_menu_item) }
end
impaired = User.current.impaired?
option_tags = impaired ? (content_tag :option, l(:label_jump_to_a_project), :value => "") : (content_tag :option, "", :value => "")
option_tags << project_tree_options_for_select(projects, :selected => @project) do |p|
{ :value => url_for(:controller => 'projects', :action => 'show', :id => p, :jump => current_menu_item) }
end
html_options[:class] ||= ""
html_options[:class] << " chzn-select " if !impaired
select_tag "", option_tags, html_options.merge({ :onchange => "if (this.value != \'\') { window.location = this.value; }" })
end
end

@ -250,6 +250,19 @@ class User < Principal
@time_zone ||= (self.pref.time_zone.blank? ? nil : ActiveSupport::TimeZone[self.pref.time_zone])
end
def impaired=(value)
self.pref.update_attribute(:impaired, !!value)
!!value
end
def impaired
!!self.pref.impaired
end
def impaired?
impaired
end
def wants_comments_in_reverse_order?
self.pref[:comments_sorting] == 'desc'
end

@ -52,8 +52,8 @@
<li class="drop-down">
<%= link_to l(:label_project_plural), :controller => 'projects', :action => 'index' %>
<ul style="display:none;">
<li><%= link_to l(:label_project_view_all), :controller => 'projects', :action => 'index' %></li>
<li><%= render_project_jump_box Project.visible, :id => "project-search", :class => "chzn-select", :'data-placeholder' => "Enter Project Name..." %></li>
<li><%= link_to l(:label_project_view_all), :controller => 'projects', :action => 'index' %></li>
<li><%= render_project_jump_box Project.visible, { :id => "project-search" } %></li>
</ul>
</li>
<% end %>

@ -34,6 +34,11 @@
<%= render :partial => 'users/mail_notifications' %>
</div>
<h3><%=l(:field_impaired_settings)%></h3>
<div class="box tabular">
<%= render :partial => 'users/impaired_settings' %>
</div>
<h3><%=l(:label_preferences)%></h3>
<div class="box tabular">
<%= render :partial => 'users/preferences' %>

@ -0,0 +1,8 @@
<% form_tag({:controller => 'my', :action => "first_login", :back_url => @back_url }, {:method => :put}) do %>
<h3><%=l(:field_impaired_settings)%></h3>
<div class="box tabular">
<%= render :partial => "users/impaired_settings" %>
</div>
<%= submit_tag l(:button_save) %>
<% end %>

@ -19,6 +19,11 @@
<%= call_hook(:view_users_form, :user => @user, :form => f) %>
</div>
<div class="box tabular">
<h3><%=l(:field_impaired_settings)%></h3>
<%= render :partial => "users/impaired_settings" %>
</div>
<div class="box tabular">
<h3><%=l(:label_authentication)%></h3>
<% unless @auth_sources.empty? %>

@ -0,0 +1,3 @@
<% fields_for :pref, @user.pref, :builder => TabularFormBuilder, :lang => current_language do |pref_fields| %>
<p><%= pref_fields.check_box :impaired %></p>
<% end %>

@ -164,6 +164,7 @@ de:
notice_account_wrong_password: Falsches Kennwort.
notice_account_register_done: Konto wurde erfolgreich angelegt.
notice_account_unknown_email: Unbekannter Benutzer.
notice_account_update_failed: Konto konnte nicht aktualisiert werden. Bitte besuchen Sie ihre Profilseite und überprüfen Sie die Einstellungen.
notice_can_t_change_password: Dieses Konto verwendet eine externe Authentifizierungs-Quelle. Unmöglich, das Kennwort zu ändern.
notice_account_lost_email_sent: Eine E-Mail mit Anweisungen, ein neues Kennwort zu wählen, wurde Ihnen geschickt.
notice_account_activated: Ihr Konto ist aktiviert. Sie können sich jetzt anmelden.
@ -985,6 +986,9 @@ de:
field_effective_date: Due date
label_news_comment_added: Comment added to a news
field_warn_on_leaving_unsaved: Warn me when leaving a page with unsaved text
field_impaired_settings: "ChiliProject bietet eine optimierte Oberfläche für motorisch- oder seh-behinderte Nutzer"
field_impaired: "Angepasste ChiliProject-Oberfläche benutzen"
text_warn_on_leaving_unsaved: The current page contains unsaved text that will be lost if you leave this page.
text_default_encoding: "Default: UTF-8"
text_git_repo_example: a bare and local repository (e.g. /gitrepo, c:\gitrepo)

@ -147,6 +147,7 @@ en:
notice_account_wrong_password: Wrong password
notice_account_register_done: Account was successfully created. To activate your account, click on the link that was emailed to you.
notice_account_unknown_email: Unknown user.
notice_account_update_failed: Account setting could not be safed. Please have a look at your account page.
notice_can_t_change_password: This account uses an external authentication source. Impossible to change the password.
notice_account_lost_email_sent: An email with instructions to choose a new password has been sent to you.
notice_account_activated: Your account has been activated. You can now log in.
@ -307,6 +308,8 @@ en:
field_text: Text field
field_visible: Visible
field_warn_on_leaving_unsaved: "Warn me when leaving a page with unsaved text"
field_impaired_settings: "ChiliProject offers a slightly different User Interface for visually/motorically impaired Users"
field_impaired: "Use adjusted ChiliProject Interface"
setting_app_title: Application title
setting_app_subtitle: Application subtitle

@ -0,0 +1,11 @@
class AddUserFirstLoggedInAndImpairedFields < ActiveRecord::Migration
def self.up
add_column :users, :first_login, :boolean, :null => false, :default => true
add_column :user_preferences, :impaired, :boolean, :default => false
end
def self.down
remove_column :users, :first_login
remove_column :user_preferences, :impaired
end
end

@ -41,4 +41,8 @@ class User < Principal
@last_lastname.succ!
@last_lastname
end
def self.first_login
false
end
end

@ -17,6 +17,7 @@ users_004:
mail_notification: all
login: rhill
type: User
first_login: false
users_001:
created_on: 2006-07-19 19:12:21 +02:00
status: 1
@ -35,6 +36,7 @@ users_001:
mail_notification: all
login: admin
type: User
first_login: false
users_002:
created_on: 2006-07-19 19:32:09 +02:00
status: 1
@ -53,6 +55,7 @@ users_002:
mail_notification: all
login: jsmith
type: User
first_login: false
users_003:
created_on: 2006-07-19 19:33:19 +02:00
status: 1
@ -71,6 +74,7 @@ users_003:
mail_notification: all
login: dlopper
type: User
first_login: false
users_005:
id: 5
created_on: 2006-07-19 19:33:19 +02:00
@ -88,6 +92,7 @@ users_005:
mail_notification: all
login: dlopper2
type: User
first_login: false
users_006:
id: 6
created_on: 2006-07-19 19:33:19 +02:00
@ -104,6 +109,7 @@ users_006:
mail_notification: only_my_events
login: ''
type: AnonymousUser
first_login: false
users_007:
id: 7
created_on: 2006-07-19 19:33:19 +02:00
@ -120,6 +126,7 @@ users_007:
mail_notification: only_my_events
login: someone
type: User
first_login: false
users_008:
id: 8
created_on: 2006-07-19 19:33:19 +02:00
@ -136,6 +143,7 @@ users_008:
mail_notification: only_my_events
login: miscuser8
type: User
first_login: false
users_009:
id: 9
created_on: 2006-07-19 19:33:19 +02:00
@ -152,6 +160,7 @@ users_009:
mail_notification: only_my_events
login: miscuser9
type: User
first_login: false
groups_010:
id: 10
lastname: A Team

@ -60,7 +60,7 @@ class AccountControllerTest < ActionController::TestCase
assert existing_user.save!
post :login, :openid_url => existing_user.identity_url
assert_redirected_to '/my/page'
assert_redirected_to '/my/first_login'
end
def test_login_with_invalid_openid_provider

@ -180,7 +180,7 @@ class AccountTest < ActionController::IntegrationTest
AuthSource.expects(:authenticate).returns({:login => 'foo', :firstname => 'Foo', :lastname => 'Smith', :mail => 'foo@bar.com', :auth_source_id => 66})
post 'account/login', :username => 'foo', :password => 'bar'
assert_redirected_to '/my/page'
assert_redirected_to '/my/first_login'
user = User.find_by_login('foo')
assert user.is_a?(User)

Loading…
Cancel
Save