Skip to content

Commit

Permalink
Set created_by in wiki pages, and log actions in project
Browse files Browse the repository at this point in the history
Signed-off-by: James Urquhart <[email protected]>
  • Loading branch information
Sergio authored and jamesu committed Jul 16, 2009
1 parent d022f42 commit a88e349
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/controllers/wiki_pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@ class WikiPagesController < ApplicationController
layout 'project_website'

before_filter :process_session
before_filter :set_created_by, :only => [:create, :update]
after_filter :user_track, :only => [:index, :show]

include WikiEngine::Controller

protected
def set_created_by
params[:wiki_page][:created_by] = @logged_user
end

def wiki_pages
@active_project.wiki_pages
end
Expand Down
16 changes: 16 additions & 0 deletions app/models/wiki_page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@ class WikiPage < ActiveRecord::Base
self.non_versioned_columns << :project_id
named_scope :main, lambda{ |project| {:conditions => {:main => true, :project_id => project.id}} }

after_create :process_create
before_update :process_update_params
before_destroy :process_destroy

def process_create
ApplicationLog.new_log(self, self.created_by, :add)
end

def process_update_params
ApplicationLog.new_log(self, self.created_by, :edit)
end

def process_destroy
ApplicationLog.new_log(self, self.created_by, :delete)
end

def object_name
self.title
end
Expand Down
2 changes: 1 addition & 1 deletion lib/wiki_engine/user_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ def user
end

def user_name
self.user ? user.name : 'anonymous'
self.user ? user.display_name : 'anonymous'
end
end

0 comments on commit a88e349

Please sign in to comment.