spree_dash 2.0.1 → 2.0.2

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: af813a84c3abda15fc14acbf602ae345dceb790a
4
+ data.tar.gz: dfe88e0930f6513cac7e0b43570c8149f0d5fc86
5
+ SHA512:
6
+ metadata.gz: f6e796a21e6d3a608525855091980515a85b0b7e3f447036eda1dd30a7e0f0611089a8d79369598e814b37d2fd49e9446e77dd115241ed58b0512929e6786a83
7
+ data.tar.gz: c5ac96802c2faf7bc98adc978fe345c8c6be617e14cd0c163097718974cf1b1f8aeec433eba375096dc57274fffbe2fc2708d0885e9d2a4892ee895d34cb183b
@@ -10,7 +10,14 @@ module Spree
10
10
  Spree::Dash::Config.app_token = store[:app_token]
11
11
  Spree::Dash::Config.site_id = store[:site_id]
12
12
  Spree::Dash::Config.token = store[:site_token]
13
+ Spree::Dash::Config.jirafe_available = true
13
14
  redirect_to admin_path
15
+
16
+ rescue Spree::Dash::JirafeUnavailable => e
17
+ session[:jirafe_unavailable_since] = Time.now.to_i
18
+ flash[:error] = e.message
19
+ Spree::Dash::Config.jirafe_available = false
20
+ redirect_to spree.admin_path
14
21
  rescue Spree::Dash::JirafeException => e
15
22
  flash[:error] = e.message
16
23
  redirect_to root_path
@@ -8,7 +8,14 @@ module Spree
8
8
  :japanese => 'ja_JA' }
9
9
 
10
10
  def index
11
- redirect_to admin_analytics_register_path unless Spree::Dash::Config.configured?
11
+ if session[:jirafe_unavailable_since]
12
+ jirafe_unavailable_since = Time.at(session[:jirafe_unavailable_since])
13
+ if jirafe_unavailable_since < Time.now - 10.minutes
14
+ redirect_to admin_analytics_register_path if !dash_config.configured?
15
+ end
16
+ else
17
+ redirect_to admin_analytics_register_path if !dash_config.configured?
18
+ end
12
19
 
13
20
  if JIRAFE_LOCALES.values.include? params[:locale]
14
21
  Spree::Dash::Config.locale = params[:locale]
@@ -31,5 +38,9 @@ module Spree
31
38
  def model_class
32
39
  Spree::Admin::OverviewController
33
40
  end
41
+
42
+ def dash_config
43
+ Spree::Dash::Config
44
+ end
34
45
  end
35
46
  end
@@ -5,6 +5,7 @@ module Spree
5
5
  preference :site_id, :string
6
6
  preference :token, :string
7
7
  preference :locale, :string, :default => 'en_US'
8
+ preference :jirafe_available, :boolean, :default => true
8
9
 
9
10
  def configured?
10
11
  preferred_app_id.present? and preferred_site_id.present? and preferred_token.present?
@@ -25,7 +25,7 @@
25
25
  }
26
26
  }, 10000);
27
27
  <% end %>
28
- <% else %>
28
+ <% elsif Spree::Dash::Config.jirafe_available %>
29
29
  <div class="no-border-top analytics-description">
30
30
  <div class="description-text">
31
31
  <hgroup>
@@ -41,11 +41,12 @@
41
41
  </ul>
42
42
  </div>
43
43
  <div class="preview-buttons filter-actions actions">
44
- <%= link_to_with_icon 'icon-ok', Spree.t(:activate), admin_analytics_sign_up_path, :class => 'button' %>
44
+ <%= link_to_with_icon 'icon-ok', Spree.t(:activate), admin_analytics_register_path, :class => 'button' %>
45
45
  <span class="or">&nbsp; <%= Spree.t(:or) %> &nbsp;</span>
46
46
  <%= link_to_with_icon 'icon-info-sign', Spree.t(:learn_more), "http://spreecommerce.com/blog/2012/01/31/introducing-spree-analytics/", :class => 'button', :target => '_blank' %>
47
47
  </div>
48
48
  </div>
49
-
50
49
  <div class="analytics_splash"></div>
50
+ <% else %>
51
+ <%= Spree.t(:'dash.jirafe.currently_unavailable') %>
51
52
  <% end %>
@@ -1,6 +1,7 @@
1
1
  module Spree
2
2
  module Dash
3
3
  class JirafeException < Exception; end
4
+ class JirafeUnavailable < Exception; end
4
5
 
5
6
  class Jirafe
6
7
  include HTTParty
@@ -32,12 +33,15 @@ module Spree
32
33
  }
33
34
  }
34
35
  response = post '/applications', options
35
- raise JirafeException, 'unable to create jirafe application' unless response.code == 200 &&
36
- response['app_id'].present? &&
37
- response['token'].present?
38
- store[:app_id] = response['app_id']
39
- store[:app_token] = response['token']
40
- store
36
+ if response.code == 200
37
+ store[:app_id] = response['app_id']
38
+ store[:app_token] = response['token']
39
+ return store
40
+ elsif response.code == 503
41
+ raise JirafeUnavailable, Spree.t(:'dash.jirafe.currently_unavailable')
42
+ else
43
+ raise JirafeException, 'unable to create jirafe application'
44
+ end
41
45
  end
42
46
 
43
47
  def synchronize_resources(store)
metadata CHANGED
@@ -1,52 +1,46 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_dash
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
5
- prerelease:
4
+ version: 2.0.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Brian Quinn
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-06-04 00:00:00.000000000 Z
11
+ date: 2013-06-12 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: spree_backend
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - '='
20
18
  - !ruby/object:Gem::Version
21
- version: 2.0.1
19
+ version: 2.0.2
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - '='
28
25
  - !ruby/object:Gem::Version
29
- version: 2.0.1
26
+ version: 2.0.2
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: spree_frontend
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - '='
36
32
  - !ruby/object:Gem::Version
37
- version: 2.0.1
33
+ version: 2.0.2
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - '='
44
39
  - !ruby/object:Gem::Version
45
- version: 2.0.1
40
+ version: 2.0.2
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: httparty
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -87,30 +80,26 @@ files:
87
80
  homepage: http://spreecommerce.com
88
81
  licenses:
89
82
  - BSD-3
83
+ metadata: {}
90
84
  post_install_message:
91
85
  rdoc_options: []
92
86
  require_paths:
93
87
  - lib
94
88
  required_ruby_version: !ruby/object:Gem::Requirement
95
- none: false
96
89
  requirements:
97
- - - ! '>='
90
+ - - '>='
98
91
  - !ruby/object:Gem::Version
99
92
  version: 1.9.3
100
93
  required_rubygems_version: !ruby/object:Gem::Requirement
101
- none: false
102
94
  requirements:
103
- - - ! '>='
95
+ - - '>='
104
96
  - !ruby/object:Gem::Version
105
97
  version: '0'
106
- segments:
107
- - 0
108
- hash: 1677247741916088368
109
98
  requirements:
110
99
  - none
111
100
  rubyforge_project:
112
- rubygems_version: 1.8.25
101
+ rubygems_version: 2.0.0
113
102
  signing_key:
114
- specification_version: 3
103
+ specification_version: 4
115
104
  summary: Overview dashboard for use with Spree.
116
105
  test_files: []