bookyt_projects 0.2.3 → 0.3.0

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.3
1
+ 0.3.0
@@ -2,4 +2,8 @@ class Project < ActiveRecord::Base
2
2
  belongs_to :client, :class_name => 'Person'
3
3
  belongs_to :project_state
4
4
  has_many :tasks
5
+
6
+ def to_s
7
+ name
8
+ end
5
9
  end
data/app/models/task.rb CHANGED
@@ -2,7 +2,31 @@ class Task < ActiveRecord::Base
2
2
  belongs_to :project
3
3
  belongs_to :person
4
4
 
5
+ attr_accessor :minutes, :hours
6
+
7
+ validates :project, :presence => true
8
+ validates :person, :presence => true
9
+ validates :when, :presence => true
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
14
+
15
+ before_save :calculate_hours, :if => :hours_minutes
16
+
17
+ def hours_minutes
18
+ minutes || hours
19
+ end
20
+
21
+ def calculate_hours
22
+ self.from = DateTime.now
23
+ self.to = self.from + hours.to_i.hours + minutes.to_i.minutes
24
+ end
25
+
26
+ # The duration of the task in minutes
5
27
  def duration
6
- "2h"
28
+ minutes = (to.to_f - from.to_f).to_i / 60
29
+
30
+ minutes < 0 ? 1.day.to_i + minutes : minutes
7
31
  end
8
32
  end
@@ -20,6 +20,6 @@
20
20
  %tr
21
21
  %td= task.person
22
22
  %td= task.when
23
- %td= task.duration
23
+ %td= t('bookyt.projects.minutes', :duration => task.duration)
24
24
 
25
25
  = link_to t_title(:new, Task), new_project_task_path(resource)
@@ -6,6 +6,8 @@
6
6
  = f.input :when, :as => :date_field
7
7
  = f.input :from, :as => :hour_field
8
8
  = f.input :to, :as => :hour_field
9
+ = f.input :hours
10
+ = f.input :minutes
9
11
  = f.inputs do
10
12
  = f.input :comment
11
13
  = f.buttons do
@@ -0,0 +1,19 @@
1
+ %table{:class => "#{collection.first.class.to_s.downcase} detail"}
2
+ %tr
3
+ %th= t_attr(:project)
4
+ %td= resource.project
5
+ %tr
6
+ %th= t_attr(:person)
7
+ %td= resource.person
8
+ %tr
9
+ %th= t_attr(:when)
10
+ %td= l(resource.when)
11
+ %tr
12
+ %th= t_attr(:time)
13
+ %td= "#{l(resource.from, :format => :time)} - #{l(resource.to, :format => :time)}"
14
+ %tr
15
+ %th= t_attr(:duration)
16
+ %td= t('bookyt.projects.minutes', :duration => resource.duration)
17
+ %tr
18
+ %th= t_attr(:comment)
19
+ %td= resource.comment
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{bookyt_projects}
8
- s.version = "0.2.3"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Roman Simecek}]
12
- s.date = %q{2011-09-19}
12
+ s.date = %q{2011-09-20}
13
13
  s.description = %q{Rails engine for project management it's used to extend the functionallity of bookyt.}
14
14
  s.email = %q{roman.simecek@cyt.ch}
15
15
  s.extra_rdoc_files = [
@@ -39,6 +39,7 @@ Gem::Specification.new do |s|
39
39
  "app/views/projects/new.html.haml",
40
40
  "app/views/projects/show.html.haml",
41
41
  "app/views/tasks/_form.html.haml",
42
+ "app/views/tasks/_resource_detail.html.haml",
42
43
  "bookyt_projects.gemspec",
43
44
  "config/locales/de.yml",
44
45
  "config/routes.rb",
@@ -13,10 +13,16 @@ de:
13
13
  project_state: Status
14
14
  project_state_id: Status
15
15
  client: Kunde
16
- client_id: Kunde
16
+ client_id: Kunde
17
17
  project_state:
18
18
  name: Bezeichnung
19
19
  task:
20
20
  person: Person
21
21
  when: Datum
22
22
  duration: Dauer
23
+ project: Projekt
24
+ comment: Kommentar
25
+ time: Zeitraum
26
+ bookyt:
27
+ projects:
28
+ minutes: "%{duration} Minuten"
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: 17
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 2
9
8
  - 3
10
- version: 0.2.3
9
+ - 0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Roman Simecek
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-19 00:00:00 Z
18
+ date: 2011-09-20 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  requirement: &id001 !ruby/object:Gem::Requirement
@@ -126,6 +126,7 @@ files:
126
126
  - app/views/projects/new.html.haml
127
127
  - app/views/projects/show.html.haml
128
128
  - app/views/tasks/_form.html.haml
129
+ - app/views/tasks/_resource_detail.html.haml
129
130
  - bookyt_projects.gemspec
130
131
  - config/locales/de.yml
131
132
  - config/routes.rb