From: Steve Coast Date: Sat, 7 Apr 2007 11:40:43 +0000 (+0000) Subject: various user bits X-Git-Tag: live~8571 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/c382f33e1c2e17ba00898dede1ff9c3605818f16 various user bits --- diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 4a4d4d855..599521265 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -2,9 +2,9 @@ class UserController < ApplicationController layout 'site' before_filter :authorize, :only => :preferences - before_filter :authorize_web, :only => :rename - - + before_filter :authorize_web, :only => [:rename, :account] + before_filter :require_user, :only => [:account, :display_name_edit] + def save @user = User.new(params[:user]) @user.set_defaults @@ -17,20 +17,15 @@ class UserController < ApplicationController render :action => 'new' end end - + def rename - new_name = params['display_name'] - if @user - @user.display_name = new_name + if params[:user] and params[:user][:display_name] + @user.display_name = params[:user][:display_name] if @user.save flash[:notice] = "User display name updated OK." - else - flash[:notice] = "Rename failed: #{ @user.errors.full_messages.join('; ') }." + redirect_to :controller => 'user', :action => 'account' end - else - flash[:notice] = 'not logged in' end - redirect_to :back end def lost_password diff --git a/app/views/layouts/site.rhtml b/app/views/layouts/site.rhtml index 1154237cb..d32490729 100644 --- a/app/views/layouts/site.rhtml +++ b/app/views/layouts/site.rhtml @@ -15,7 +15,7 @@ <% end %>
<% if flash[:notice] %> -
<%= flash[:notice] %>
+
<%= flash[:notice] %>
<% end %> <%= yield %> @@ -23,12 +23,13 @@
- <% if @user %> - Welcome, <%= @user.display_name %> | - <%= link_to 'logout', {:controller => 'user', :action => 'logout'}, {:id => 'loginanchor'}%> + <% if @user %> + Welcome, <%= @user.display_name %> | + <%= link_to 'account', {:controller => 'user', :action => 'account'}, {:id => 'loginanchor'}%> | + <%= link_to 'logout', {:controller => 'user', :action => 'logout'}, {:id => 'loginanchor'}%> <% else %> - <%= link_to 'log in', {:controller => 'user', :action => 'login'}, {:id => 'loginanchor'}%> | - <%= link_to 'sign up', {:controller => 'user', :action => 'new'}, {:id => 'registeranchor'} %> + <%= link_to 'log in', {:controller => 'user', :action => 'login'}, {:id => 'loginanchor'}%> | + <%= link_to 'sign up', {:controller => 'user', :action => 'new'}, {:id => 'registeranchor'} %> <% end %> diff --git a/app/views/trace/_trace_optionals.rhtml b/app/views/trace/_trace_optionals.rhtml index 394e6daa0..20db1f495 100644 --- a/app/views/trace/_trace_optionals.rhtml +++ b/app/views/trace/_trace_optionals.rhtml @@ -9,17 +9,4 @@ <% end %> <% end %> - <% if @user %> -
- User -
-
-
- Display name:
- - - -
-
- <% end %> <% end %> diff --git a/app/views/user/account.rhtml b/app/views/user/account.rhtml new file mode 100644 index 000000000..c26089671 --- /dev/null +++ b/app/views/user/account.rhtml @@ -0,0 +1,14 @@ +

User details

+ + + + + +
id<%= @user.id %>
email<%= @user.email %>
display name<%= @user.display_name %> (<%= link_to 'change...', :controller => 'user', :action => 'rename' %>)
account created<%= @user.creation_time %>
+ +

Privacy

+ +<%= start_form_tag :controller => 'user', :action => 'public'%> +<%= submit_tag 'Make all my edits public, forever' %> +<%= end_form_tag %> + diff --git a/app/views/user/login.rhtml b/app/views/user/login.rhtml index 31fe7e415..09ace0f51 100644 --- a/app/views/user/login.rhtml +++ b/app/views/user/login.rhtml @@ -8,6 +8,6 @@ Please login or <%= link_to 'create an account', :controller => 'user', :action
- +<%= submit_tag 'Login' %> <%= end_form_tag %> (<%= link_to 'Lost your password?', :controller => 'user', :action => 'lost_password' %>) diff --git a/app/views/user/rename.rhtml b/app/views/user/rename.rhtml new file mode 100644 index 000000000..5e9db6f29 --- /dev/null +++ b/app/views/user/rename.rhtml @@ -0,0 +1,7 @@ +

Display name:

+ +<%= error_messages_for 'user' %> +<%= start_form_tag :controller => 'user', :action => 'rename' %> +<%= text_field :user, :display_name, :value => @user.display_name %> +<%= submit_tag 'Change' %> +<%= end_form_tag %> diff --git a/db/migrate.sql b/db/migrate.sql index 80d11eb9a..a884156d4 100644 --- a/db/migrate.sql +++ b/db/migrate.sql @@ -1,3 +1,5 @@ +/* this script when run on the current db migrates it to rails */ + drop table meta_nodes; alter table current_nodes modify tags text not null; alter table current_nodes modify id bigint(64) not null auto_increment; @@ -26,4 +28,7 @@ create index gpx_file_tags_gpxid_idx on gpx_file_tags(gpx_id); alter table gpx_file_tags add id int(20) auto_increment not null, add primary key(id); alter table users add preferences text; -create index users_display_name_idx on users(display_name); \ No newline at end of file +create index users_display_name_idx on users(display_name); + +alter table users add public boolean default false; + diff --git a/public/stylesheets/site.css b/public/stylesheets/site.css index e18b182b9..d49b603ad 100644 --- a/public/stylesheets/site.css +++ b/public/stylesheets/site.css @@ -370,10 +370,10 @@ hides rule from IE5-Mac \*/ } #notice { - width: 400px; - border: 1px solid black; + border: 1px solid green; padding: 7px; - background-color: #f0f0f0; + background-color: #f0fff0; + margin-bottom: 20px; } #errorExplanation {