spree_core 0.60.2 → 0.60.3
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/admin/base_controller.rb +31 -1
- data/app/controllers/admin/general_settings_controller.rb +9 -0
- data/app/models/app_configuration.rb +3 -0
- data/app/models/spree/alert.rb +13 -0
- data/app/views/admin/general_settings/edit.html.erb +8 -0
- data/app/views/admin/general_settings/show.html.erb +5 -1
- data/app/views/admin/shared/_alert.html.erb +6 -0
- data/app/views/layouts/admin.html.erb +1 -0
- data/config/locales/en.yml +2 -0
- data/config/routes.rb +5 -1
- data/lib/spree_core/version.rb +1 -1
- data/public/javascripts/admin.js +6 -0
- data/public/stylesheets/admin/admin.css +29 -0
- metadata +6 -4
@@ -1,12 +1,42 @@
|
|
1
1
|
class Admin::BaseController < Spree::BaseController
|
2
2
|
ssl_required
|
3
3
|
|
4
|
+
before_filter :check_alerts if Rails.env.production?
|
5
|
+
|
4
6
|
helper :search
|
5
7
|
helper 'admin/navigation'
|
6
8
|
layout 'admin'
|
7
9
|
|
8
10
|
protected
|
9
|
-
|
11
|
+
def check_alerts
|
12
|
+
return unless current_user and should_check_alerts?
|
13
|
+
|
14
|
+
unless session.has_key? :alerts
|
15
|
+
begin
|
16
|
+
session[:alerts] = Spree::Alert.current(request.host)
|
17
|
+
filter_dismissed_alerts
|
18
|
+
Spree::Config.set :last_check_for_spree_alerts => DateTime.now.to_s
|
19
|
+
rescue
|
20
|
+
session[:alerts] = nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def should_check_alerts?
|
26
|
+
return false if not Spree::Config[:check_for_spree_alerts]
|
27
|
+
|
28
|
+
last_check = Spree::Config[:last_check_for_spree_alerts]
|
29
|
+
return true if last_check.blank?
|
30
|
+
|
31
|
+
DateTime.parse(last_check) < 12.hours.ago
|
32
|
+
end
|
33
|
+
|
34
|
+
def filter_dismissed_alerts
|
35
|
+
return unless session[:alerts]
|
36
|
+
dismissed = (Spree::Config[:dismissed_spree_alerts] || '').split(',')
|
37
|
+
session[:alerts].reject! { |a| dismissed.include? a.id.to_s }
|
38
|
+
end
|
39
|
+
|
10
40
|
def flash_message_for(object, event_sym)
|
11
41
|
resource_desc = object.class.model_name.human
|
12
42
|
resource_desc += " \"#{object.name}\"" if object.respond_to?(:name)
|
@@ -10,4 +10,13 @@ class Admin::GeneralSettingsController < Admin::BaseController
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
+
def dismiss_alert
|
14
|
+
if request.xhr? and params[:alert_id]
|
15
|
+
dismissed = Spree::Config[:dismissed_spree_alerts] || ''
|
16
|
+
Spree::Config.set :dismissed_spree_alerts => dismissed.split(',').push(params[:alert_id]).join(',')
|
17
|
+
filter_dismissed_alerts
|
18
|
+
render :nothing => true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
13
22
|
end
|
@@ -35,6 +35,9 @@ class AppConfiguration < Configuration
|
|
35
35
|
preference :use_content_controller, :boolean, :default => true
|
36
36
|
preference :allow_checkout_on_gateway_error, :boolean, :default => false
|
37
37
|
preference :select_taxons_from_tree, :boolean, :default => false # provide opportunity to select taxons from tree instead of search with autocomplete
|
38
|
+
preference :check_for_spree_alerts, :boolean, :default => true
|
39
|
+
preference :dismissed_spree_alerts, :string, :default => ''
|
40
|
+
preference :last_check_for_spree_alerts, :string, :default => nil
|
38
41
|
|
39
42
|
validates :name, :presence => true, :uniqueness => true
|
40
43
|
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Spree::Alert < ActiveResource::Base
|
2
|
+
self.site = "http://alerts.spreecommerce.com/"
|
3
|
+
self.format = :json
|
4
|
+
|
5
|
+
def self.current(host)
|
6
|
+
find(:all, :params => { :version => Spree.version,
|
7
|
+
:name => Spree::Config[:site_name],
|
8
|
+
:host => host,
|
9
|
+
:rails_env => Rails.env,
|
10
|
+
:rails_version => Rails.version })
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
@@ -31,6 +31,14 @@
|
|
31
31
|
</label>
|
32
32
|
</p>
|
33
33
|
|
34
|
+
<p>
|
35
|
+
<label>
|
36
|
+
<input name="preferences[check_for_spree_alerts]" type="hidden" value="0" />
|
37
|
+
<%= check_box_tag('preferences[check_for_spree_alerts]', "1", Spree::Config[:check_for_spree_alerts]) %>
|
38
|
+
<%= t('spree_alert_checking') %>
|
39
|
+
</label>
|
40
|
+
</p>
|
41
|
+
|
34
42
|
<p class="form-buttons">
|
35
43
|
<%= button t('update') %>
|
36
44
|
<%= t("or") %> <%= link_to t("cancel"), admin_general_settings_url %>
|
@@ -23,7 +23,11 @@
|
|
23
23
|
<tr>
|
24
24
|
<td colspan="2">
|
25
25
|
<%= (Spree::Config[:allow_ssl_in_development_and_test] ? t("ssl_will_be_used_in_development_and_test_modes") : t("ssl_will_not_be_used_in_development_and_test_modes")) %>
|
26
|
-
|
26
|
+
</td>
|
27
|
+
</tr>
|
28
|
+
<tr>
|
29
|
+
<td colspan="2">
|
30
|
+
<%= (Spree::Config[:check_for_spree_alerts] ? t("spree_alert_checking") : t("spree_alert_not_checking")) %>
|
27
31
|
</tr>
|
28
32
|
</table>
|
29
33
|
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<div class="alert <%= alert.severity.downcase %>">
|
2
|
+
<%= alert.message %> <%= link_to alert.url_name, alert.url if alert.url %>
|
3
|
+
<%= link_to 'X', dismiss_alert_admin_general_settings_path(:alert_id => alert.id),
|
4
|
+
:remote => true, :method => :post, :class => 'dismiss' %>
|
5
|
+
</div>
|
6
|
+
|
data/config/locales/en.yml
CHANGED
@@ -907,6 +907,8 @@ en:
|
|
907
907
|
ssl_will_be_used_in_production_mode: "SSL will be used in production mode"
|
908
908
|
ssl_will_not_be_used_in_development_and_test_modes: "SSL will not be used in development and test mode if necessary."
|
909
909
|
ssl_will_not_be_used_in_production_mode: "SSL will not be used in production mode"
|
910
|
+
spree_alert_checking: "Check for Spree security and release alerts"
|
911
|
+
spree_alert_not_checking: "Not checking for Spree security and release alerts"
|
910
912
|
start: Start
|
911
913
|
start_date: Valid from
|
912
914
|
state: State
|
data/config/routes.rb
CHANGED
data/lib/spree_core/version.rb
CHANGED
data/public/javascripts/admin.js
CHANGED
@@ -583,3 +583,32 @@ span.handle{
|
|
583
583
|
width:14px;
|
584
584
|
height:15px;
|
585
585
|
}
|
586
|
+
|
587
|
+
.alert {
|
588
|
+
-moz-border-radius: 5px;
|
589
|
+
-webkit-border-radius: 5px;
|
590
|
+
border-radius: 5px;
|
591
|
+
font-size: 1.3em;
|
592
|
+
margin-bottom: 1em;
|
593
|
+
padding: 0.8em;
|
594
|
+
}
|
595
|
+
.alert a.dismiss {
|
596
|
+
float:right;
|
597
|
+
font-size: 0.8em;
|
598
|
+
}
|
599
|
+
.alert.release {
|
600
|
+
background: #ccddff url(../images/shadow_top.png) 0px -50px repeat-x;
|
601
|
+
color: #556699;
|
602
|
+
border: 1px solid #99aacc;
|
603
|
+
}
|
604
|
+
.alert.security {
|
605
|
+
background: #f4b4b4 url(../images/shadow_top.png) 0px -50px repeat-x;
|
606
|
+
color: #000000;
|
607
|
+
border: 1px solid #e75b5b;
|
608
|
+
}
|
609
|
+
.alert.news {
|
610
|
+
background: #ccffd4 url(../images/shadow_top.png) 0px -50px repeat-x;
|
611
|
+
color: #000000;
|
612
|
+
border: 1px solid #66ff7e;
|
613
|
+
}
|
614
|
+
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 233
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 60
|
9
|
-
-
|
10
|
-
version: 0.60.
|
9
|
+
- 3
|
10
|
+
version: 0.60.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sean Schofield
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-10-
|
18
|
+
date: 2011-10-21 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
@@ -385,6 +385,7 @@ files:
|
|
385
385
|
- app/models/shipment.rb
|
386
386
|
- app/models/shipping_category.rb
|
387
387
|
- app/models/shipping_method.rb
|
388
|
+
- app/models/spree/alert.rb
|
388
389
|
- app/models/state.rb
|
389
390
|
- app/models/state_event.rb
|
390
391
|
- app/models/tax_category.rb
|
@@ -509,6 +510,7 @@ files:
|
|
509
510
|
- app/views/admin/shared/_additional_field.html.erb
|
510
511
|
- app/views/admin/shared/_address.html.erb
|
511
512
|
- app/views/admin/shared/_address_form.html.erb
|
513
|
+
- app/views/admin/shared/_alert.html.erb
|
512
514
|
- app/views/admin/shared/_calculator_fields.html.erb
|
513
515
|
- app/views/admin/shared/_configuration_menu.html.erb
|
514
516
|
- app/views/admin/shared/_destroy.js.erb
|