bookyt_projects 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,14 +6,16 @@ class ActivitiesController < AuthorizedController
6
6
  if params[:activity]
7
7
  @activity = Activity.new(params[:activity])
8
8
  else
9
- @activity = Activity.new(:when => Date.today)
9
+ @activity = Activity.new(:date => Date.today)
10
10
  end
11
11
 
12
- # Nested resources support
13
- @activity.project_id ||= params[:project_id] if params[:project_id]
14
- # Educated guessing of defaults
12
+ # Educated guessing of person
15
13
  @activity.person = current_user.person if current_user
16
14
 
15
+ # Educated guessing of project
16
+ @activity.project_id ||= params[:project_id] if params[:project_id]
17
+ @activity.project_id ||= @activity.person.activities.order(:duration_to).last
18
+
17
19
  new!
18
20
  end
19
21
 
@@ -1,16 +1,18 @@
1
1
  class Activity < ActiveRecord::Base
2
+ # Associations
2
3
  belongs_to :project
3
4
  belongs_to :person
5
+ validates :project, :presence => true, :allow_blank => false
6
+ validates :person, :presence => true, :allow_blank => false
4
7
 
5
8
  attr_accessor :minutes, :hours
6
9
 
7
- validates :project, :presence => true, :allow_blank => false
8
- validates :person, :presence => true, :allow_blank => false
9
- validates_date :when, :allow_nil => false, :allow_blank => false
10
- validates :from, :presence => true, :unless => :hours_minutes
11
- validates :to, :presence => true, :unless => :hours_minutes
12
- validates_numericality_of :hours, :only_integer => true, :unless => :from
13
- validates_numericality_of :minutes, :only_integer => true, :unless => :from
10
+ # Duration
11
+ validates_date :date, :allow_nil => false, :allow_blank => false
12
+ validates :duration_from, :presence => true, :unless => :hours_minutes
13
+ validates :duration_to, :presence => true, :unless => :hours_minutes
14
+ validates_numericality_of :hours, :only_integer => true, :unless => :duration_from
15
+ validates_numericality_of :minutes, :only_integer => true, :unless => :duration_from
14
16
 
15
17
  before_save :calculate_hours
16
18
 
@@ -20,14 +22,14 @@ class Activity < ActiveRecord::Base
20
22
 
21
23
  def calculate_hours
22
24
  unless hours.empty? or minutes.empty?
23
- self.from = DateTime.now
24
- self.to = self.from + hours.to_i.hours + minutes.to_i.minutes
25
+ self.duration_from = DateTime.now
26
+ self.duration_to = self.duration_from + hours.to_i.hours + minutes.to_i.minutes
25
27
  end
26
28
  end
27
29
 
28
30
  # The duration of the task in minutes
29
31
  def duration
30
- minutes = (to.to_f - from.to_f).to_i / 60
32
+ minutes = (duration_to.to_f - duration_from.to_f).to_i / 60
31
33
 
32
34
  minutes < 0 ? 1.day.to_i + minutes : minutes
33
35
  end
@@ -1,5 +1,5 @@
1
1
  module BookytProjects
2
- module Employee
2
+ module Person
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
@@ -16,7 +16,7 @@ class WorkDay
16
16
  end
17
17
 
18
18
  def hours_worked
19
- employment.employee.activities.where(:when => date).to_a.sum(&:duration)
19
+ employment.employee.activities.where(:date => date).to_a.sum(&:duration)
20
20
  end
21
21
 
22
22
  def overtime
@@ -0,0 +1,7 @@
1
+ %tr[activity]
2
+ %td= activity.person
3
+ %td= link_to activity.date, activity, {'data-href-container' => 'tr'}
4
+ %td= t('bookyt.projects.minutes', :duration => activity.duration)
5
+ %td.action-links
6
+ = list_link_for(:edit, activity, :remote => true)
7
+ = list_link_for(:delete, activity)
@@ -3,9 +3,9 @@
3
3
  = f.input :project, :as => :combobox
4
4
  = f.input :person, :as => :combobox
5
5
  = f.inputs do
6
- = f.input :when, :as => :date_field, :required => true
7
- = f.input :from, :as => :hour_field
8
- = f.input :to, :as => :hour_field
6
+ = f.input :date, :as => :date_field, :required => true
7
+ = f.input :duration_from, :as => :hour_field
8
+ = f.input :duration_to, :as => :hour_field
9
9
  = f.input :hours
10
10
  = f.input :minutes
11
11
  = f.inputs do
@@ -1,14 +1,7 @@
1
1
  %table.list#activities_list
2
2
  %tr
3
- - [:person, :when, :duration].each do |attr|
3
+ - [:person, :date, :duration].each do |attr|
4
4
  %th= t_attr(attr, Activity)
5
5
  %th.action-links
6
6
 
7
- - collection.each do |task|
8
- %tr
9
- %td= task.person
10
- %td= link_to task.when, task, {'data-href-container' => 'tr'}
11
- %td= t('bookyt.projects.minutes', :duration => task.duration)
12
- %td.action-links
13
- = list_link_for(:edit, task)
14
- = list_link_for(:delete, task)
7
+ = render collection
@@ -3,8 +3,8 @@
3
3
  = f.inputs do
4
4
  = f.input :name, :input_html => {'data-autofocus' => 'true'}
5
5
  = f.input :comment, :input_html => {:rows => 5}
6
- = f.input :from, :as => :date_field
7
- = f.input :to, :as => :date_field
6
+ = f.input :duration_from, :as => :date_field
7
+ = f.input :duration_to, :as => :date_field
8
8
  = f.input :project_state
9
9
  = f.input :client, :as => :combobox
10
10
  = f.buttons do
@@ -1,13 +1,16 @@
1
+ .contextual
2
+ = contextual_link_to :new, Activity
3
+
1
4
  %h1= t_title
2
5
 
3
6
  %table.list
4
7
  %tr
5
8
  %th Datum
6
9
  %th Wochentag
7
- %th Soll-Stunden
8
- %th Stunden
9
- %th Über-/Unterzeit
10
- %th Saldo
10
+ %th.number Soll-Stunden
11
+ %th.number Stunden
12
+ %th.number Über-/Unterzeit
13
+ %th.number Saldo
11
14
 
12
15
  - overall_overtime = 0
13
16
  - @work_days.each do |day|
@@ -15,7 +18,7 @@
15
18
  %tr
16
19
  %td= day.date
17
20
  %td= l(day.date, :format => '%A')
18
- %td= day.hours_due
19
- %td= day.hours_worked
20
- %td= day.overtime
21
- %td= overall_overtime
21
+ %td.number= day.hours_due
22
+ %td.number= day.hours_worked
23
+ %td.number= day.overtime
24
+ %td.number= overall_overtime
@@ -9,8 +9,8 @@ de:
9
9
  project:
10
10
  name: Bezeichnung
11
11
  comment: Kommentar
12
- from: Von
13
- to: Bis
12
+ duration_from: Begin
13
+ duration_to: Ende
14
14
  project_state: Status
15
15
  project_state_id: Status
16
16
  client: Kunde
@@ -20,9 +20,9 @@ de:
20
20
  activity:
21
21
  person: Person
22
22
  person_id: Person
23
- when: Datum
24
- from: Von
25
- to: Bis
23
+ date: Datum
24
+ duration_from: Von
25
+ duration_to: Bis
26
26
  duration: Dauer
27
27
  hours: Stunden
28
28
  minutes: Minuten
@@ -0,0 +1,9 @@
1
+ class CreateProjectStates < ActiveRecord::Migration
2
+ def change
3
+ create_table :project_states do |t|
4
+ t.string :name
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ class CreateProjects < ActiveRecord::Migration
2
+ def change
3
+ create_table :projects do |t|
4
+ t.string :name
5
+ t.text :comment
6
+ t.date :from
7
+ t.date :to
8
+ t.integer :project_state_id
9
+ t.integer :client_id
10
+
11
+ t.timestamps
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ class CreateTasks < ActiveRecord::Migration
2
+ def change
3
+ create_table :tasks do |t|
4
+ t.date :when
5
+ t.datetime :from
6
+ t.datetime :to
7
+ t.integer :person_id
8
+ t.integer :project_id
9
+ t.string :comment
10
+
11
+ t.timestamps
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ class RenameTaskToActivity < ActiveRecord::Migration
2
+ def change
3
+ rename_table :tasks, :activities
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ class RenameDurationColumnsInProjectsAndActivities < ActiveRecord::Migration
2
+ def change
3
+ rename_column :activities, :when, :date
4
+ rename_column :activities, :from, :duration_from
5
+ rename_column :activities, :to, :duration_to
6
+
7
+ rename_column :projects, :from, :duration_from
8
+ rename_column :projects, :to, :duration_to
9
+ end
10
+ end
@@ -3,8 +3,10 @@ require 'rails'
3
3
 
4
4
  module BookytProjects
5
5
  class Railtie < Rails::Engine
6
+ engine_name "bookyt_projects"
7
+
6
8
  config.to_prepare do
7
- ::Employee.send :include, BookytProjects::Employee
9
+ ::Person.send :include, BookytProjects::Person
8
10
  end
9
11
  end
10
12
  end
@@ -1,3 +1,3 @@
1
1
  module BookytPos
2
- VERSION = '0.10.0'
2
+ VERSION = '0.11.0'
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bookyt_projects
3
3
  version: !ruby/object:Gem::Version
4
- hash: 55
5
- prerelease:
4
+ hash: 51
5
+ prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 10
8
+ - 11
9
9
  - 0
10
- version: 0.10.0
10
+ version: 0.11.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Roman Simecek (CyT)
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-10-25 00:00:00 +02:00
19
+ date: 2011-10-29 00:00:00 +02:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -109,10 +109,11 @@ files:
109
109
  - app/controllers/projects_controller.rb
110
110
  - app/controllers/timesheets_controller.rb
111
111
  - app/models/activity.rb
112
- - app/models/bookyt_projects/employee.rb
112
+ - app/models/bookyt_projects/person.rb
113
113
  - app/models/project.rb
114
114
  - app/models/project_state.rb
115
115
  - app/models/work_day.rb
116
+ - app/views/activities/_activity.html.haml
116
117
  - app/views/activities/_form.html.haml
117
118
  - app/views/activities/_list.html.haml
118
119
  - app/views/project_states/_form.html.haml
@@ -124,6 +125,11 @@ files:
124
125
  - config/boot.rb
125
126
  - config/locales/de.yml
126
127
  - config/routes.rb
128
+ - db/migrate/20110909075128_create_project_states.rb
129
+ - db/migrate/20110909075220_create_projects.rb
130
+ - db/migrate/20110912071440_create_tasks.rb
131
+ - db/migrate/20111010114218_rename_task_to_activity.rb
132
+ - db/migrate/20111025090501_rename_duration_columns_in_projects_and_activities.rb
127
133
  - lib/bookyt_projects.rb
128
134
  - lib/bookyt_projects/navigation.rb
129
135
  - lib/bookyt_projects/railtie.rb
@@ -160,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
166
  requirements: []
161
167
 
162
168
  rubyforge_project:
163
- rubygems_version: 1.5.2
169
+ rubygems_version: 1.3.7
164
170
  signing_key:
165
171
  specification_version: 3
166
172
  summary: Project management plugin for bookyt