Commit 31340dc25f963c2535161d54aaf17a517542ea0d

Destroy events if associated project/user is deleted

Signed-off-by: David A. Cuadrado <krawek@gmail.com>

Commit diff

app/controllers/projects_controller.rb

 
8686 if @project.can_be_deleted_by?(current_user)
8787 project_title = @project.title
8888 @project.destroy
89 #current_user.create_event(Action::DELETE_PROJECT, nil, project_title)
89# Event.create(:action => Action::DELETE_PROJECT, :user => current_user, :data => project_title) # FIXME: project_id cannot be null
9090 else
9191 flash[:error] = "You're not the owner of this project, or the project has clones"
9292 end
toggle raw diff

app/models/project.rb

 
99 :class_name => "Repository"
1010 has_many :repository_clones, :conditions => ["mainline = ?", false],
1111 :class_name => "Repository"
12 has_many :events, :order => "created_at asc"
12 has_many :events, :order => "created_at asc", :dependent => :destroy
1313
1414 is_indexed :fields => ["title", "description", "slug"],
1515 :concatenate => [
toggle raw diff

app/models/user.rb

 
66 has_many :repositories, :through => :committerships
77 has_many :ssh_keys, :order => "id desc"
88 has_many :comments
9 has_many :events, :order => "events.created_at asc"
9 has_many :events, :order => "events.created_at asc", :dependent => :destroy
1010
1111 # Virtual attribute for the unencrypted password
1212 attr_accessor :password, :current_password
toggle raw diff