Skip to content
Browse files

First pass at deeper Ido-event integration

  • Loading branch information...
1 parent 10e88cb commit 472c6372d475eb22af774194cc854a0792221fef @sgrove sgrove committed Mar 18, 2012
View
7 db/migrate/20120318053922_add_ido_id_to_models.rb
@@ -0,0 +1,7 @@
+class AddIdoIdToModels < ActiveRecord::Migration
+ def change
+ add_column :notes, :ido_id, :string
+ add_column :projects, :ido_id, :string
+ add_column :stories, :ido_id, :string
+ end
+end
View
2 lib/bushido/bushido_bootstrap.rb
@@ -13,6 +13,8 @@ def self.extend_user!
validates_presence_of :ido_id
validates_uniqueness_of :ido_id
+ attr_accessible :ido_id
+
after_create :add_all_projects!
before_destroy :remove_all_projects!
end
View
20 lib/bushido/bushido_hooks/note_hooks.rb
@@ -0,0 +1,20 @@
+class ProjectNoteHooks < Bushido::EventObserver
+ def project_task_note_created
+ data = params['data']
+
+ note = Note.find_by_ido_id(data['ido_id'])
+ note ||= Note.new
+
+ # Just in case
+ note.ido_id ||= data['ido_id']
+ note.note = data['note']
+ note.user = User.find_by_ido_id( data['author_id'] )
+ note.story = Story.find_by_ido_id( data['story_id'] )
+
+ note.save
+ end
+
+ def project_task_note_imported
+ project_task_note_created
+ end
+end
View
23 lib/bushido/bushido_hooks/project_hooks.rb
@@ -0,0 +1,23 @@
+class ProjectHooks < Bushido::EventObserver
+ def project_created
+ puts params.inspect
+ puts "prarm"
+ data = params['data']
+
+ project = Project.find_by_ido_id(data['ido_id'])
+ project ||= Project.new
+
+ # Just in case
+ project.ido_id ||= data['ido_id']
+ project.name = data['name']
+ project.point_scale = 'linear' || data['point_scale'] # TODO: Put in a reverse lookup
+ project.iteration_start_day = data['iteration_start_day']
+ project.iteration_length = data['iteration_length']
+
+ project.save!
+ end
+
+ def project_imported
+ project_created
+ end
+end
View
27 lib/bushido/bushido_hooks/story_hooks.rb
@@ -0,0 +1,27 @@
+class ProjectStoryHooks < Bushido::EventObserver
+ def project_task_created
+ data = params['data']
+
+ story = Story.find_by_ido_id(data['ido_id'])
+ story ||= Story.new
+
+ # Just in case
+ story.ido_id ||= data['ido_id']
+ story.title = data['title']
+ story.description = data['description']
+ story.estimate = data['estimate']
+ story.story_type = data['task_type']
+ story.state = data['state']
+ story.accepted_at = data['accepted_at']
+ story.requested_by_id = User.find_by_ido_id(data['requested_by_id'])
+ story.owned_by_id = User.find_by_ido_id(data['owned_by_id'])
+ story.project = Project.find_by_ido_id(data['project_id'])
+ story.labels = data['labels']
+
+ story.save
+ end
+
+ def project_task_imported
+ project_task_created
+ end
+end

0 comments on commit 472c637

Please sign in to comment.
Something went wrong with that request. Please try again.