Skip to content

Commit

Permalink
Use the anonymous account for news revisions
Browse files Browse the repository at this point in the history
  • Loading branch information
nono committed May 29, 2013
1 parent 32c6537 commit 7c9720a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions app/models/account.rb
Expand Up @@ -84,6 +84,10 @@ def create_user
self.user_id = User.create(:name => login).id
end

def self.anonymous
where(login: "Anonyme").first
end

### Password ###

before_validation :generate_a_password, :on => :create
Expand Down
10 changes: 5 additions & 5 deletions app/models/news.rb
Expand Up @@ -205,11 +205,11 @@ def announce_modification

after_save :create_new_version, :if => Proc.new { |news| news.body_changed? || news.second_part_changed? || news.title_changed? }
def create_new_version
v = versions.create(:user_id => (editor || author_account).try(:user_id),
:title => title,
:body => wiki_body,
:second_part => wiki_second_part,
:links => links.map(&:to_s).join("\n"))
v = versions.create(:user_id => (editor || author_account || Account.anonymous).try(:user_id),
:title => title,
:body => wiki_body,
:second_part => wiki_second_part,
:links => links.map(&:to_s).join("\n"))
Push.create(self, :kind => :revision, :id => v.id, :version => v.version, :message => v.message, :username => v.author_name)
end

Expand Down

0 comments on commit 7c9720a

Please sign in to comment.