afl_teamwork 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,6 +4,18 @@ class ListsController < ApplicationController
4
4
  @dev_items = client.get_list_items("Development")
5
5
  end
6
6
 
7
+ def add_task
8
+ list = client.get_tasklist("Development")
9
+ task = { :'todo-item' => { :content => params[:task][:title], :description => params[:task][:description] }}
10
+ response = client.add_task_to_list(task, list['id'])
11
+
12
+ if response.status == 201
13
+ redirect_to '/lists'
14
+ else
15
+ logger.info "Unable to add task to list."
16
+ end
17
+ end
18
+
7
19
  protected
8
20
 
9
21
  def client
@@ -81,7 +81,7 @@
81
81
  </div>
82
82
  </div>
83
83
  <div class="row-fluid">
84
- <div class="span12">
84
+ <div class="span8">
85
85
  <div class="task-items">
86
86
  <% @dev_items.each_with_index do |item, i| %>
87
87
  <div class="task-item">
@@ -112,4 +112,20 @@
112
112
  <% end %>
113
113
  </div>
114
114
  </div>
115
+ <div class="span4">
116
+ <div class="request-wrapper">
117
+ <% form_tag("/add-task") do %>
118
+ <fieldset>
119
+ <legend>New Task</legend>
120
+ <%= label_tag "Task title" %>
121
+ <%= text_field_tag "task[title]" %>
122
+ <%= label_tag "Description" %>
123
+ <%= text_area_tag "task[description]" %>
124
+ <div class="form-actions">
125
+ <%= submit_tag "Add task", :class => "btn btn-primary" %>
126
+ </div>
127
+ </fieldset>
128
+ <% end %>
129
+ </div>
130
+ </div>
115
131
  </div>
@@ -0,0 +1,4 @@
1
+ ActionController::Routing::Routes.draw do |map|
2
+ map.connect '/lists', :controller => 'lists', :action => 'show'
3
+ map.connect '/add-task', :controller => 'lists', :action => 'add_task', :method => :post
4
+ end
@@ -1,4 +1,5 @@
1
1
  require 'faraday'
2
+ require 'json'
2
3
 
3
4
  module AflTeamwork
4
5
  class Client
@@ -7,27 +8,45 @@ module AflTeamwork
7
8
  @api_key = api_key
8
9
  end
9
10
 
11
+ def get_tasklist(list)
12
+ get_tasklists.each do |tasklist|
13
+ if list === tasklist['name']
14
+ return tasklist
15
+ end
16
+ end
17
+ end
18
+
10
19
  def get_list_items(list)
11
- project_id = AflTeamwork.configuration.project_id
12
- projects = connection.get("/projects/#{project_id}/tasklists.json")
13
- tasklists = JSON.parse(projects.body)['tasklists']
14
- tasklists.each do |tasklist|
20
+ get_tasklists.each do |tasklist|
15
21
  if list === tasklist['name']
16
22
  tasklist_id = tasklist['id']
17
23
  todo_items = connection.get("/tasklists/#{tasklist_id}/tasks.json")
18
24
  return JSON.parse(todo_items.body)['todo-items']
19
25
  end
20
26
  end
27
+ end
21
28
 
29
+ def add_task_to_list(task, list)
30
+ connection.post do |req|
31
+ req.url "/tasklists/#{list}/tasks.json"
32
+ req.headers['Content-Type'] = 'application/json'
33
+ req.body = task.to_json
34
+ end
22
35
  end
23
36
 
24
37
  protected
25
38
 
39
+ def get_tasklists
40
+ project_id = AflTeamwork.configuration.project_id
41
+ projects = connection.get("/projects/#{project_id}/tasklists.json")
42
+ tasklists = JSON.parse(projects.body)['tasklists']
43
+ end
44
+
26
45
  def connection
27
46
  Faraday.new(:url => "https://#{@tw_name}.teamwork.com") do |faraday|
28
47
  faraday.request :basic_auth, @api_key, 'xxx'
29
48
  faraday.request :url_encoded # form-encode POST params
30
- #faraday.response :logger # log requests to STDOUT
49
+ faraday.response :logger # log requests to STDOUT
31
50
  faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
32
51
  end
33
52
  end
@@ -1,3 +1,3 @@
1
1
  module AflTeamwork
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,66 +1,73 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: afl_teamwork
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.3
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 4
9
+ version: 0.0.4
5
10
  platform: ruby
6
- authors:
11
+ authors:
7
12
  - Analytics For Lawyers
8
13
  autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
- date: 2016-08-09 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
16
+
17
+ date: 2016-08-16 00:00:00 -04:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
14
21
  name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.6'
20
- type: :development
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ segments:
27
+ - 1
28
+ - 6
29
+ version: "1.6"
21
30
  prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.6'
27
- - !ruby/object:Gem::Dependency
31
+ type: :development
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
28
34
  name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
35
+ requirement: &id002 !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ~>
38
+ - !ruby/object:Gem::Version
39
+ segments:
40
+ - 10
41
+ - 4
42
+ - 2
33
43
  version: 10.4.2
34
- type: :development
35
44
  prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: 10.4.2
41
- - !ruby/object:Gem::Dependency
45
+ type: :development
46
+ version_requirements: *id002
47
+ - !ruby/object:Gem::Dependency
42
48
  name: faraday
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
49
+ requirement: &id003 !ruby/object:Gem::Requirement
50
+ requirements:
45
51
  - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
52
+ - !ruby/object:Gem::Version
53
+ segments:
54
+ - 0
55
+ version: "0"
49
56
  prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
57
+ type: :runtime
58
+ version_requirements: *id003
55
59
  description: Teamwork task lists integration gem.
56
- email:
60
+ email:
57
61
  - matt@analyticsforlawyers.com
58
62
  - brandon@analyticsforlawyers.com
59
63
  executables: []
64
+
60
65
  extensions: []
66
+
61
67
  extra_rdoc_files: []
62
- files:
63
- - ".gitignore"
68
+
69
+ files:
70
+ - .gitignore
64
71
  - Gemfile
65
72
  - LICENSE.txt
66
73
  - README.md
@@ -68,32 +75,40 @@ files:
68
75
  - afl_teamwork.gemspec
69
76
  - app/controllers/lists_controller.rb
70
77
  - app/views/lists/show.html.erb
78
+ - config/routes.rb
71
79
  - lib/afl_teamwork.rb
72
80
  - lib/afl_teamwork/client.rb
73
81
  - lib/afl_teamwork/version.rb
74
82
  - rails/init.rb
75
- homepage: ''
76
- licenses:
83
+ has_rdoc: true
84
+ homepage: ""
85
+ licenses:
77
86
  - MIT
78
- metadata: {}
79
87
  post_install_message:
80
88
  rdoc_options: []
81
- require_paths:
89
+
90
+ require_paths:
82
91
  - lib
83
- required_ruby_version: !ruby/object:Gem::Requirement
84
- requirements:
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
85
94
  - - ">="
86
- - !ruby/object:Gem::Version
87
- version: '0'
88
- required_rubygems_version: !ruby/object:Gem::Requirement
89
- requirements:
95
+ - !ruby/object:Gem::Version
96
+ segments:
97
+ - 0
98
+ version: "0"
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
90
101
  - - ">="
91
- - !ruby/object:Gem::Version
92
- version: '0'
102
+ - !ruby/object:Gem::Version
103
+ segments:
104
+ - 0
105
+ version: "0"
93
106
  requirements: []
107
+
94
108
  rubyforge_project:
95
- rubygems_version: 2.4.5.1
109
+ rubygems_version: 1.3.6
96
110
  signing_key:
97
- specification_version: 4
111
+ specification_version: 3
98
112
  summary: Gem uses Teamwork to pull in tasklist data.
99
113
  test_files: []
114
+
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 72dafd7dd84aff2961f4b69f6abfbdc3603dfc96
4
- data.tar.gz: a5498514ef62110b364bd7988e1266b9db3d655c
5
- SHA512:
6
- metadata.gz: 6aad44767dd058eeb7563fa8389a22ac31dcce4ccbab6bd2e600402b3b1dd971f6d351ec14ac58c35eccb58b45cf326d46ff7fb6cafb9858b602a5c248c71d8c
7
- data.tar.gz: afc1c0c7ed0dc9a7ade118d2a26bdfccebb969b785285d03963abcc430ff6b4368f9a8a4456a15d750401ad0fdaea1dd5dac3c7166285bdaf1a581253eec1717