backlog 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. data/History.txt +10 -0
  2. data/Rakefile +2 -1
  3. data/app/controllers/application.rb +55 -8
  4. data/app/controllers/groups_controller.rb +62 -0
  5. data/app/controllers/periods_controller.rb +13 -55
  6. data/app/controllers/tasks_controller.rb +9 -5
  7. data/app/controllers/works_controller.rb +43 -6
  8. data/app/helpers/application_helper.rb +20 -2
  9. data/app/helpers/groups_helper.rb +2 -0
  10. data/app/models/backlog.rb +19 -10
  11. data/app/models/estimate.rb +2 -1
  12. data/app/models/group.rb +11 -0
  13. data/app/models/party.rb +3 -0
  14. data/app/models/period.rb +43 -6
  15. data/app/models/task.rb +27 -14
  16. data/app/models/user.rb +37 -8
  17. data/app/models/work.rb +4 -6
  18. data/app/views/backlogs/_name_list.rhtml +5 -0
  19. data/app/views/backlogs/show.rhtml +4 -4
  20. data/app/views/groups/_form.rhtml +7 -0
  21. data/app/views/groups/edit.rhtml +31 -0
  22. data/app/views/groups/list.rhtml +27 -0
  23. data/app/views/groups/new.rhtml +8 -0
  24. data/app/views/layouts/wide.rhtml +2 -2
  25. data/app/views/periods/_burn_down_chart.rhtml +1 -1
  26. data/app/views/periods/_form.rhtml +13 -9
  27. data/app/views/periods/_show_active.rhtml +6 -12
  28. data/app/views/periods/_title.rhtml +4 -5
  29. data/app/views/periods/edit.rhtml +1 -1
  30. data/app/views/periods/new.rhtml +1 -1
  31. data/app/views/periods/show.rhtml +10 -6
  32. data/app/views/tasks/_backlog_header.rhtml +22 -0
  33. data/app/views/tasks/_description_list.rhtml +5 -0
  34. data/app/views/tasks/_form.rhtml +26 -7
  35. data/app/views/tasks/_task.rhtml +4 -4
  36. data/app/views/tasks/edit.rhtml +2 -3
  37. data/app/views/tasks/list_started.rhtml +1 -0
  38. data/app/views/tasks/new.rhtml +2 -2
  39. data/app/views/works/_buttons.rhtml +3 -0
  40. data/app/views/works/_form.rhtml +15 -10
  41. data/app/views/works/daily_work_sheet.rhtml +30 -18
  42. data/app/views/works/edit.rhtml +4 -4
  43. data/app/views/works/list.rhtml +2 -2
  44. data/app/views/works/new.rhtml +3 -2
  45. data/app/views/works/weekly_work_sheet.rhtml +2 -2
  46. data/bin/backlog +2 -0
  47. data/bin/backlog_init.d_kubosch_production +27 -0
  48. data/bin/copy_production2development.rb +33 -0
  49. data/config/database.yml +13 -7
  50. data/config/deploy_kubosch.rb +1 -0
  51. data/config/environment.rb +2 -0
  52. data/config/environments/development_mysql.rb +27 -0
  53. data/config/environments/kubosch_production_mysql.rb +21 -0
  54. data/config/routes.rb +1 -1
  55. data/db/migrate/{001_tasks.rb → 001_create_tasks.rb} +1 -1
  56. data/db/migrate/{002_backlogs.rb → 002_create_backlogs.rb} +2 -2
  57. data/db/migrate/003_add_estimation_points.rb +1 -1
  58. data/db/migrate/004_add_period.rb +2 -2
  59. data/db/migrate/013_create_estimates.rb +1 -1
  60. data/db/migrate/015_add_user_option.rb +9 -5
  61. data/db/migrate/017_insert_datek_projects.rb +13 -10
  62. data/db/migrate/018_create_groups.rb +115 -0
  63. data/db/schema.rb +72 -12
  64. data/lang/en.yaml +7 -0
  65. data/lang/no.yaml +7 -0
  66. data/lib/big_decimal_yaml_fix.rb +27 -0
  67. data/lib/class_table_inheritance.rb +163 -0
  68. data/lib/tasks/backup.rake +92 -0
  69. data/public/images/person.org.png +0 -0
  70. data/public/images/person.png +0 -0
  71. data/public/stylesheets/backlog.css +3 -1
  72. data/public/stylesheets/mwrt002.css +1 -1
  73. data/test/fixtures/groups.yml +6 -0
  74. data/test/fixtures/parties.yml +31 -0
  75. data/test/fixtures/periods.yml +2 -2
  76. data/test/fixtures/tasks.yml +2 -0
  77. data/test/fixtures/users.yml +6 -6
  78. data/test/functional/backlogs_controller_test.rb +1 -1
  79. data/test/functional/groups_controller_test.rb +120 -0
  80. data/test/functional/periods_controller_test.rb +1 -1
  81. data/test/functional/tasks_controller_test.rb +16 -1
  82. data/test/functional/user_controller_test.rb +8 -2
  83. data/test/test_helper.rb +5 -0
  84. data/test/unit/big_decimal_yaml_fix_test.rb +14 -0
  85. data/test/unit/estimate_test.rb +1 -1
  86. data/test/unit/group_test.rb +10 -0
  87. data/test/unit/user_test.rb +56 -44
  88. data/tmp/sessions/ruby_sess.22dec3e9df47fb4e +0 -0
  89. data/tmp/sessions/ruby_sess.8037e0ab58cbcf1a +0 -0
  90. data/vendor/plugins/activerecord_foreign_key_extensions/lib/active_record_extensions.rb +35 -0
  91. data/vendor/rails/actionmailer/test/fixtures/test_mailer/implicitly_multipart_example.rhtml.bak +1 -0
  92. data/vendor/rails/{actionwebservice/lib/action_web_service/templates/scaffolds/layout.rhtml → railties/configs/empty.log} +0 -0
  93. metadata +36 -105
  94. data/backlog.gemspec +0 -21
  95. data/vendor/rails/actionwebservice/CHANGELOG +0 -265
  96. data/vendor/rails/actionwebservice/MIT-LICENSE +0 -21
  97. data/vendor/rails/actionwebservice/README +0 -364
  98. data/vendor/rails/actionwebservice/Rakefile +0 -171
  99. data/vendor/rails/actionwebservice/TODO +0 -32
  100. data/vendor/rails/actionwebservice/examples/googlesearch/README +0 -143
  101. data/vendor/rails/actionwebservice/examples/googlesearch/autoloading/google_search_api.rb +0 -50
  102. data/vendor/rails/actionwebservice/examples/googlesearch/autoloading/google_search_controller.rb +0 -57
  103. data/vendor/rails/actionwebservice/examples/googlesearch/delegated/google_search_service.rb +0 -108
  104. data/vendor/rails/actionwebservice/examples/googlesearch/delegated/search_controller.rb +0 -7
  105. data/vendor/rails/actionwebservice/examples/googlesearch/direct/google_search_api.rb +0 -50
  106. data/vendor/rails/actionwebservice/examples/googlesearch/direct/search_controller.rb +0 -58
  107. data/vendor/rails/actionwebservice/examples/metaWeblog/README +0 -17
  108. data/vendor/rails/actionwebservice/examples/metaWeblog/apis/blogger_api.rb +0 -60
  109. data/vendor/rails/actionwebservice/examples/metaWeblog/apis/blogger_service.rb +0 -34
  110. data/vendor/rails/actionwebservice/examples/metaWeblog/apis/meta_weblog_api.rb +0 -67
  111. data/vendor/rails/actionwebservice/examples/metaWeblog/apis/meta_weblog_service.rb +0 -48
  112. data/vendor/rails/actionwebservice/examples/metaWeblog/controllers/xmlrpc_controller.rb +0 -16
  113. data/vendor/rails/actionwebservice/install.rb +0 -30
  114. data/vendor/rails/actionwebservice/lib/action_web_service.rb +0 -66
  115. data/vendor/rails/actionwebservice/lib/action_web_service/api.rb +0 -301
  116. data/vendor/rails/actionwebservice/lib/action_web_service/base.rb +0 -42
  117. data/vendor/rails/actionwebservice/lib/action_web_service/casting.rb +0 -138
  118. data/vendor/rails/actionwebservice/lib/action_web_service/client.rb +0 -3
  119. data/vendor/rails/actionwebservice/lib/action_web_service/client/base.rb +0 -28
  120. data/vendor/rails/actionwebservice/lib/action_web_service/client/soap_client.rb +0 -113
  121. data/vendor/rails/actionwebservice/lib/action_web_service/client/xmlrpc_client.rb +0 -58
  122. data/vendor/rails/actionwebservice/lib/action_web_service/container.rb +0 -3
  123. data/vendor/rails/actionwebservice/lib/action_web_service/container/action_controller_container.rb +0 -93
  124. data/vendor/rails/actionwebservice/lib/action_web_service/container/delegated_container.rb +0 -86
  125. data/vendor/rails/actionwebservice/lib/action_web_service/container/direct_container.rb +0 -69
  126. data/vendor/rails/actionwebservice/lib/action_web_service/dispatcher.rb +0 -2
  127. data/vendor/rails/actionwebservice/lib/action_web_service/dispatcher/abstract.rb +0 -207
  128. data/vendor/rails/actionwebservice/lib/action_web_service/dispatcher/action_controller_dispatcher.rb +0 -379
  129. data/vendor/rails/actionwebservice/lib/action_web_service/invocation.rb +0 -202
  130. data/vendor/rails/actionwebservice/lib/action_web_service/protocol.rb +0 -4
  131. data/vendor/rails/actionwebservice/lib/action_web_service/protocol/abstract.rb +0 -112
  132. data/vendor/rails/actionwebservice/lib/action_web_service/protocol/discovery.rb +0 -37
  133. data/vendor/rails/actionwebservice/lib/action_web_service/protocol/soap_protocol.rb +0 -176
  134. data/vendor/rails/actionwebservice/lib/action_web_service/protocol/soap_protocol/marshaler.rb +0 -235
  135. data/vendor/rails/actionwebservice/lib/action_web_service/protocol/xmlrpc_protocol.rb +0 -122
  136. data/vendor/rails/actionwebservice/lib/action_web_service/scaffolding.rb +0 -283
  137. data/vendor/rails/actionwebservice/lib/action_web_service/struct.rb +0 -68
  138. data/vendor/rails/actionwebservice/lib/action_web_service/support/class_inheritable_options.rb +0 -26
  139. data/vendor/rails/actionwebservice/lib/action_web_service/support/signature_types.rb +0 -226
  140. data/vendor/rails/actionwebservice/lib/action_web_service/templates/scaffolds/layout.erb +0 -65
  141. data/vendor/rails/actionwebservice/lib/action_web_service/templates/scaffolds/methods.erb +0 -6
  142. data/vendor/rails/actionwebservice/lib/action_web_service/templates/scaffolds/methods.rhtml +0 -0
  143. data/vendor/rails/actionwebservice/lib/action_web_service/templates/scaffolds/parameters.erb +0 -29
  144. data/vendor/rails/actionwebservice/lib/action_web_service/templates/scaffolds/parameters.rhtml +0 -0
  145. data/vendor/rails/actionwebservice/lib/action_web_service/templates/scaffolds/result.erb +0 -30
  146. data/vendor/rails/actionwebservice/lib/action_web_service/templates/scaffolds/result.rhtml +0 -0
  147. data/vendor/rails/actionwebservice/lib/action_web_service/test_invoke.rb +0 -110
  148. data/vendor/rails/actionwebservice/lib/action_web_service/version.rb +0 -9
  149. data/vendor/rails/actionwebservice/setup.rb +0 -1379
  150. data/vendor/rails/actionwebservice/test/abstract_client.rb +0 -183
  151. data/vendor/rails/actionwebservice/test/abstract_dispatcher.rb +0 -551
  152. data/vendor/rails/actionwebservice/test/abstract_unit.rb +0 -45
  153. data/vendor/rails/actionwebservice/test/api_test.rb +0 -102
  154. data/vendor/rails/actionwebservice/test/apis/auto_load_api.rb +0 -3
  155. data/vendor/rails/actionwebservice/test/apis/broken_auto_load_api.rb +0 -2
  156. data/vendor/rails/actionwebservice/test/base_test.rb +0 -42
  157. data/vendor/rails/actionwebservice/test/casting_test.rb +0 -86
  158. data/vendor/rails/actionwebservice/test/client_soap_test.rb +0 -153
  159. data/vendor/rails/actionwebservice/test/client_xmlrpc_test.rb +0 -152
  160. data/vendor/rails/actionwebservice/test/container_test.rb +0 -73
  161. data/vendor/rails/actionwebservice/test/dispatcher_action_controller_soap_test.rb +0 -137
  162. data/vendor/rails/actionwebservice/test/dispatcher_action_controller_xmlrpc_test.rb +0 -59
  163. data/vendor/rails/actionwebservice/test/fixtures/db_definitions/mysql.sql +0 -8
  164. data/vendor/rails/actionwebservice/test/fixtures/users.yml +0 -12
  165. data/vendor/rails/actionwebservice/test/gencov +0 -3
  166. data/vendor/rails/actionwebservice/test/invocation_test.rb +0 -185
  167. data/vendor/rails/actionwebservice/test/run +0 -6
  168. data/vendor/rails/actionwebservice/test/scaffolded_controller_test.rb +0 -146
  169. data/vendor/rails/actionwebservice/test/struct_test.rb +0 -52
  170. data/vendor/rails/actionwebservice/test/test_invoke_test.rb +0 -112
@@ -1,11 +1,11 @@
1
1
  <div id="spotlight">
2
- <% @page_title = :edit_work %>
2
+ <% @page_title = "#{l :editing} #{:work}" %>
3
3
 
4
4
  <% form_tag :action => 'update', :id => @work do %>
5
+ <%= submit_tag l(:save), :style => 'display: none' %>
5
6
  <%= render :partial => 'form' %>
6
- <%= submit_tag 'Edit' %>
7
+ <%= submit_tag l(:save) %>
8
+ <%= link_to l(:back), :controller => 'periods', :action => 'list_work', :id => @work.task.period %>
7
9
  <% end %>
8
10
 
9
- <%= link_to 'Show', :action => 'show', :id => @work %> |
10
- <%= link_to 'Back', :controller => 'periods', :action => 'list_work', :id => @work.task.period %>
11
11
  </div>
@@ -8,7 +8,7 @@
8
8
  <th><%=l :task %></th>
9
9
  <th><%=l :user %></th>
10
10
  <th><%=l :done %></th>
11
- <% if @period && @period.backlog.track_times? %>
11
+ <% if @period && @period.track_times? %>
12
12
  <th><%=l :started_at %></th>
13
13
  <% end %>
14
14
  <th><%=l :completed_at %></th>
@@ -19,7 +19,7 @@
19
19
  <td><%=work.task.description %></td>
20
20
  <td><%=work.user && work.user.login %></td>
21
21
  <td><%=work.hours %></td>
22
- <% if @period && @period.backlog.track_times? %>
22
+ <% if @period && @period.track_times? %>
23
23
  <td><%=work.started_at && work.started_at.strftime('%Y-%m-%d %H:%M:%S') %></td>
24
24
  <% end %>
25
25
  <td><%=work.completed_at && work.completed_at.strftime('%Y-%m-%d %H:%M:%S') %></td>
@@ -3,9 +3,10 @@
3
3
  <div id="spotlight">
4
4
 
5
5
  <% form_tag :action => 'create' do %>
6
+ <%= submit_tag l(:save), :style => 'display: none' %>
6
7
  <%= render :partial => 'form' %>
7
- <%= submit_tag "Create" %>
8
+ <%= submit_tag l(:save) %>
9
+ <%= link_to l(:back), :action => 'list' %>
8
10
  <% end %>
9
11
 
10
- <%= link_to 'Back', :action => 'list' %>
11
12
  </div>
@@ -1,8 +1,8 @@
1
1
  <% @page_title = l(:weekly_work_sheet) + (@period ? " for #{@period}" : '') + (user? ? " for #{user.login}" : '')%>
2
2
 
3
3
  <div id="spotlight">
4
- <% track_times = @rows.find {|r| r.find {|w| w && w.task.period.backlog.track_times?}} %>
5
- <% invoicing = @rows.find {|r| r.find {|w| w && w.task.period.backlog.enable_invoicing?}} %>
4
+ <% track_times = @rows.find {|r| r.find {|w| w && w.task.backlog.track_times?}} %>
5
+ <% invoicing = @rows.find {|r| r.find {|w| w && w.task.backlog.enable_invoicing?}} %>
6
6
  <% columns = 2 + (track_times ? 2 : 0) + (invoicing ? 1 : 0) %>
7
7
 
8
8
  <h1>Work for week <%=@week%><%=user? ? " for #{user.login}" : ''%></h1>
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/ruby -w
2
2
  #
3
3
  # backlog Startup script for the backlog application
4
+ #
5
+ # chkconfig: 345 88 12
4
6
  # description: Backlog
5
7
 
6
8
  require 'rubygems'
@@ -0,0 +1,27 @@
1
+ #!/bin/bash
2
+ #
3
+ # backlog Startup script for the backlog application
4
+ #
5
+ # chkconfig: 345 88 12
6
+ # description: Backlog
7
+
8
+ # See how we were called.
9
+ case "$1" in
10
+ start)
11
+ mongrel_rails start -p 3000 -e production -c /u/apps/backlog/current -d -m /u/apps/backlog/current/config/mime_types.yaml 1>/u/apps/backlog/current/log/stdout.log 2>/u/apps/backlog/current/log/stderr.log
12
+ ;;
13
+ stop)
14
+ mongrel_rails stop -c /u/apps/backlog/current
15
+ ;;
16
+ restart)
17
+ mongrel_rails restart -c /u/apps/backlog/current
18
+ ;;
19
+ status)
20
+ ps -ef | grep backlog
21
+ ;;
22
+ *)
23
+ echo $"Usage: $prog {start|stop|restart|status}"
24
+ exit 1
25
+ esac
26
+
27
+ exit 0
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/ruby -w
2
+
3
+ require 'config/boot'
4
+ require "active_record"
5
+
6
+ alias :old_exec :`
7
+
8
+ def `(cmd)
9
+ puts old_exec(cmd)
10
+ raise "Command returned #{$?} #{$? >> 8}" unless $? == 0
11
+ end
12
+
13
+ `dropdb backlog_development`
14
+ `createdb backlog_development`
15
+
16
+ ENV['RAILS_ENV'] = 'kubosch_production_mysql'
17
+ `rake db:schema:dump`
18
+ if ActiveRecord::Base.connection.adapter_name.downcase == 'mysql'
19
+ lines = File.readlines('db/schema.rb')
20
+ File.open('db/schema.rb', 'w') do |file|
21
+ lines.each do |line|
22
+ line.gsub!(/, :name => "\w+_id"/, '')
23
+ file << line
24
+ end
25
+ end
26
+ end
27
+
28
+ `rake db:backup:write`
29
+
30
+ ENV['RAILS_ENV'] = 'development'
31
+ `rake db:backup:read`
32
+ `rake db:backup:set_sequences`
33
+ `rake db:migrate`
@@ -5,6 +5,13 @@ development:
5
5
  # password:
6
6
  host: localhost
7
7
 
8
+ development_mysql:
9
+ adapter: mysql
10
+ database: backlog_development
11
+ username: root
12
+ password: mithrandir
13
+ host: localhost
14
+
8
15
  # Warning: The database defined as 'test' will be erased and
9
16
  # re-generated from your development database when you run 'rake'.
10
17
  # Do not set this db to the same as development or production.
@@ -15,19 +22,18 @@ test:
15
22
  # password:
16
23
  host: localhost
17
24
 
18
- production:
25
+ kubosch_production:
19
26
  adapter: postgresql
20
27
  database: backlog_production
21
- username: postgres
22
- # password:
28
+ username: donv
23
29
  host: localhost
24
30
 
25
- kubosch_production:
31
+ kubosch_production_mysql:
26
32
  adapter: mysql
27
33
  database: backlog_development
28
- username:
29
- password:
30
- host: kubosch.no
34
+ username: root
35
+ password: mithrandir
36
+ host: localhost
31
37
 
32
38
  datek_production:
33
39
  adapter: postgresql
@@ -1,5 +1,6 @@
1
1
  set :application, "backlog"
2
2
  set :repository, "svn://rubyforge.org/var/svn/#{application}/trunk"
3
+ set :rails_env, :kubosch_production
3
4
 
4
5
  role :web, "www.kubosch.no"
5
6
  role :app, "www.kubosch.no"
@@ -61,3 +61,5 @@ require 'gruff'
61
61
  #Mime::Type.register "image/svg", :svg
62
62
  require 'environments/user_environment'
63
63
  require 'array_helper'
64
+ require 'big_decimal_yaml_fix'
65
+ require 'class_table_inheritance'
@@ -0,0 +1,27 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # In the development environment your application's code is reloaded on
4
+ # every request. This slows down response time but is perfect for development
5
+ # since you don't have to restart the webserver when you make code changes.
6
+ config.cache_classes = false
7
+
8
+ # Log error messages when you accidentally call methods on nil.
9
+ config.whiny_nils = true
10
+
11
+ # Show full error reports and disable caching
12
+ config.action_controller.consider_all_requests_local = true
13
+ config.action_controller.perform_caching = false
14
+ config.action_view.cache_template_extensions = false
15
+ config.action_view.debug_rjs = true
16
+
17
+ # Raise exceptions when mailer fails
18
+ config.action_mailer.raise_delivery_errors = true
19
+
20
+ #ActionMailer::Base.delivery_method = :sendmail
21
+ ActionMailer::Base.delivery_method = :smtp
22
+
23
+ ActionMailer::Base.smtp_settings = {
24
+ :address => "mail.datek.no",
25
+ :port => 25
26
+ }
27
+
@@ -0,0 +1,21 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # The production environment is meant for finished, "live" apps.
4
+ # Code is not reloaded between requests
5
+ config.cache_classes = true
6
+
7
+ # Use a different logger for distributed setups
8
+ # config.logger = SyslogLogger.new
9
+
10
+ # Full error reports are disabled and caching is turned on
11
+ config.action_controller.consider_all_requests_local = false
12
+ config.action_controller.perform_caching = true
13
+
14
+ # Enable serving of images, stylesheets, and javascripts from an asset server
15
+ # config.action_controller.asset_host = "http://assets.example.com"
16
+
17
+ # Disable delivery errors if you bad email addresses should just be ignored
18
+ config.action_mailer.raise_delivery_errors = false
19
+
20
+ ActionMailer::Base.delivery_method = :sendmail
21
+
@@ -1,5 +1,5 @@
1
1
  ActionController::Routing::Routes.draw do |map|
2
2
  map.connect '', :controller => "backlogs"
3
- map.connect ':controller/:action/:id.:extension'
3
+ map.connect ':controller/:action/:id.:format'
4
4
  map.connect ':controller/:action/:id'
5
5
  end
@@ -1,4 +1,4 @@
1
- class Tasks < ActiveRecord::Migration
1
+ class CreateTasks < ActiveRecord::Migration
2
2
  def self.up
3
3
  create_table :tasks do |table|
4
4
  table.column :position, :integer, :null => true
@@ -1,9 +1,9 @@
1
- class Backlogs < ActiveRecord::Migration
1
+ class CreateBacklogs < ActiveRecord::Migration
2
2
  def self.up
3
3
  create_table :backlogs do |table|
4
4
  table.column :name, :string, :limit => 32, :null => false
5
5
  end
6
- execute "INSERT INTO backlogs (id,name) VALUES (1,'Default Backlog')"
6
+ execute "INSERT INTO backlogs (name) VALUES ('Default Backlog')"
7
7
  add_column :tasks, :backlog_id, :integer, :null => false, :default => 1
8
8
  end
9
9
 
@@ -10,7 +10,7 @@ class AddEstimationPoints < ActiveRecord::Migration
10
10
  end
11
11
 
12
12
  def self.down
13
- drop_table :works
14
13
  remove_column :tasks, :initial_estimate
14
+ drop_table :works
15
15
  end
16
16
  end
@@ -33,8 +33,8 @@ class AddPeriod < ActiveRecord::Migration
33
33
  def self.down
34
34
  add_column :tasks, :backlog_id, :integer
35
35
  Task.find(:all).each do |task|
36
- task.backlog_id = task.root_task.period.backlog.id
37
- task.save
36
+ task.backlog_id = task.root_task.period.backlog_id
37
+ task.save!
38
38
  end
39
39
  remove_column :tasks, :period_id
40
40
  drop_table :periods
@@ -13,7 +13,7 @@ class CreateEstimates < ActiveRecord::Migration
13
13
 
14
14
  def self.down
15
15
  add_column :works, "todo", :decimal, :precision => 6, :scale => 2, :default => 1.0, :null => true
16
- execute("UPDATE works SET todo = (SELECT todo FROM estimates e1 WHERE e1.task_id = works.task_id AND e1.created_at <= works.completed_at AND NOT EXISTS (SELECT completed_at FROM estimates e2 where e2.task_id = works.task_id AND e2.created_at <= works.completed_at AND e2.created_at > e1.created_at))")
16
+ execute("UPDATE works SET todo = (SELECT todo FROM estimates e1 WHERE e1.task_id = works.task_id AND e1.created_at <= works.completed_at AND NOT EXISTS (SELECT completed_at FROM estimates e2 where e2.task_id = works.task_id AND (e2.created_at > e1.created_at OR (e2.id > e1.id AND e2.created_at = e1.created_at)) ))")
17
17
  change_column :works, "todo", :decimal, :precision => 6, :scale => 2, :default => 1.0, :null => false
18
18
  drop_table :estimates
19
19
  end
@@ -3,7 +3,7 @@ class AddUserOption < ActiveRecord::Migration
3
3
  add_column :backlogs, :enable_users, :boolean
4
4
  add_column :estimates, :user_id, :integer, :references => :users
5
5
  add_column :works, :user_id, :integer, :references => :users
6
- change_column_null :works, :completed_at, true
6
+ change_column_null :works, :completed_at, :timestamp, true
7
7
  started_tasks = Task.find(:all, :conditions => 'work_started_at IS NOT NULL')
8
8
  started_tasks.each do |task|
9
9
  started_work = Work.new(:task_id => task.id, :started_at => task.work_started_at)
@@ -21,17 +21,21 @@ class AddUserOption < ActiveRecord::Migration
21
21
  task.save!
22
22
  work.destroy
23
23
  end
24
- change_column_null :works, :completed_at, false
24
+ change_column_null :works, :completed_at, :timestamp, false
25
25
  remove_column :works, :user_id
26
26
  remove_column :estimates, :user_id
27
27
  remove_column :backlogs, :enable_users
28
28
  end
29
29
 
30
- def self.change_column_null(table_name, column_name, null, default = nil) #:nodoc:
30
+ def self.change_column_null(table_name, column_name, column_type, null, default = nil) #:nodoc:
31
31
  unless null || default.nil?
32
32
  execute("UPDATE #{table_name} SET #{column_name}=#{quote(default)} WHERE #{column_name} IS NULL")
33
- end
34
- execute("ALTER TABLE #{table_name} ALTER #{column_name} #{null ? 'DROP' : 'SET'} NOT NULL")
33
+ end
34
+ if ActiveRecord::Base.connection.adapter_name.downcase == "postgresql"
35
+ execute("ALTER TABLE #{table_name} ALTER #{column_name} #{null ? 'DROP' : 'SET'} NOT NULL")
36
+ elsif ActiveRecord::Base.connection.adapter_name.downcase == "mysql"
37
+ execute("ALTER TABLE #{table_name} MODIFY COLUMN #{column_name} #{column_type} #{null ? 'NULL' : 'NOT NULL'}")
38
+ end
35
39
  end
36
40
 
37
41
  end
@@ -1,7 +1,7 @@
1
1
  class InsertDatekProjects < ActiveRecord::Migration
2
2
  def self.up
3
3
  change_column :backlogs, :name, :string, :limit => 64, :null => false
4
-
4
+
5
5
  if RAILS_ENV =~ /datek|development/
6
6
  projects = {
7
7
  1 => 'Viderefakturering SCR',
@@ -50,6 +50,8 @@ class InsertDatekProjects < ActiveRecord::Migration
50
50
  80 => 'Transportsentralen Lillestrøm',
51
51
  81 => 'GFS',
52
52
  }
53
+ Backlog.reset_column_information
54
+
53
55
  projects.each do |invoice_code, name|
54
56
  if backlog = Backlog.find_by_invoice_code(invoice_code)
55
57
  if backlog.invoice_code.nil? || backlog.invoice_code.length >= 31
@@ -58,7 +60,7 @@ class InsertDatekProjects < ActiveRecord::Migration
58
60
  backlog.save!
59
61
  end
60
62
  else
61
- puts "Added Mamut project #{invoice_code} #{name}"
63
+ puts "Adding Mamut project #{invoice_code} #{name}"
62
64
  Backlog.new(:invoice_code => invoice_code, :name => name).save!
63
65
  end
64
66
  end
@@ -83,13 +85,14 @@ class InsertDatekProjects < ActiveRecord::Migration
83
85
  execute "UPDATE backlogs SET name = SUBSTR(name, 0, 33)"
84
86
  change_column :backlogs, :name, :string, :limit => 32, :null => false
85
87
  end
86
- end
87
-
88
- class Backlog < ActiveRecord::Base
89
- end
90
-
91
- class Period < ActiveRecord::Base
92
- end
88
+
89
+ class Backlog < ActiveRecord::Base
90
+ end
91
+
92
+ class Period < ActiveRecord::Base
93
+ end
94
+
95
+ class User < ActiveRecord::Base
96
+ end
93
97
 
94
- class User < ActiveRecord::Base
95
98
  end
@@ -0,0 +1,115 @@
1
+ class CreateGroups < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :parties do |t|
4
+ t.column :type, :string
5
+ end
6
+
7
+ create_table :groups, :primary_key => :party_id do |t|
8
+ t.string :name, :null => false
9
+ end
10
+
11
+ rename_column :users, :id, :party_id
12
+
13
+ execute "INSERT INTO parties (id, type) SELECT party_id, 'User' FROM users"
14
+ if ActiveRecord::Base.connection.adapter_name.downcase == "postgresql"
15
+ ActiveRecord::Base.connection.execute "select setval('parties_id_seq', (select max(id) from parties));"
16
+ end
17
+ add_foreign_key :users, :party_id, :parties, :id
18
+
19
+ create_table :groups_users, :id => false do |t|
20
+ t.integer :group_id, :null => false, :references => nil
21
+ t.integer :user_id, :null => false, :references => nil
22
+ end
23
+
24
+ add_foreign_key :groups_users, :group_id, :groups, :party_id
25
+ add_foreign_key :groups_users, :user_id, :users, :party_id
26
+
27
+ add_index :groups_users, ["group_id", "user_id"], :unique => true
28
+
29
+ add_column :periods, :party_id, :integer
30
+ add_index :periods, ["party_id", "position"], :unique => true
31
+
32
+ add_column :tasks, :backlog_id, :integer
33
+
34
+ load_classes
35
+
36
+ Backlog.find(:all).each do |b|
37
+ next if b.periods.empty?
38
+ group = Group.create! :name => (b.name + 'Group')
39
+ b.periods.each do |p|
40
+ p.party_id = group.id
41
+ p.save!
42
+ p.tasks.each {|t| t.backlog = b; t.save!}
43
+ end
44
+ users = b.periods.map {|p| p.tasks.map {|t| t.estimates.map{|e| e.user} + t.works.map{|w| w.user}}}.flatten.compact.uniq
45
+ users.each do |u|
46
+ execute "INSERT INTO groups_users (group_id, user_id) VALUES (#{group.id}, #{u.id})"
47
+ end
48
+ end
49
+
50
+ remove_column :periods, :backlog_id
51
+ end
52
+
53
+ def self.down
54
+ add_column :periods, :backlog_id, :integer
55
+ load_classes
56
+ Period.find(:all).each do |p|
57
+ if first_task = p.tasks.first
58
+ p.backlog_id = first_task.backlog_id
59
+ p.save!
60
+ end
61
+ end
62
+ change_column :periods, :backlog_id, :integer, :null => false
63
+
64
+ remove_column :tasks, :backlog_id
65
+ remove_column :periods, :party_id
66
+ drop_table :groups_users
67
+ rename_column :users, :party_id, :id
68
+ drop_table :groups
69
+ drop_table :parties
70
+ end
71
+
72
+ def self.load_classes
73
+ class_eval <<EOF
74
+ class Party < ActiveRecord::Base
75
+ end
76
+
77
+ class User < Party
78
+ class_table_inheritance
79
+ end
80
+
81
+ class Group < Party
82
+ class_table_inheritance
83
+ has_and_belongs_to_many :users, :class_name => 'CreateGroups::User'
84
+ # has_many :users, :through => :groups_users, :class_name => 'CreateGroups::User'
85
+ end
86
+
87
+ class Backlog < ActiveRecord::Base
88
+ has_many :periods
89
+ end
90
+
91
+ class Period < ActiveRecord::Base
92
+ # belongs_to :backlog
93
+ # belongs_to :party
94
+ has_many :tasks
95
+ end
96
+
97
+ class Estimate < ActiveRecord::Base
98
+ belongs_to :user
99
+ end
100
+
101
+ class Work < ActiveRecord::Base
102
+ belongs_to :user
103
+ end
104
+
105
+ class Task < ActiveRecord::Base
106
+ belongs_to :backlog
107
+ belongs_to :period
108
+ has_many :estimates
109
+ has_many :works
110
+ end
111
+ EOF
112
+
113
+ end
114
+ end
115
+