Revert set_impaired_flag functionality

This will be added via a separate feature branch

This reverts the commits
* 3269edfa08
* 145f8104a0
* f1973e710c
* f790754487
pull/41/head
Gregor Schmidt 13 years ago
parent a89406429a
commit d78294434a
  1. 31
      app/controllers/application_controller.rb
  2. 1
      app/controllers/my_controller.rb
  3. 14
      app/controllers/users_controller.rb
  4. 6
      app/helpers/application_helper.rb
  5. 14
      app/models/user.rb
  6. 2
      app/views/layouts/base.rhtml
  7. 5
      app/views/my/account.rhtml
  8. 4
      app/views/users/_form.rhtml
  9. 4
      app/views/users/_impaired_flag_checkbox.rhtml
  10. 3
      app/views/users/_impaired_flag_description.rhtml
  11. 2
      app/views/users/_set_impaired_flag.rhtml
  12. 7
      app/views/users/set_impaired_flag.rhtml
  13. 4
      config/locales/en.yml
  14. 1
      config/routes.rb
  15. 11
      db/migrate/20111114124552_add_user_first_logged_in_and_impaired_fields.rb
  16. 4
      test/exemplars/user_exemplar.rb
  17. 9
      test/fixtures/users.yml

@ -63,8 +63,6 @@ class ApplicationController < ActionController::Base
before_filter :user_setup, :check_if_login_required, :set_localization
filter_parameter_logging :password
before_filter :check_for_first_login, :if => :check_if_login_required
rescue_from ActionController::InvalidAuthenticityToken, :with => :invalid_authenticity_token
@ -283,12 +281,7 @@ class ApplicationController < ActionController::Base
end
def redirect_back_or_default(default)
redirect_to default if (redirect_back == false)
false
end
def redirect_back
back_url = CGI.unescape(params[:back_url].to_s)
back_url = URI.escape(CGI.unescape(params[:back_url].to_s))
if !back_url.blank?
begin
uri = URI.parse(back_url)
@ -298,9 +291,10 @@ class ApplicationController < ActionController::Base
return
end
rescue URI::InvalidURIError
# don't do anything
# redirect to default
end
end
redirect_to default
false
end
@ -491,25 +485,6 @@ class ApplicationController < ActionController::Base
render options
end
def check_for_first_login
user = User.current
return true if (!user.first_login or !user.logged?)
user.first_login = false
user.save
if request.get?
url = url_for(params)
else
url = url_for(:controller => params[:controller], :action => params[:action], :id => params[:id], :project_id => params[:project_id])
end
respond_to do |format|
format.html { redirect_to :controller => "users", :action => "set_impaired_flag", :id => User.current, :back_url => url }
format.atom { redirect_to :controller => "users", :action => "set_impaired_flag", :id => User.current, :back_url => url }
format.xml { head :unauthorized }
format.json { head :unauthorized }
end
false
end
# Overrides #default_template so that the api template
# is used automatically if it exists
def default_template(action_name = self.action_name)

@ -53,7 +53,6 @@ class MyController < ApplicationController
@user.safe_attributes = params[:user]
@user.pref.attributes = params[:pref]
@user.pref[:no_self_notified] = (params[:no_self_notified] == '1')
@user.pref[:impaired] = !!(params[:pref].try(:[], :impaired))
if @user.save
@user.pref.save
@user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])

@ -144,7 +144,6 @@ class UsersController < ApplicationController
was_activated = (@user.status_change == [User::STATUS_REGISTERED, User::STATUS_ACTIVE])
# TODO: Similar to My#account
@user.pref.attributes = params[:pref]
@user.pref[:impaired] = !!(params[:pref].try(:[], :impaired))
@user.pref[:no_self_notified] = (params[:no_self_notified] == '1')
if @user.save
@ -212,19 +211,6 @@ class UsersController < ApplicationController
end
end
def set_impaired_flag
user = User.current
user.first_login = false
if request.get?
user.save
@back_url = url_for(params[:back_url])
elsif request.post? || request.put?
user.impaired = !!(params[:pref].try(:[], :impaired))
user.save
redirect_back
end
end
private
def find_user

@ -250,13 +250,11 @@ module ApplicationHelper
def render_project_jump_box(projects = [], html_options = {})
projects ||= User.current.memberships.collect(&:project).compact.uniq
if projects.any?
impaired = User.current.impaired?
option_tags = impaired ? (content_tag :option, l(:label_jump_to_a_project), :value => "") : (content_tag :option, "", :value => "")
# 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
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,20 +250,6 @@ class User < Principal
@time_zone ||= (self.pref.time_zone.blank? ? nil : ActiveSupport::TimeZone[self.pref.time_zone])
end
def impaired?
!!impaired
end
def impaired=(value)
@impaired = (self.pref[:impaired] = !!value)
self.pref.save
@impaired
end
def impaired
@impaired ||= (self.pref[:impaired].nil? ? self.pref[:impaired] = false : self.pref[:impaired])
end
def wants_comments_in_reverse_order?
self.pref[:comments_sorting] == 'desc'
end

@ -53,7 +53,7 @@
<%= 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" } %></li>
<li><%= render_project_jump_box Project.visible, :id => "project-search", :class => "chzn-select", :'data-placeholder' => "Enter Project Name..." %></li>
</ul>
</li>
<% end %>

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

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

@ -1,4 +0,0 @@
<p>
<%= label_tag :'pref[impaired]', l(:label_impaired_checkbox) %>
<%= check_box_tag :'pref[impaired]', true, User.current.impaired? ? true : false %>
</p>

@ -1,3 +0,0 @@
<h3>
<%= l(:text_impaired_information) %>
</h3>

@ -1,2 +0,0 @@
<%= render :partial => "users/impaired_flag_description" %>
<%= render :partial => "users/impaired_flag_checkbox" %>

@ -1,7 +0,0 @@
<% form_tag({ :controller => 'users', :action => "set_impaired_flag", :id => User.current, :back_url => @back_url }, {:method => :put}) do %>
<%= render :partial => "users/impaired_flag_description" %>
<div class="tabular box">
<%= render :partial => "users/impaired_flag_checkbox"%>
</div>
<%= submit_tag l(:button_save) %>
<% end %>

@ -998,7 +998,3 @@ en:
description_compare_to: Compare to version
description_active: Active?
description_current_position: "You are here:"
text_impaired_information: "Chiliproject offers a slightly different User Interface for visually/motorically impaired Users"
label_impaired_checkbox: "Check to use adjusted Chiliproject Interface"
label_impaired_settings: Impairment Settings

@ -126,7 +126,6 @@ ActionController::Routing::Routes.draw do |map|
map.with_options :controller => 'users' do |users|
users.connect 'users/:id/edit/:tab', :action => 'edit', :tab => nil, :conditions => {:method => :get}
users.connect 'users/:id/set_impaired_flag', :action => 'set_impaired_flag'
users.with_options :conditions => {:method => :post} do |user_actions|
user_actions.connect 'users/:id/memberships', :action => 'edit_membership'

@ -1,11 +0,0 @@
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,8 +41,4 @@ class User < Principal
@last_lastname.succ!
@last_lastname
end
def self.first_login
false
end
end

@ -17,7 +17,6 @@ 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
@ -36,7 +35,6 @@ 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
@ -55,7 +53,6 @@ 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
@ -74,7 +71,6 @@ 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
@ -92,7 +88,6 @@ 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
@ -109,7 +104,6 @@ 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
@ -126,7 +120,6 @@ 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
@ -143,7 +136,6 @@ 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
@ -160,7 +152,6 @@ users_009:
mail_notification: only_my_events
login: miscuser9
type: User
first_login: false
groups_010:
id: 10
lastname: A Team

Loading…
Cancel
Save