Commit 31340dc25f963c2535161d54aaf17a517542ea0d
- Date: Sat May 03 17:40:17 +0000 2008
- Committer: David A. Cuadrado (krawek@gmail.com)
- Author: David A. Cuadrado (krawek@gmail.com)
- Commit SHA1: 31340dc25f963c2535161d54aaf17a517542ea0d
- Tree SHA1: a125de159298edeeda088f5b95055e1dee29a3e8
Destroy events if associated project/user is deleted
Signed-off-by: David A. Cuadrado <krawek@gmail.com>
Commit diff
| |   |
| 86 | 86 | if @project.can_be_deleted_by?(current_user) |
| 87 | 87 | project_title = @project.title |
| 88 | 88 | @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 |
| 90 | 90 | else |
| 91 | 91 | flash[:error] = "You're not the owner of this project, or the project has clones" |
| 92 | 92 | end |
| toggle raw diff |
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -86,7 +86,7 @@ class ProjectsController < ApplicationController
if @project.can_be_deleted_by?(current_user)
project_title = @project.title
@project.destroy
- #current_user.create_event(Action::DELETE_PROJECT, nil, project_title)
+# Event.create(:action => Action::DELETE_PROJECT, :user => current_user, :data => project_title) # FIXME: project_id cannot be null
else
flash[:error] = "You're not the owner of this project, or the project has clones"
end |
| |   |
| 9 | 9 | :class_name => "Repository" |
| 10 | 10 | has_many :repository_clones, :conditions => ["mainline = ?", false], |
| 11 | 11 | :class_name => "Repository" |
| 12 | | has_many :events, :order => "created_at asc" |
| 12 | has_many :events, :order => "created_at asc", :dependent => :destroy |
| 13 | 13 | |
| 14 | 14 | is_indexed :fields => ["title", "description", "slug"], |
| 15 | 15 | :concatenate => [ |
| toggle raw diff |
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -9,7 +9,7 @@ class Project < ActiveRecord::Base
:class_name => "Repository"
has_many :repository_clones, :conditions => ["mainline = ?", false],
:class_name => "Repository"
- has_many :events, :order => "created_at asc"
+ has_many :events, :order => "created_at asc", :dependent => :destroy
is_indexed :fields => ["title", "description", "slug"],
:concatenate => [ |
| |   |
| 6 | 6 | has_many :repositories, :through => :committerships |
| 7 | 7 | has_many :ssh_keys, :order => "id desc" |
| 8 | 8 | has_many :comments |
| 9 | | has_many :events, :order => "events.created_at asc" |
| 9 | has_many :events, :order => "events.created_at asc", :dependent => :destroy |
| 10 | 10 | |
| 11 | 11 | # Virtual attribute for the unencrypted password |
| 12 | 12 | attr_accessor :password, :current_password |
| toggle raw diff |
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -6,7 +6,7 @@ class User < ActiveRecord::Base
has_many :repositories, :through => :committerships
has_many :ssh_keys, :order => "id desc"
has_many :comments
- has_many :events, :order => "events.created_at asc"
+ has_many :events, :order => "events.created_at asc", :dependent => :destroy
# Virtual attribute for the unencrypted password
attr_accessor :password, :current_password |