end
##
- # delete a user, marking them as deleted and removing personal data
+ # destroy a user, marking them as deleted and removing personal data
def destroy
- @user.delete
+ @user.destroy
redirect_to user_path(:display_name => params[:display_name])
end
validates_email_format_of :email, :if => proc { |u| u.email_changed? }
validates_email_format_of :new_email, :allow_blank => true, :if => proc { |u| u.new_email_changed? }
- after_initialize :set_defaults
+ alias_attribute :created_at, :creation_time
+
before_save :encrypt_password
before_save :update_tile
after_save :spam_check
end
##
- # delete a user - leave the account but purge most personal data
- def delete
+ # destroy a user - leave the account but purge most personal data
+ def destroy
avatar.purge_later
self.display_name = "user_#{id}"
end
def max_messages_per_hour
- account_age_in_seconds = Time.now.utc - creation_time
+ account_age_in_seconds = Time.now.utc - created_at
account_age_in_hours = account_age_in_seconds / 3600
recent_messages = messages.where("sent_on >= ?", Time.now.utc - 3600).count
active_reports = issues.with_status(:open).sum(:reports_count)
end
def max_friends_per_hour
- account_age_in_seconds = Time.now.utc - creation_time
+ account_age_in_seconds = Time.now.utc - created_at
account_age_in_hours = account_age_in_seconds / 3600
recent_friends = Friendship.where(:befriendee => self).where("created_at >= ?", Time.now.utc - 3600).count
active_reports = issues.with_status(:open).sum(:reports_count)
private
- def set_defaults
- self.creation_time = Time.now.getutc unless attribute_present?(:creation_time)
- end
-
def encrypt_password
if pass_crypt_confirmation
self.pass_crypt, self.pass_salt = PasswordHash.create(pass_crypt)
json.user do
json.id user.id
json.display_name user.display_name
- json.account_created user.creation_time.xmlschema
+ json.account_created user.created_at.xmlschema
json.description user.description if user.description
if current_user && current_user == user && can?(:details, User)
xml.tag! "user", :id => user.id,
:display_name => user.display_name,
- :account_created => user.creation_time.xmlschema do
+ :account_created => user.created_at.xmlschema do
xml.tag! "description", user.description if user.description
if current_user && current_user == user && can?(:details, User)
xml.tag! "contributor-terms", :agreed => user.terms_agreed.present?,
<%= t "users.index.summary_html",
:name => link_to(user.display_name, user_path(user)),
:ip_address => link_to(user.creation_ip, :ip => user.creation_ip),
- :date => l(user.creation_time, :format => :friendly) %>
+ :date => l(user.created_at, :format => :friendly) %>
<% else %>
<%= t "users.index.summary_no_ip_html",
:name => link_to(user.display_name, user_path(user)),
- :date => l(user.creation_time, :format => :friendly) %>
+ :date => l(user.created_at, :format => :friendly) %>
<% end %>
</p>
<div class="richtext text-break"><%= user.description.to_html %></div>
<small>
<dl class="dl-inline">
<dt><%= t ".mapper since" %></dt>
- <dd><%= l @user.creation_time.to_date, :format => :long %></dd>
+ <dd><%= l @user.created_at.to_date, :format => :long %></dd>
<% unless @user.terms_agreed %>
<dt><%= t ".ct status" %></dt>
<dd>
assert_select "div.note-comments ul li", :count => 2
assert_select "div.details", /Resolved by #{user.display_name}/
- user.delete
+ user.destroy
reset!
assert create(:moderator_user).has_role?("moderator")
end
- def test_delete
+ def test_destroy
user = create(:user, :with_home_location, :description => "foo")
- user.delete
+ user.destroy
assert_equal "user_#{user.id}", user.display_name
assert user.description.blank?
assert_nil user.home_lat