Commit 2d316bf49a011f82f9922abd451f871ba7357740
1 parent
c6e22675
Exists in
master
and in
29 other branches
ActionItem279: done
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1646 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
9 changed files
with
85 additions
and
28 deletions
Show diff stats
app/controllers/public/account_controller.rb
@@ -11,7 +11,7 @@ class AccountController < PublicController | @@ -11,7 +11,7 @@ class AccountController < PublicController | ||
11 | def login | 11 | def login |
12 | @user = User.new | 12 | @user = User.new |
13 | return unless request.post? | 13 | return unless request.post? |
14 | - self.current_user = User.authenticate(params[:login], params[:password]) | 14 | + self.current_user = User.authenticate(params[:user][:login], params[:user][:password]) |
15 | if logged_in? | 15 | if logged_in? |
16 | if params[:remember_me] == "1" | 16 | if params[:remember_me] == "1" |
17 | self.current_user.remember_me | 17 | self.current_user.remember_me |
app/models/change_password.rb
1 | # TODO: send an e-mail with a hash code to the task after the ChangePassword is creatd -> override messages from #Task | 1 | # TODO: send an e-mail with a hash code to the task after the ChangePassword is creatd -> override messages from #Task |
2 | 2 | ||
3 | +class HumanName | ||
4 | + def human_name | ||
5 | + @name | ||
6 | + end | ||
7 | + def initialize(name) | ||
8 | + @name = name | ||
9 | + end | ||
10 | +end | ||
11 | + | ||
3 | class ChangePassword < Task | 12 | class ChangePassword < Task |
4 | 13 | ||
5 | serialize :data, Hash | 14 | serialize :data, Hash |
@@ -7,6 +16,9 @@ class ChangePassword < Task | @@ -7,6 +16,9 @@ class ChangePassword < Task | ||
7 | self[:data] ||= {} | 16 | self[:data] ||= {} |
8 | end | 17 | end |
9 | 18 | ||
19 | + self.columns_hash['login'] = HumanName.new _('Username') | ||
20 | + self.columns_hash['email'] = HumanName.new _('e-Mail') | ||
21 | + | ||
10 | attr_accessor :login, :email, :password, :password_confirmation | 22 | attr_accessor :login, :email, :password, :password_confirmation |
11 | N_('ChangePassword|Login') | 23 | N_('ChangePassword|Login') |
12 | N_('ChangePassword|Email') | 24 | N_('ChangePassword|Email') |
app/models/user.rb
@@ -7,6 +7,14 @@ class User < ActiveRecord::Base | @@ -7,6 +7,14 @@ class User < ActiveRecord::Base | ||
7 | N_('User|Password') | 7 | N_('User|Password') |
8 | N_('User|Password confirmation') | 8 | N_('User|Password confirmation') |
9 | 9 | ||
10 | + def self.human_attribute_name(attrib) | ||
11 | + case attrib.to_sym | ||
12 | + when :login: return _('Username') | ||
13 | + when :email: return _('e-Mail') | ||
14 | + else self.superclass.human_attribute_name(attrib) | ||
15 | + end | ||
16 | + end | ||
17 | + | ||
10 | before_create do |user| | 18 | before_create do |user| |
11 | if user.environment.nil? | 19 | if user.environment.nil? |
12 | user.environment = Environment.default | 20 | user.environment = Environment.default |
app/views/account/forgot_password.rhtml
@@ -2,11 +2,15 @@ | @@ -2,11 +2,15 @@ | ||
2 | 2 | ||
3 | <%= error_messages_for :change_password %> | 3 | <%= error_messages_for :change_password %> |
4 | 4 | ||
5 | -<%= help(_('To change your password, please fill the form on this screen using yout username and your e-mail. You will receive a message at that e-mail address with a web address you can access to create a new password.')) %> | 5 | +<% labelled_form_for :change_password, @change_password, |
6 | + :url => { :action => 'forgot_password' }, | ||
7 | + :html => { :help => _('To change your password, please fill the form on this screen using your username and your e-mail. You will receive a message at that e-mail address with a web address you can access to create a new password.') } do |f| %> | ||
8 | + | ||
9 | + <%= f.text_field :login, | ||
10 | + :onchange => 'this.value = convToValidLogin( this.value )' %> | ||
11 | + | ||
12 | + <%= f.text_field :email %> | ||
6 | 13 | ||
7 | -<% form_for :change_password, @change_password, :url => { :action => 'forgot_password' } do |f| %> | ||
8 | - <%= labelled_form_field(_('Username'), (f.text_field :login)) %> | ||
9 | - <%= labelled_form_field(_('E-mail'), (f.text_field :email)) %> | ||
10 | <div> | 14 | <div> |
11 | <% button_bar do %> | 15 | <% button_bar do %> |
12 | <%= submit_button('send', _('Send change password procedure by e-mail')) %> | 16 | <%= submit_button('send', _('Send change password procedure by e-mail')) %> |
app/views/account/login.rhtml
@@ -2,13 +2,20 @@ | @@ -2,13 +2,20 @@ | ||
2 | 2 | ||
3 | <h2><%= _('Login') %></h2> | 3 | <h2><%= _('Login') %></h2> |
4 | 4 | ||
5 | -<% labelled_form_for :user, @user, :url => { :controller => 'account', :action => 'login' } do |f| %> | 5 | +<% |
6 | + @user = User.new if ! @user | ||
7 | +%> | ||
6 | 8 | ||
7 | -<%= display_form_field(_('Login'), | ||
8 | - text_field_tag(:login, nil, | ||
9 | - :onchange => 'this.value = convToValidLogin( this.value )') ) %> | 9 | +<% labelled_form_for :user, @user, |
10 | + :url => { :controller => 'account', :action => 'login' }, | ||
11 | + :html => { :help => _('If you are a registered user, enter your username and password to be authenticated.')+'<p/>'+_('To join on this environment, click on "<b>I want to be an user!</b>".')+'<p/>'+_('If you forgot your password, click on "<b>I forgot my password!</b>" link.') } do |f| %> | ||
10 | 12 | ||
11 | -<%= display_form_field(_('Password'), password_field_tag(:password) ) %> | 13 | +<%= f.text_field :login, |
14 | + :help => _('Here goes the nickname that you give on the registration.'), | ||
15 | + :onchange => 'this.value = convToValidLogin( this.value )' %> | ||
16 | + | ||
17 | +<%= f.password_field :password, | ||
18 | + :help => _('your password is personal, protect it.') %> | ||
12 | 19 | ||
13 | <% button_bar do %> | 20 | <% button_bar do %> |
14 | <%= submit_button( 'login', _('Log in') )%> | 21 | <%= submit_button( 'login', _('Log in') )%> |
@@ -17,11 +24,11 @@ | @@ -17,11 +24,11 @@ | ||
17 | 24 | ||
18 | <% end %> | 25 | <% end %> |
19 | 26 | ||
20 | -<p class="forgot-passwd"> | 27 | +<p class="forgot-passwd" help="<%= _('You can recover your password clicking on this link.') %>"> |
21 | <%= link_to _("I forgot my password!"), :controller => 'account', :action => 'forgot_password' %> | 28 | <%= link_to _("I forgot my password!"), :controller => 'account', :action => 'forgot_password' %> |
22 | </p> | 29 | </p> |
23 | 30 | ||
24 | -<p class="want-to-be-an-user"><strong> | 31 | +<p class="want-to-be-an-user" help="<%= _('Click here to join to this environment, if you is not already an user.') %>"><strong> |
25 | <%= link_to _("I want to be an user!"), :controller => 'account', :action => 'signup' %> | 32 | <%= link_to _("I want to be an user!"), :controller => 'account', :action => 'signup' %> |
26 | </strong></p> | 33 | </strong></p> |
27 | 34 |
app/views/account/login_block.rhtml
@@ -4,25 +4,33 @@ | @@ -4,25 +4,33 @@ | ||
4 | <h2><%= _('Login') %></h2> | 4 | <h2><%= _('Login') %></h2> |
5 | 5 | ||
6 | <div class="login-box-content"> | 6 | <div class="login-box-content"> |
7 | + | ||
8 | +<% | ||
9 | + @user = User.new if ! @user | ||
10 | +%> | ||
7 | 11 | ||
8 | <% labelled_form_for :user, @user, | 12 | <% labelled_form_for :user, @user, |
13 | + :html => { :help => _('If you are a registered user, enter your username and password to be authenticated.')+'<p/>'+_('To join on this environment, click on "<b>New user</b>".')+'<p/>'+_('If you forgot your password, click on "<b>I forgot my password!</b>" link.') }, | ||
9 | :url => { :controller => 'account', :action => 'login' } do |f| %> | 14 | :url => { :controller => 'account', :action => 'login' } do |f| %> |
10 | 15 | ||
11 | - <%= display_form_field(_('Username'), | ||
12 | - text_field_tag(:login, nil, | ||
13 | - :onchange => 'this.value = convToValidLogin( this.value )') ) %> | ||
14 | - <%= display_form_field(_('Password'), password_field_tag(:password) ) %> | 16 | +<%= f.text_field :login, |
17 | + :help => _('Here goes the nickname that you give on the registration.'), | ||
18 | + :onchange => 'this.value = convToValidLogin( this.value )' %> | ||
19 | + | ||
20 | +<%= f.password_field :password, | ||
21 | + :help => _('your password is personal, protect it.') %> | ||
15 | 22 | ||
16 | <% button_bar do %> | 23 | <% button_bar do %> |
17 | <%= submit_button( 'login', _('Log in') )%> | 24 | <%= submit_button( 'login', _('Log in') )%> |
18 | <%= link_to content_tag( 'span', _('New user') ), | 25 | <%= link_to content_tag( 'span', _('New user') ), |
19 | { :controller => 'account', :action => 'signup' }, | 26 | { :controller => 'account', :action => 'signup' }, |
27 | + :help => _('Click here to join to this environment, if you is not already an user.'), | ||
20 | :class => 'button with-text icon-add' %> | 28 | :class => 'button with-text icon-add' %> |
21 | <% end %> | 29 | <% end %> |
22 | 30 | ||
23 | <% end %> | 31 | <% end %> |
24 | 32 | ||
25 | - <div class="forgot-passwd"> | 33 | + <div class="forgot-passwd" help="<%= _('You can recover your password clicking on this link.') %>"> |
26 | <%= link_to _("I forgot my password!"), | 34 | <%= link_to _("I forgot my password!"), |
27 | :controller => 'account', :action => 'forgot_password' %> | 35 | :controller => 'account', :action => 'forgot_password' %> |
28 | </div> | 36 | </div> |
app/views/account/signup.rhtml
1 | <h1><%= _('Register') %></h1> | 1 | <h1><%= _('Register') %></h1> |
2 | 2 | ||
3 | <%= error_messages_for :user %> | 3 | <%= error_messages_for :user %> |
4 | -<% labelled_form_for :user, @user do |f| -%> | ||
5 | - | 4 | +<% labelled_form_for :user, @user, |
5 | + :html => { :help=>_('Fill all this fields to join in this environment.' + | ||
6 | + '<p/>If you forgot your password, do not create a new account,' + | ||
7 | + ' click on the "<b>I forgot my password!</b>" link. ;-)') | ||
8 | + } do |f| -%> | ||
9 | + | ||
6 | <%= f.text_field :login, | 10 | <%= f.text_field :login, |
7 | - :onchange => 'this.value = convToValidLogin( this.value )' %> | 11 | + :help => help=_('"Username" is a simple nickname to recognize you on this environment.'), |
12 | + :onchange => 'this.value = convToValidLogin( this.value )' %> | ||
13 | +<small><%= help %></small> | ||
14 | + | ||
15 | +<%= f.text_field :email, | ||
16 | + :help => help=_('We\'ll send you an e-mail to validate your registration.') %> | ||
17 | +<small><%= help %></small> | ||
18 | + | ||
19 | +<%= f.password_field :password, | ||
20 | + :help => help=_('Do not use a obviously password, but try some unforgettable word.') %> | ||
21 | +<small><%= help %></small> | ||
8 | 22 | ||
9 | -<%= f.text_field :email %> | ||
10 | -<%= f.password_field :password %> | ||
11 | -<%= f.password_field :password_confirmation %> | 23 | +<%= f.password_field :password_confirmation, |
24 | + :help => help=_('We need to be sure that you wrote correctly your password.') %> | ||
25 | +<small><%= help %></small> | ||
12 | 26 | ||
13 | <% if @terms_of_use %> | 27 | <% if @terms_of_use %> |
14 | <p> | 28 | <p> |
@@ -21,6 +35,6 @@ | @@ -21,6 +35,6 @@ | ||
21 | <% end %> | 35 | <% end %> |
22 | 36 | ||
23 | <% button_bar do %> | 37 | <% button_bar do %> |
24 | - <%= submit_button('save', _('Sign up'), :cancel => {:action => 'index'}) %> | 38 | + <%= submit_button('save', _('Sign up'), :cancel => {:action => 'index'}, :class => 'icon-menu-login') %> |
25 | <% end %> | 39 | <% end %> |
26 | <% end -%> | 40 | <% end -%> |
app/views/layouts/application.rhtml
@@ -110,7 +110,7 @@ | @@ -110,7 +110,7 @@ | ||
110 | 110 | ||
111 | <a href="#" id="btShowHelp" class="icon-help32on" | 111 | <a href="#" id="btShowHelp" class="icon-help32on" |
112 | title="<%= _('Turn help on/off') %>" | 112 | title="<%= _('Turn help on/off') %>" |
113 | - onclick="mouseHelpOnOff()"><span><%= _('Help') %></span></a> | 113 | + onclick="mouseHelpOnOff(); return false"><span><%= _('Help') %></span></a> |
114 | 114 | ||
115 | </div><!-- id="noosfero_bar" --> | 115 | </div><!-- id="noosfero_bar" --> |
116 | 116 | ||
@@ -153,6 +153,7 @@ | @@ -153,6 +153,7 @@ | ||
153 | </div> | 153 | </div> |
154 | </div> | 154 | </div> |
155 | <%= javascript_include_tag 'show-mouse-help' %> | 155 | <%= javascript_include_tag 'show-mouse-help' %> |
156 | + <%# | ||
156 | <div id="noticeAboutHelp" style="display:none"> | 157 | <div id="noticeAboutHelp" style="display:none"> |
157 | <div class="helpAvatar"></div> | 158 | <div class="helpAvatar"></div> |
158 | <%= _('Do you want to activate the automatic help mode?') %> | 159 | <%= _('Do you want to activate the automatic help mode?') %> |
@@ -166,6 +167,7 @@ | @@ -166,6 +167,7 @@ | ||
166 | <p/> | 167 | <p/> |
167 | <%= _('If needed, you can activate or deactivate the automatic help mode by clicking the question mark symbol in the top-right corner') %> | 168 | <%= _('If needed, you can activate or deactivate the automatic help mode by clicking the question mark symbol in the top-right corner') %> |
168 | </div> | 169 | </div> |
170 | + %> | ||
169 | <%= javascript_include_tag 'noosfero-show-help' %> | 171 | <%= javascript_include_tag 'noosfero-show-help' %> |
170 | 172 | ||
171 | <%# javascript_tag('noosferoHelpInit(%s, %s)' % [ _('Do you want to activate the automatic help mode?').inspect, _('If needed, you can activate the automatic help mode by clicking the question mark symbol in the top-right corner').inspect ]) %> | 173 | <%# javascript_tag('noosferoHelpInit(%s, %s)' % [ _('Do you want to activate the automatic help mode?').inspect, _('If needed, you can activate the automatic help mode by clicking the question mark symbol in the top-right corner').inspect ]) %> |
public/javascripts/noosfero-show-help.js
@@ -8,8 +8,8 @@ function mouseHelpOnOff() { | @@ -8,8 +8,8 @@ function mouseHelpOnOff() { | ||
8 | $("btShowHelp").className = "icon-help32off"; | 8 | $("btShowHelp").className = "icon-help32off"; |
9 | } | 9 | } |
10 | var date = new Date(); | 10 | var date = new Date(); |
11 | - // open/close help on help button is remembed by 30 days: | ||
12 | - date.setTime( date.getTime() + ( 30*24*60*60*1000 ) ); | 11 | + // open/close help on help button is remembed by one year: |
12 | + date.setTime( date.getTime() + ( 365*24*60*60*1000 ) ); | ||
13 | var expires = "; expires=" + date.toGMTString(); | 13 | var expires = "; expires=" + date.toGMTString(); |
14 | document.cookie = "mouseHelpTurnOn="+ pageHelp.info.updateBox + expires +"; path=/"; | 14 | document.cookie = "mouseHelpTurnOn="+ pageHelp.info.updateBox + expires +"; path=/"; |
15 | } | 15 | } |
@@ -33,7 +33,9 @@ if ( document.cookie.indexOf("mouseHelpTurnOn=") > -1 ) { | @@ -33,7 +33,9 @@ if ( document.cookie.indexOf("mouseHelpTurnOn=") > -1 ) { | ||
33 | mouseHelpOnOff(); | 33 | mouseHelpOnOff(); |
34 | } | 34 | } |
35 | } | 35 | } |
36 | + | ||
37 | +/* O Noosfero não deve mais propor o help na entrada | ||
36 | else { | 38 | else { |
37 | new Effect.Appear( "noticeAboutHelp", {duration:2} ); | 39 | new Effect.Appear( "noticeAboutHelp", {duration:2} ); |
38 | } | 40 | } |
39 | - | 41 | +*/ |