diff options
author | francis <francis> | 2008-03-12 16:07:13 +0000 |
---|---|---|
committer | francis <francis> | 2008-03-12 16:07:13 +0000 |
commit | 938306b88df6c6734566ea7995bf92da9862efc4 (patch) | |
tree | fb33992562f3f1cff0f83e00207d7472b844f074 /app/models/user.rb | |
parent | facda1bfffb9d91da6a2f2e22b2345590e452f96 (diff) |
Make users all have their own URL, rather than sharing if they have the same name.
Diffstat (limited to 'app/models/user.rb')
-rw-r--r-- | app/models/user.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 547ae4225..14a1d63e3 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 39 +# Schema version: 41 # # Table name: users # @@ -20,7 +20,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: user.rb,v 1.34 2008-03-07 23:13:38 francis Exp $ +# $Id: user.rb,v 1.35 2008-03-12 16:07:13 francis Exp $ require 'digest/sha1' @@ -85,6 +85,13 @@ class User < ActiveRecord::Base end def update_url_name url_name = MySociety::Format.simplify_url_part(self.name) + if url_name.size > 32 + url_name = url_name[0..31] + end + # For request with same name as others, tag on the request numeric id + while not User.find_by_url_name(url_name, :conditions => ["id <> ?", self.id] ).nil? + url_name += "_" + self.id.to_s + end write_attribute(:url_name, url_name) end |