backlog 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +10 -0
- data/Rakefile +2 -1
- data/app/controllers/application.rb +55 -8
- data/app/controllers/groups_controller.rb +62 -0
- data/app/controllers/periods_controller.rb +13 -55
- data/app/controllers/tasks_controller.rb +9 -5
- data/app/controllers/works_controller.rb +43 -6
- data/app/helpers/application_helper.rb +20 -2
- data/app/helpers/groups_helper.rb +2 -0
- data/app/models/backlog.rb +19 -10
- data/app/models/estimate.rb +2 -1
- data/app/models/group.rb +11 -0
- data/app/models/party.rb +3 -0
- data/app/models/period.rb +43 -6
- data/app/models/task.rb +27 -14
- data/app/models/user.rb +37 -8
- data/app/models/work.rb +4 -6
- data/app/views/backlogs/_name_list.rhtml +5 -0
- data/app/views/backlogs/show.rhtml +4 -4
- data/app/views/groups/_form.rhtml +7 -0
- data/app/views/groups/edit.rhtml +31 -0
- data/app/views/groups/list.rhtml +27 -0
- data/app/views/groups/new.rhtml +8 -0
- data/app/views/layouts/wide.rhtml +2 -2
- data/app/views/periods/_burn_down_chart.rhtml +1 -1
- data/app/views/periods/_form.rhtml +13 -9
- data/app/views/periods/_show_active.rhtml +6 -12
- data/app/views/periods/_title.rhtml +4 -5
- data/app/views/periods/edit.rhtml +1 -1
- data/app/views/periods/new.rhtml +1 -1
- data/app/views/periods/show.rhtml +10 -6
- data/app/views/tasks/_backlog_header.rhtml +22 -0
- data/app/views/tasks/_description_list.rhtml +5 -0
- data/app/views/tasks/_form.rhtml +26 -7
- data/app/views/tasks/_task.rhtml +4 -4
- data/app/views/tasks/edit.rhtml +2 -3
- data/app/views/tasks/list_started.rhtml +1 -0
- data/app/views/tasks/new.rhtml +2 -2
- data/app/views/works/_buttons.rhtml +3 -0
- data/app/views/works/_form.rhtml +15 -10
- data/app/views/works/daily_work_sheet.rhtml +30 -18
- data/app/views/works/edit.rhtml +4 -4
- data/app/views/works/list.rhtml +2 -2
- data/app/views/works/new.rhtml +3 -2
- data/app/views/works/weekly_work_sheet.rhtml +2 -2
- data/bin/backlog +2 -0
- data/bin/backlog_init.d_kubosch_production +27 -0
- data/bin/copy_production2development.rb +33 -0
- data/config/database.yml +13 -7
- data/config/deploy_kubosch.rb +1 -0
- data/config/environment.rb +2 -0
- data/config/environments/development_mysql.rb +27 -0
- data/config/environments/kubosch_production_mysql.rb +21 -0
- data/config/routes.rb +1 -1
- data/db/migrate/{001_tasks.rb → 001_create_tasks.rb} +1 -1
- data/db/migrate/{002_backlogs.rb → 002_create_backlogs.rb} +2 -2
- data/db/migrate/003_add_estimation_points.rb +1 -1
- data/db/migrate/004_add_period.rb +2 -2
- data/db/migrate/013_create_estimates.rb +1 -1
- data/db/migrate/015_add_user_option.rb +9 -5
- data/db/migrate/017_insert_datek_projects.rb +13 -10
- data/db/migrate/018_create_groups.rb +115 -0
- data/db/schema.rb +72 -12
- data/lang/en.yaml +7 -0
- data/lang/no.yaml +7 -0
- data/lib/big_decimal_yaml_fix.rb +27 -0
- data/lib/class_table_inheritance.rb +163 -0
- data/lib/tasks/backup.rake +92 -0
- data/public/images/person.org.png +0 -0
- data/public/images/person.png +0 -0
- data/public/stylesheets/backlog.css +3 -1
- data/public/stylesheets/mwrt002.css +1 -1
- data/test/fixtures/groups.yml +6 -0
- data/test/fixtures/parties.yml +31 -0
- data/test/fixtures/periods.yml +2 -2
- data/test/fixtures/tasks.yml +2 -0
- data/test/fixtures/users.yml +6 -6
- data/test/functional/backlogs_controller_test.rb +1 -1
- data/test/functional/groups_controller_test.rb +120 -0
- data/test/functional/periods_controller_test.rb +1 -1
- data/test/functional/tasks_controller_test.rb +16 -1
- data/test/functional/user_controller_test.rb +8 -2
- data/test/test_helper.rb +5 -0
- data/test/unit/big_decimal_yaml_fix_test.rb +14 -0
- data/test/unit/estimate_test.rb +1 -1
- data/test/unit/group_test.rb +10 -0
- data/test/unit/user_test.rb +56 -44
- data/tmp/sessions/ruby_sess.22dec3e9df47fb4e +0 -0
- data/tmp/sessions/ruby_sess.8037e0ab58cbcf1a +0 -0
- data/vendor/plugins/activerecord_foreign_key_extensions/lib/active_record_extensions.rb +35 -0
- data/vendor/rails/actionmailer/test/fixtures/test_mailer/implicitly_multipart_example.rhtml.bak +1 -0
- data/vendor/rails/{actionwebservice/lib/action_web_service/templates/scaffolds/layout.rhtml → railties/configs/empty.log} +0 -0
- metadata +36 -105
- data/backlog.gemspec +0 -21
- data/vendor/rails/actionwebservice/CHANGELOG +0 -265
- data/vendor/rails/actionwebservice/MIT-LICENSE +0 -21
- data/vendor/rails/actionwebservice/README +0 -364
- data/vendor/rails/actionwebservice/Rakefile +0 -171
- data/vendor/rails/actionwebservice/TODO +0 -32
- data/vendor/rails/actionwebservice/examples/googlesearch/README +0 -143
- data/vendor/rails/actionwebservice/examples/googlesearch/autoloading/google_search_api.rb +0 -50
- data/vendor/rails/actionwebservice/examples/googlesearch/autoloading/google_search_controller.rb +0 -57
- data/vendor/rails/actionwebservice/examples/googlesearch/delegated/google_search_service.rb +0 -108
- data/vendor/rails/actionwebservice/examples/googlesearch/delegated/search_controller.rb +0 -7
- data/vendor/rails/actionwebservice/examples/googlesearch/direct/google_search_api.rb +0 -50
- data/vendor/rails/actionwebservice/examples/googlesearch/direct/search_controller.rb +0 -58
- data/vendor/rails/actionwebservice/examples/metaWeblog/README +0 -17
- data/vendor/rails/actionwebservice/examples/metaWeblog/apis/blogger_api.rb +0 -60
- data/vendor/rails/actionwebservice/examples/metaWeblog/apis/blogger_service.rb +0 -34
- data/vendor/rails/actionwebservice/examples/metaWeblog/apis/meta_weblog_api.rb +0 -67
- data/vendor/rails/actionwebservice/examples/metaWeblog/apis/meta_weblog_service.rb +0 -48
- data/vendor/rails/actionwebservice/examples/metaWeblog/controllers/xmlrpc_controller.rb +0 -16
- data/vendor/rails/actionwebservice/install.rb +0 -30
- data/vendor/rails/actionwebservice/lib/action_web_service.rb +0 -66
- data/vendor/rails/actionwebservice/lib/action_web_service/api.rb +0 -301
- data/vendor/rails/actionwebservice/lib/action_web_service/base.rb +0 -42
- data/vendor/rails/actionwebservice/lib/action_web_service/casting.rb +0 -138
- data/vendor/rails/actionwebservice/lib/action_web_service/client.rb +0 -3
- data/vendor/rails/actionwebservice/lib/action_web_service/client/base.rb +0 -28
- data/vendor/rails/actionwebservice/lib/action_web_service/client/soap_client.rb +0 -113
- data/vendor/rails/actionwebservice/lib/action_web_service/client/xmlrpc_client.rb +0 -58
- data/vendor/rails/actionwebservice/lib/action_web_service/container.rb +0 -3
- data/vendor/rails/actionwebservice/lib/action_web_service/container/action_controller_container.rb +0 -93
- data/vendor/rails/actionwebservice/lib/action_web_service/container/delegated_container.rb +0 -86
- data/vendor/rails/actionwebservice/lib/action_web_service/container/direct_container.rb +0 -69
- data/vendor/rails/actionwebservice/lib/action_web_service/dispatcher.rb +0 -2
- data/vendor/rails/actionwebservice/lib/action_web_service/dispatcher/abstract.rb +0 -207
- data/vendor/rails/actionwebservice/lib/action_web_service/dispatcher/action_controller_dispatcher.rb +0 -379
- data/vendor/rails/actionwebservice/lib/action_web_service/invocation.rb +0 -202
- data/vendor/rails/actionwebservice/lib/action_web_service/protocol.rb +0 -4
- data/vendor/rails/actionwebservice/lib/action_web_service/protocol/abstract.rb +0 -112
- data/vendor/rails/actionwebservice/lib/action_web_service/protocol/discovery.rb +0 -37
- data/vendor/rails/actionwebservice/lib/action_web_service/protocol/soap_protocol.rb +0 -176
- data/vendor/rails/actionwebservice/lib/action_web_service/protocol/soap_protocol/marshaler.rb +0 -235
- data/vendor/rails/actionwebservice/lib/action_web_service/protocol/xmlrpc_protocol.rb +0 -122
- data/vendor/rails/actionwebservice/lib/action_web_service/scaffolding.rb +0 -283
- data/vendor/rails/actionwebservice/lib/action_web_service/struct.rb +0 -68
- data/vendor/rails/actionwebservice/lib/action_web_service/support/class_inheritable_options.rb +0 -26
- data/vendor/rails/actionwebservice/lib/action_web_service/support/signature_types.rb +0 -226
- data/vendor/rails/actionwebservice/lib/action_web_service/templates/scaffolds/layout.erb +0 -65
- data/vendor/rails/actionwebservice/lib/action_web_service/templates/scaffolds/methods.erb +0 -6
- data/vendor/rails/actionwebservice/lib/action_web_service/templates/scaffolds/methods.rhtml +0 -0
- data/vendor/rails/actionwebservice/lib/action_web_service/templates/scaffolds/parameters.erb +0 -29
- data/vendor/rails/actionwebservice/lib/action_web_service/templates/scaffolds/parameters.rhtml +0 -0
- data/vendor/rails/actionwebservice/lib/action_web_service/templates/scaffolds/result.erb +0 -30
- data/vendor/rails/actionwebservice/lib/action_web_service/templates/scaffolds/result.rhtml +0 -0
- data/vendor/rails/actionwebservice/lib/action_web_service/test_invoke.rb +0 -110
- data/vendor/rails/actionwebservice/lib/action_web_service/version.rb +0 -9
- data/vendor/rails/actionwebservice/setup.rb +0 -1379
- data/vendor/rails/actionwebservice/test/abstract_client.rb +0 -183
- data/vendor/rails/actionwebservice/test/abstract_dispatcher.rb +0 -551
- data/vendor/rails/actionwebservice/test/abstract_unit.rb +0 -45
- data/vendor/rails/actionwebservice/test/api_test.rb +0 -102
- data/vendor/rails/actionwebservice/test/apis/auto_load_api.rb +0 -3
- data/vendor/rails/actionwebservice/test/apis/broken_auto_load_api.rb +0 -2
- data/vendor/rails/actionwebservice/test/base_test.rb +0 -42
- data/vendor/rails/actionwebservice/test/casting_test.rb +0 -86
- data/vendor/rails/actionwebservice/test/client_soap_test.rb +0 -153
- data/vendor/rails/actionwebservice/test/client_xmlrpc_test.rb +0 -152
- data/vendor/rails/actionwebservice/test/container_test.rb +0 -73
- data/vendor/rails/actionwebservice/test/dispatcher_action_controller_soap_test.rb +0 -137
- data/vendor/rails/actionwebservice/test/dispatcher_action_controller_xmlrpc_test.rb +0 -59
- data/vendor/rails/actionwebservice/test/fixtures/db_definitions/mysql.sql +0 -8
- data/vendor/rails/actionwebservice/test/fixtures/users.yml +0 -12
- data/vendor/rails/actionwebservice/test/gencov +0 -3
- data/vendor/rails/actionwebservice/test/invocation_test.rb +0 -185
- data/vendor/rails/actionwebservice/test/run +0 -6
- data/vendor/rails/actionwebservice/test/scaffolded_controller_test.rb +0 -146
- data/vendor/rails/actionwebservice/test/struct_test.rb +0 -52
- data/vendor/rails/actionwebservice/test/test_invoke_test.rb +0 -112
data/app/views/works/edit.rhtml
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
<div id="spotlight">
|
2
|
-
<% @page_title = :
|
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
|
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>
|
data/app/views/works/list.rhtml
CHANGED
@@ -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.
|
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.
|
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>
|
data/app/views/works/new.rhtml
CHANGED
@@ -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
|
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.
|
5
|
-
<% invoicing = @rows.find {|r| r.find {|w| w && w.task.
|
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>
|
data/bin/backlog
CHANGED
@@ -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`
|
data/config/database.yml
CHANGED
@@ -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
|
-
|
25
|
+
kubosch_production:
|
19
26
|
adapter: postgresql
|
20
27
|
database: backlog_production
|
21
|
-
username:
|
22
|
-
# password:
|
28
|
+
username: donv
|
23
29
|
host: localhost
|
24
30
|
|
25
|
-
|
31
|
+
kubosch_production_mysql:
|
26
32
|
adapter: mysql
|
27
33
|
database: backlog_development
|
28
|
-
username:
|
29
|
-
password:
|
30
|
-
host:
|
34
|
+
username: root
|
35
|
+
password: mithrandir
|
36
|
+
host: localhost
|
31
37
|
|
32
38
|
datek_production:
|
33
39
|
adapter: postgresql
|
data/config/deploy_kubosch.rb
CHANGED
data/config/environment.rb
CHANGED
@@ -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
|
+
|
data/config/routes.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
class
|
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 (
|
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
|
|
@@ -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.
|
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
|
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
|
-
|
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 "
|
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
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
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
|
+
|