bookyt_projects 0.12.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,7 +17,7 @@ class ActivitiesController < AuthorizedController
17
17
 
18
18
  # Educated guessing of project
19
19
  @activity.project_id ||= params[:project_id] if params[:project_id]
20
- @activity.project_id ||= @activity.person.activities.order(:duration_to).last
20
+ @activity.project_id ||= @activity.person.activities.order(:date).last
21
21
 
22
22
  new!
23
23
  end
@@ -14,7 +14,7 @@ class BatchActivitiesController < ApplicationController
14
14
  def create
15
15
  date = Date.parse(params[:batch_activities][:date])
16
16
  @activites = params[:activities].collect{|activity_params|
17
- Activity.create(activity_params.merge(:date => date, :minutes => "0"))
17
+ Activity.create(activity_params.merge(:date => date))
18
18
  }
19
19
 
20
20
  redirect_to activities_path(:by_date => date.to_s(:db))
@@ -9,35 +9,20 @@ class Activity < ActiveRecord::Base
9
9
  scope :by_date, lambda {|value| where(:date => value)}
10
10
 
11
11
  # Duration
12
- attr_accessor :minutes, :hours
12
+ validates :duration, :presence => true, :format => {:with => /[0-9]{1,2}([:.][0-9]{1,2})/}
13
13
 
14
14
  validates_date :date, :allow_nil => false, :allow_blank => false
15
- validates :duration_from, :presence => true, :unless => :hours_minutes
16
- validates :duration_to, :presence => true, :unless => :hours_minutes
17
- validates_numericality_of :hours, :only_integer => true, :unless => :duration_from
18
- validates_numericality_of :minutes, :only_integer => true, :unless => :duration_from
19
-
20
- before_save :calculate_hours
21
-
22
- def hours_minutes
23
- minutes || hours
24
- end
25
-
26
- def calculate_hours
27
- unless hours.empty? or minutes.empty?
28
- self.duration_from = DateTime.now
29
- self.duration_to = self.duration_from + hours.to_i.hours + minutes.to_i.minutes
15
+
16
+ def duration=(value)
17
+ if value.match(/:/)
18
+ hours, minutes = value.split(':')
19
+ write_attribute(:duration, hours.to_i + BigDecimal.new(minutes) / 60)
20
+ else
21
+ write_attribute(:duration, value)
30
22
  end
31
23
  end
32
-
33
- # The duration of the task in minutes
34
- def duration
35
- minutes = (duration_to.to_f - duration_from.to_f).to_i / 60
36
-
37
- minutes < 0 ? 1.day.to_i + minutes : minutes
38
- end
39
24
 
40
25
  def to_s
41
- "#{duration} => #{person}"
26
+ "%s: %0.2fh" % [project.name, duration]
42
27
  end
43
28
  end
@@ -8,7 +8,7 @@ module BookytProjects
8
8
 
9
9
  module InstanceMethods
10
10
  def latest_project
11
- activities.order(:duration_to).last.try(:project)
11
+ activities.order(:date).last.try(:project)
12
12
  end
13
13
  end
14
14
  end
@@ -1,4 +1,4 @@
1
1
  %tr[activity]
2
2
  %td= activity.person
3
3
  %td= link_to activity.date, activity, {'data-href-container' => 'tr'}
4
- %td= t('bookyt.projects.minutes', :duration => activity.duration)
4
+ %td= t('bookyt.projects.hours', :duration => "%0.2f" % activity.duration)
@@ -1,17 +1,14 @@
1
1
  = semantic_form_for @activity do |f|
2
2
  = f.inputs do
3
- = f.input :project, :as => :combobox
4
- = f.input :person, :as => :combobox
3
+ .row
4
+ .span8= f.input :person, :as => :combobox
5
+ .span8= f.input :project, :as => :combobox
6
+ .row
7
+ .span8= f.input :date, :as => :date_field
8
+ .span8= f.input :duration, :as => :string
5
9
 
6
- = f.inputs do
7
- = f.input :date, :as => :date_field, :required => true
8
- = f.input :duration_from, :as => :hour_field
9
- = f.input :duration_to, :as => :hour_field
10
- = f.input :hours
11
- = f.input :minutes
12
-
13
- = f.inputs do
14
- = f.input :comment
10
+ .row
11
+ .span16= f.input :remarks, :input_html => {:rows => 2, :class => 'span12'}
15
12
 
16
13
  = f.buttons do
17
14
  = f.commit_button
@@ -8,7 +8,7 @@
8
8
  %th= t_attr :person, Activity
9
9
  %th= t_attr :project, Activity
10
10
  %th{:style => 'width: 5em'}= t_attr :duration, Activity
11
- %th= t_attr :comment, Activity
11
+ %th= t_attr :remarks, Activity
12
12
 
13
13
  %tbody
14
14
  - for activity in @activities
@@ -18,8 +18,8 @@
18
18
  = link_to activity.person, activity.person
19
19
  = a.hidden_field :person_id
20
20
  %td= a.select :project_id, Project.all.map{|project| [project.to_s, project.id]}, {:prompt => t_select_prompt(Project)}
21
- %td= a.text_field :hours
22
- %td= a.text_field :comment
21
+ %td= a.text_field :duration
22
+ %td= a.text_field :remarks
23
23
 
24
24
  = f.buttons do
25
25
  = f.commit_button
@@ -11,7 +11,7 @@
11
11
  = f.input :duration_to, :as => :date_field
12
12
  .row
13
13
  .span16
14
- = f.input :comment, :input_html => {:rows => 5, :class => 'span12'}
14
+ = f.input :remarks, :input_html => {:rows => 5, :class => 'span12'}
15
15
 
16
16
  = f.buttons do
17
17
  = f.commit_button
@@ -1,3 +1,3 @@
1
1
  - activities.each do |activity|
2
- %h4= "#{activity.project.name}: #{activity.duration}"
3
- %p= activity.comment
2
+ %h4= activity.to_s
3
+ %p= activity.remarks
@@ -10,11 +10,11 @@
10
10
  - overall_overtime += day.overtime
11
11
  - activities = @employee.activities.where(:date => day.date)
12
12
  - tr_params = {:class => work_day_classes(day)}
13
- - tr_params.merge!(:rel => 'popover', 'data-content' => h(render 'activities_popover', :activities => activities), 'data-original-title' => 'Aktivitäten', 'data-html' => 'true') unless activities.empty?
13
+ - tr_params.merge!(:rel => 'popover', 'data-content' => h(render 'timesheets/activities_popover', :activities => activities), 'data-original-title' => 'Aktivitäten', 'data-html' => 'true') unless activities.empty?
14
14
  %tr{tr_params}
15
15
  %td= link_to l(day.date, :format => '%a, %d.%m.%Y'), person_activities_path(@employee, :by_date => day.date.to_s(:db)), 'data-href-container' => 'tr'
16
16
  %td.number
17
- %span.strong= "%0.1f" % day.hours_worked
18
- = "(%0.1f)" % day.hours_due
19
- %td.number.overtime.strong= day.overtime
20
- %td.number.overall-overtime.strong= overall_overtime
17
+ %span.strong= "%0.2f" % day.hours_worked
18
+ = "(%0.2f)" % day.hours_due
19
+ %td.number.overtime.strong= "%0.2f" % day.overtime
20
+ %td.number.overall-overtime.strong= "%0.2f" % overall_overtime
@@ -39,7 +39,7 @@ de:
39
39
 
40
40
  bookyt:
41
41
  projects:
42
- minutes: "%{duration} Minuten"
42
+ hours: "%{duration}h"
43
43
  main_navigation:
44
44
  salaries: Löhne
45
45
  projects: Projekte
@@ -0,0 +1,15 @@
1
+ class RenameCommentColumnsToRemarks < ActiveRecord::Migration
2
+ def up
3
+ rename_column :projects, :comment, :remarks
4
+ rename_column :activities, :comment, :remarks
5
+
6
+ change_column :activities, :remarks, :text
7
+ end
8
+
9
+ def down
10
+ change_column :activities, :remarks, :string
11
+
12
+ rename_column :projects, :remarks, :comment
13
+ rename_column :activities, :remarks, :comment
14
+ end
15
+ end
@@ -0,0 +1,8 @@
1
+ class UseSingleDurationField < ActiveRecord::Migration
2
+ def up
3
+ add_column :activities, :duration, :datetime
4
+
5
+ remove_column :activities, :duration_from
6
+ remove_column :activities, :duration_to
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ class UseDecimalForActivityDuration < ActiveRecord::Migration
2
+ def up
3
+ change_column :activities, :duration, :decimal, :scale => 2, :precision => 4
4
+ end
5
+
6
+ def down
7
+ end
8
+ end
@@ -1,3 +1,3 @@
1
1
  module BookytPos
2
- VERSION = '0.12.0'
2
+ VERSION = '0.13.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: 47
4
+ hash: 43
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 12
8
+ - 13
9
9
  - 0
10
- version: 0.12.0
10
+ version: 0.13.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: 2012-01-16 00:00:00 Z
19
+ date: 2012-01-17 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: rails
@@ -139,6 +139,9 @@ files:
139
139
  - db/migrate/20110912071440_create_tasks.rb
140
140
  - db/migrate/20111010114218_rename_task_to_activity.rb
141
141
  - db/migrate/20111025090501_rename_duration_columns_in_projects_and_activities.rb
142
+ - db/migrate/20120117070747_rename_comment_columns_to_remarks.rb
143
+ - db/migrate/20120117075541_use_single_duration_field.rb
144
+ - db/migrate/20120117080212_use_decimal_for_activity_duration.rb
142
145
  - lib/bookyt_projects.rb
143
146
  - lib/bookyt_projects/navigation.rb
144
147
  - lib/bookyt_projects/railtie.rb
@@ -174,9 +177,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
177
  requirements: []
175
178
 
176
179
  rubyforge_project:
177
- rubygems_version: 1.8.15
180
+ rubygems_version: 1.8.10
178
181
  signing_key:
179
182
  specification_version: 3
180
183
  summary: Project management plugin for bookyt
181
184
  test_files: []
182
185
 
186
+ has_rdoc: