various user bits
This commit is contained in:
parent
3789c7b592
commit
c382f33e1c
8 changed files with 45 additions and 36 deletions
|
@ -2,9 +2,9 @@ class UserController < ApplicationController
|
||||||
layout 'site'
|
layout 'site'
|
||||||
|
|
||||||
before_filter :authorize, :only => :preferences
|
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
|
def save
|
||||||
@user = User.new(params[:user])
|
@user = User.new(params[:user])
|
||||||
@user.set_defaults
|
@user.set_defaults
|
||||||
|
@ -17,20 +17,15 @@ class UserController < ApplicationController
|
||||||
render :action => 'new'
|
render :action => 'new'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def rename
|
def rename
|
||||||
new_name = params['display_name']
|
if params[:user] and params[:user][:display_name]
|
||||||
if @user
|
@user.display_name = params[:user][:display_name]
|
||||||
@user.display_name = new_name
|
|
||||||
if @user.save
|
if @user.save
|
||||||
flash[:notice] = "User display name updated OK."
|
flash[:notice] = "User display name updated OK."
|
||||||
else
|
redirect_to :controller => 'user', :action => 'account'
|
||||||
flash[:notice] = "Rename failed: #{ @user.errors.full_messages.join('; ') }."
|
|
||||||
end
|
end
|
||||||
else
|
|
||||||
flash[:notice] = 'not logged in'
|
|
||||||
end
|
end
|
||||||
redirect_to :back
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def lost_password
|
def lost_password
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
<div id="content">
|
<div id="content">
|
||||||
<% if flash[:notice] %>
|
<% if flash[:notice] %>
|
||||||
<div id="notice"><%= flash[:notice] %></div>
|
<div id="notice"><%= flash[:notice] %></div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= yield %>
|
<%= yield %>
|
||||||
|
@ -23,12 +23,13 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<span id="greeting">
|
<span id="greeting">
|
||||||
<% if @user %>
|
<% if @user %>
|
||||||
Welcome, <%= @user.display_name %> |
|
Welcome, <%= @user.display_name %> |
|
||||||
<%= link_to 'logout', {:controller => 'user', :action => 'logout'}, {:id => 'loginanchor'}%>
|
<%= link_to 'account', {:controller => 'user', :action => 'account'}, {:id => 'loginanchor'}%> |
|
||||||
|
<%= link_to 'logout', {:controller => 'user', :action => 'logout'}, {:id => 'loginanchor'}%>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= link_to 'log in', {:controller => 'user', :action => 'login'}, {:id => 'loginanchor'}%> |
|
<%= link_to 'log in', {:controller => 'user', :action => 'login'}, {:id => 'loginanchor'}%> |
|
||||||
<%= link_to 'sign up', {:controller => 'user', :action => 'new'}, {:id => 'registeranchor'} %>
|
<%= link_to 'sign up', {:controller => 'user', :action => 'new'}, {:id => 'registeranchor'} %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
|
|
|
@ -9,17 +9,4 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% if @user %>
|
|
||||||
<div class="optionalbox">
|
|
||||||
<span class="oboxheader">User</span>
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<form action="/user/rename" method="get" style="margin: 0px">
|
|
||||||
<span>Display name:</span><br />
|
|
||||||
<input type="text" value="<%= @user.display_name %>" maxlength="255" size="8" name="display_name"/>
|
|
||||||
<input type="submit" value="Save"/>
|
|
||||||
<input type="hidden" value="<%= request.request_uri %>" name="redirect_url"/>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
14
app/views/user/account.rhtml
Normal file
14
app/views/user/account.rhtml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<h2>User details</h2>
|
||||||
|
<table>
|
||||||
|
<tr><td>id</td><td><%= @user.id %></td></tr>
|
||||||
|
<tr><td>email</td><td><%= @user.email %></td></tr>
|
||||||
|
<tr><td>display name</td><td><%= @user.display_name %> (<%= link_to 'change...', :controller => 'user', :action => 'rename' %>)</td></tr>
|
||||||
|
<tr><td>account created</td><td><%= @user.creation_time %></td></tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<h2>Privacy</h2>
|
||||||
|
|
||||||
|
<%= start_form_tag :controller => 'user', :action => 'public'%>
|
||||||
|
<%= submit_tag 'Make all my edits public, forever' %>
|
||||||
|
<%= end_form_tag %>
|
||||||
|
|
|
@ -8,6 +8,6 @@ Please login or <%= link_to 'create an account', :controller => 'user', :action
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
<input type="submit" value="Login">
|
<%= submit_tag 'Login' %>
|
||||||
|
|
||||||
<%= end_form_tag %> (<%= link_to 'Lost your password?', :controller => 'user', :action => 'lost_password' %>)
|
<%= end_form_tag %> (<%= link_to 'Lost your password?', :controller => 'user', :action => 'lost_password' %>)
|
||||||
|
|
7
app/views/user/rename.rhtml
Normal file
7
app/views/user/rename.rhtml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<h2>Display name:</h2>
|
||||||
|
|
||||||
|
<%= 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 %>
|
|
@ -1,3 +1,5 @@
|
||||||
|
/* this script when run on the current db migrates it to rails */
|
||||||
|
|
||||||
drop table meta_nodes;
|
drop table meta_nodes;
|
||||||
alter table current_nodes modify tags text not null;
|
alter table current_nodes modify tags text not null;
|
||||||
alter table current_nodes modify id bigint(64) not null auto_increment;
|
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 gpx_file_tags add id int(20) auto_increment not null, add primary key(id);
|
||||||
|
|
||||||
alter table users add preferences text;
|
alter table users add preferences text;
|
||||||
create index users_display_name_idx on users(display_name);
|
create index users_display_name_idx on users(display_name);
|
||||||
|
|
||||||
|
alter table users add public boolean default false;
|
||||||
|
|
||||||
|
|
|
@ -370,10 +370,10 @@ hides rule from IE5-Mac \*/
|
||||||
}
|
}
|
||||||
|
|
||||||
#notice {
|
#notice {
|
||||||
width: 400px;
|
border: 1px solid green;
|
||||||
border: 1px solid black;
|
|
||||||
padding: 7px;
|
padding: 7px;
|
||||||
background-color: #f0f0f0;
|
background-color: #f0fff0;
|
||||||
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#errorExplanation {
|
#errorExplanation {
|
||||||
|
|
Loading…
Add table
Reference in a new issue