activity_notification 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +22 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +17 -0
- data/.github/pull_request_template.md +13 -0
- data/.gitignore +10 -3
- data/.travis.yml +6 -5
- data/CHANGELOG.md +22 -0
- data/Gemfile +8 -2
- data/Procfile +1 -1
- data/README.md +153 -1510
- data/activity_notification.gemspec +4 -1
- data/app/channels/activity_notification/notification_api_channel.rb +12 -0
- data/app/channels/activity_notification/notification_api_with_devise_channel.rb +46 -0
- data/app/channels/activity_notification/notification_channel.rb +1 -1
- data/app/channels/activity_notification/notification_with_devise_channel.rb +1 -1
- data/app/controllers/activity_notification/apidocs_controller.rb +75 -0
- data/app/controllers/activity_notification/notifications_api_controller.rb +143 -0
- data/app/controllers/activity_notification/notifications_api_with_devise_controller.rb +7 -0
- data/app/controllers/activity_notification/notifications_controller.rb +79 -53
- data/app/controllers/activity_notification/subscriptions_api_controller.rb +197 -0
- data/app/controllers/activity_notification/subscriptions_api_with_devise_controller.rb +7 -0
- data/app/controllers/activity_notification/subscriptions_controller.rb +78 -69
- data/app/views/activity_notification/notifications/default/_default.html.erb +18 -18
- data/app/views/activity_notification/notifications/default/_default_without_grouping.html.erb +14 -14
- data/app/views/activity_notification/notifications/default/index.html.erb +6 -6
- data/app/views/activity_notification/optional_targets/default/action_cable_channel/_default.html.erb +176 -0
- data/app/views/activity_notification/subscriptions/default/_form.html.erb +1 -1
- data/app/views/activity_notification/subscriptions/default/_notification_keys.html.erb +3 -31
- data/app/views/activity_notification/subscriptions/default/_subscription.html.erb +7 -7
- data/app/views/activity_notification/subscriptions/default/index.html.erb +11 -7
- data/bin/deploy_on_heroku.sh +3 -1
- data/docs/CODE_OF_CONDUCT.md +76 -0
- data/docs/CONTRIBUTING.md +36 -0
- data/docs/Functions.md +1130 -0
- data/docs/Setup.md +674 -0
- data/docs/Testing.md +148 -0
- data/gemfiles/Gemfile.rails-4.2 +3 -0
- data/gemfiles/Gemfile.rails-5.0 +3 -0
- data/gemfiles/Gemfile.rails-5.1 +3 -0
- data/gemfiles/Gemfile.rails-5.2 +3 -0
- data/gemfiles/{Gemfile.rails-6.0.rc → Gemfile.rails-6.0} +5 -3
- data/lib/activity_notification.rb +13 -1
- data/lib/activity_notification/apis/notification_api.rb +29 -92
- data/lib/activity_notification/apis/subscription_api.rb +20 -8
- data/lib/activity_notification/apis/swagger.rb +6 -0
- data/lib/activity_notification/config.rb +41 -21
- data/lib/activity_notification/controllers/common_api_controller.rb +30 -0
- data/lib/activity_notification/controllers/common_controller.rb +44 -20
- data/lib/activity_notification/controllers/concerns/swagger/error_responses.rb +55 -0
- data/lib/activity_notification/controllers/concerns/swagger/notifications_api.rb +273 -0
- data/lib/activity_notification/controllers/concerns/swagger/notifications_parameters.rb +92 -0
- data/lib/activity_notification/controllers/concerns/swagger/subscriptions_api.rb +405 -0
- data/lib/activity_notification/controllers/concerns/swagger/subscriptions_parameters.rb +50 -0
- data/lib/activity_notification/controllers/devise_authentication_controller.rb +7 -6
- data/lib/activity_notification/gem_version.rb +14 -0
- data/lib/activity_notification/helpers/errors.rb +2 -0
- data/lib/activity_notification/helpers/view_helpers.rb +4 -0
- data/lib/activity_notification/mailers/helpers.rb +17 -10
- data/lib/activity_notification/models/concerns/notifiable.rb +26 -10
- data/lib/activity_notification/models/concerns/subscriber.rb +12 -1
- data/lib/activity_notification/models/concerns/swagger/error_schema.rb +36 -0
- data/lib/activity_notification/models/concerns/swagger/notification_schema.rb +209 -0
- data/lib/activity_notification/models/concerns/swagger/subscription_schema.rb +162 -0
- data/lib/activity_notification/models/concerns/target.rb +36 -10
- data/lib/activity_notification/models/notification.rb +1 -0
- data/lib/activity_notification/models/subscription.rb +1 -0
- data/lib/activity_notification/optional_targets/action_cable_api_channel.rb +69 -0
- data/lib/activity_notification/optional_targets/action_cable_channel.rb +68 -0
- data/lib/activity_notification/optional_targets/base.rb +7 -13
- data/lib/activity_notification/orm/active_record/notification.rb +17 -1
- data/lib/activity_notification/orm/active_record/subscription.rb +1 -1
- data/lib/activity_notification/orm/dynamoid.rb +28 -0
- data/lib/activity_notification/orm/dynamoid/extension.rb +79 -1
- data/lib/activity_notification/orm/dynamoid/notification.rb +1 -1
- data/lib/activity_notification/orm/dynamoid/subscription.rb +1 -1
- data/lib/activity_notification/orm/mongoid.rb +22 -0
- data/lib/activity_notification/orm/mongoid/notification.rb +17 -1
- data/lib/activity_notification/orm/mongoid/subscription.rb +1 -1
- data/lib/activity_notification/rails/routes.rb +132 -48
- data/lib/activity_notification/renderable.rb +13 -2
- data/lib/activity_notification/roles/acts_as_notifiable.rb +38 -20
- data/lib/activity_notification/version.rb +1 -1
- data/lib/generators/activity_notification/controllers_generator.rb +2 -1
- data/lib/generators/templates/activity_notification.rb +8 -0
- data/lib/generators/templates/controllers/notifications_api_controller.rb +31 -0
- data/lib/generators/templates/controllers/notifications_api_with_devise_controller.rb +31 -0
- data/lib/generators/templates/controllers/notifications_controller.rb +1 -37
- data/lib/generators/templates/controllers/notifications_with_devise_controller.rb +1 -45
- data/lib/generators/templates/controllers/subscriptions_api_controller.rb +61 -0
- data/lib/generators/templates/controllers/subscriptions_api_with_devise_controller.rb +61 -0
- data/lib/generators/templates/controllers/subscriptions_controller.rb +14 -37
- data/lib/generators/templates/controllers/subscriptions_with_devise_controller.rb +14 -45
- data/lib/generators/templates/models/README +8 -4
- data/lib/generators/templates/models/notification.rb +1 -1
- data/lib/generators/templates/models/subscription.rb +1 -1
- data/package.json +8 -0
- data/spec/channels/notification_api_channel_shared_examples.rb +59 -0
- data/spec/channels/notification_api_channel_spec.rb +51 -0
- data/spec/channels/notification_api_with_devise_channel_spec.rb +78 -0
- data/spec/concerns/apis/notification_api_spec.rb +37 -2
- data/spec/concerns/models/notifiable_spec.rb +64 -0
- data/spec/concerns/models/subscriber_spec.rb +13 -16
- data/spec/concerns/models/target_spec.rb +32 -0
- data/spec/concerns/renderable_spec.rb +2 -2
- data/spec/controllers/controller_spec_utility.rb +136 -0
- data/spec/controllers/notifications_api_controller_shared_examples.rb +506 -0
- data/spec/controllers/notifications_api_controller_spec.rb +19 -0
- data/spec/controllers/notifications_api_with_devise_controller_spec.rb +60 -0
- data/spec/controllers/notifications_controller_shared_examples.rb +54 -79
- data/spec/controllers/notifications_controller_spec.rb +1 -2
- data/spec/controllers/notifications_with_devise_controller_spec.rb +3 -12
- data/spec/controllers/subscriptions_api_controller_shared_examples.rb +750 -0
- data/spec/controllers/subscriptions_api_controller_spec.rb +19 -0
- data/spec/controllers/subscriptions_api_with_devise_controller_spec.rb +60 -0
- data/spec/controllers/subscriptions_controller_shared_examples.rb +94 -121
- data/spec/controllers/subscriptions_controller_spec.rb +1 -2
- data/spec/controllers/subscriptions_with_devise_controller_spec.rb +3 -12
- data/spec/helpers/view_helpers_spec.rb +4 -11
- data/spec/mailers/mailer_spec.rb +41 -0
- data/spec/models/notification_spec.rb +17 -0
- data/spec/models/subscription_spec.rb +0 -13
- data/spec/optional_targets/action_cable_api_channel_spec.rb +37 -0
- data/spec/optional_targets/action_cable_channel_spec.rb +44 -0
- data/spec/optional_targets/amazon_sns_spec.rb +0 -2
- data/spec/optional_targets/slack_spec.rb +0 -2
- data/spec/rails_app/Rakefile +9 -0
- data/spec/rails_app/app/assets/config/manifest.js +3 -0
- data/spec/rails_app/app/assets/images/.keep +0 -0
- data/spec/rails_app/app/controllers/admins_controller.rb +21 -0
- data/spec/rails_app/app/controllers/application_controller.rb +1 -1
- data/spec/rails_app/app/controllers/articles_controller.rb +6 -3
- data/spec/rails_app/app/controllers/spa_controller.rb +7 -0
- data/spec/rails_app/app/controllers/users/notifications_controller.rb +0 -65
- data/spec/rails_app/app/controllers/users/notifications_with_devise_controller.rb +0 -73
- data/spec/rails_app/app/controllers/users/subscriptions_controller.rb +0 -77
- data/spec/rails_app/app/controllers/users/subscriptions_with_devise_controller.rb +0 -85
- data/spec/rails_app/app/controllers/users_controller.rb +21 -0
- data/spec/rails_app/app/javascript/App.vue +104 -0
- data/spec/rails_app/app/javascript/components/DeviseTokenAuth.vue +83 -0
- data/spec/rails_app/app/javascript/components/Top.vue +99 -0
- data/spec/rails_app/app/javascript/components/notifications/Index.vue +200 -0
- data/spec/rails_app/app/javascript/components/notifications/Notification.vue +133 -0
- data/spec/rails_app/app/javascript/components/notifications/NotificationContent.vue +122 -0
- data/spec/rails_app/app/javascript/components/subscriptions/Index.vue +279 -0
- data/spec/rails_app/app/javascript/components/subscriptions/NewSubscription.vue +112 -0
- data/spec/rails_app/app/javascript/components/subscriptions/NotificationKey.vue +141 -0
- data/spec/rails_app/app/javascript/components/subscriptions/Subscription.vue +226 -0
- data/spec/rails_app/app/javascript/config/development.js +5 -0
- data/spec/rails_app/app/javascript/config/environment.js +7 -0
- data/spec/rails_app/app/javascript/config/production.js +5 -0
- data/spec/rails_app/app/javascript/config/test.js +5 -0
- data/spec/rails_app/app/javascript/packs/application.js +18 -0
- data/spec/rails_app/app/javascript/packs/spa.js +11 -0
- data/spec/rails_app/app/javascript/store/auth.js +37 -0
- data/spec/rails_app/app/models/admin.rb +16 -15
- data/spec/rails_app/app/models/article.rb +26 -21
- data/spec/rails_app/app/models/comment.rb +24 -71
- data/spec/rails_app/app/models/user.rb +43 -20
- data/spec/rails_app/app/views/activity_notification/notifications/default/article/_update.html.erb +146 -0
- data/spec/rails_app/app/views/articles/index.html.erb +51 -7
- data/spec/rails_app/app/views/articles/show.html.erb +1 -1
- data/spec/rails_app/app/views/layouts/_header.html.erb +8 -10
- data/spec/rails_app/app/views/spa/index.html.erb +2 -0
- data/spec/rails_app/babel.config.js +72 -0
- data/spec/rails_app/bin/webpack +18 -0
- data/spec/rails_app/bin/webpack-dev-server +18 -0
- data/spec/rails_app/config/application.rb +15 -2
- data/spec/rails_app/config/environment.rb +2 -1
- data/spec/rails_app/config/environments/development.rb +5 -0
- data/spec/rails_app/config/environments/production.rb +3 -0
- data/spec/rails_app/config/environments/test.rb +5 -0
- data/spec/rails_app/config/initializers/activity_notification.rb +8 -0
- data/spec/rails_app/config/initializers/devise_token_auth.rb +55 -0
- data/spec/rails_app/config/initializers/mysql.rb +9 -0
- data/spec/rails_app/config/locales/activity_notification.en.yml +2 -2
- data/spec/rails_app/config/routes.rb +33 -1
- data/spec/rails_app/config/webpack/development.js +5 -0
- data/spec/rails_app/config/webpack/environment.js +7 -0
- data/spec/rails_app/config/webpack/loaders/vue.js +6 -0
- data/spec/rails_app/config/webpack/production.js +5 -0
- data/spec/rails_app/config/webpack/test.js +5 -0
- data/spec/rails_app/config/webpacker.yml +97 -0
- data/spec/rails_app/db/migrate/20191201000000_add_tokens_to_users.rb +10 -0
- data/spec/rails_app/db/schema.rb +4 -1
- data/spec/rails_app/db/seeds.rb +1 -0
- data/spec/rails_app/lib/custom_optional_targets/raise_error.rb +14 -0
- data/spec/rails_app/package.json +23 -0
- data/spec/rails_app/postcss.config.js +12 -0
- data/spec/roles/acts_as_group_spec.rb +0 -2
- data/spec/roles/acts_as_notifiable_spec.rb +1 -3
- data/spec/roles/acts_as_notifier_spec.rb +0 -2
- data/spec/roles/acts_as_target_spec.rb +0 -4
- data/spec/spec_helper.rb +7 -15
- data/spec/version_spec.rb +31 -0
- metadata +187 -13
@@ -1,21 +1,24 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module CommentModel
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
3
5
|
belongs_to :article
|
4
6
|
belongs_to :user
|
5
7
|
validates :article, presence: true
|
6
8
|
validates :user, presence: true
|
7
9
|
|
8
10
|
acts_as_notifiable :users,
|
9
|
-
targets: ->(comment, key) { ([comment.article.user] + comment.article.commented_users.to_a - [comment.user]).uniq },
|
11
|
+
targets: ->(comment, key) { ([comment.article.user] + comment.article.reload.commented_users.to_a - [comment.user]).uniq },
|
10
12
|
group: :article, notifier: :user, email_allowed: true,
|
11
|
-
action_cable_allowed: true,
|
13
|
+
action_cable_allowed: true, action_cable_api_allowed: true,
|
12
14
|
parameters: { 'test_default_param' => '1' },
|
13
15
|
notifiable_path: :article_notifiable_path,
|
14
16
|
printable_name: ->(comment) { "comment \"#{comment.body}\"" },
|
15
17
|
dependent_notifications: :update_group_and_delete_all
|
16
18
|
|
17
19
|
require 'custom_optional_targets/console_output'
|
18
|
-
|
20
|
+
optional_targets = {}
|
21
|
+
# optional_targets = optional_targets.merge(CustomOptionalTarget::ConsoleOutput => {})
|
19
22
|
if ENV['OPTIONAL_TARGET_AMAZON_SNS']
|
20
23
|
require 'activity_notification/optional_targets/amazon_sns'
|
21
24
|
if ENV['OPTIONAL_TARGET_AMAZON_SNS_TOPIC_ARN']
|
@@ -39,24 +42,29 @@ unless ENV['AN_TEST_DB'] == 'mongodb'
|
|
39
42
|
)
|
40
43
|
end
|
41
44
|
acts_as_notifiable :admins,
|
42
|
-
targets: Admin.all.to_a,
|
45
|
+
targets: ->(comment) { Admin.all.to_a },
|
43
46
|
group: :article, notifier: :user, notifiable_path: :article_notifiable_path,
|
44
|
-
action_cable_allowed: true,
|
45
|
-
tracked: { only: [:create], action_cable_rendering: { fallback: :default } },
|
47
|
+
action_cable_allowed: true, action_cable_api_allowed: true,
|
48
|
+
tracked: Rails.env.test? ? {only: []} : { only: [:create], action_cable_rendering: { fallback: :default } },
|
46
49
|
printable_name: ->(comment) { "comment \"#{comment.body}\"" },
|
47
50
|
dependent_notifications: :delete_all,
|
48
51
|
optional_targets: optional_targets
|
49
52
|
|
50
|
-
# For testing
|
51
53
|
acts_as_group
|
54
|
+
end
|
52
55
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
+
def article_notifiable_path
|
57
|
+
article_path(article)
|
58
|
+
end
|
56
59
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
+
def author?(user)
|
61
|
+
self.user == user
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
unless ENV['AN_TEST_DB'] == 'mongodb'
|
66
|
+
class Comment < ActiveRecord::Base
|
67
|
+
include CommentModel
|
60
68
|
end
|
61
69
|
else
|
62
70
|
require 'mongoid'
|
@@ -65,64 +73,9 @@ else
|
|
65
73
|
include Mongoid::Timestamps
|
66
74
|
include GlobalID::Identification
|
67
75
|
|
68
|
-
belongs_to :article
|
69
|
-
belongs_to :user
|
70
|
-
validates :article, presence: true
|
71
|
-
validates :user, presence: true
|
72
76
|
field :body, type: String
|
73
77
|
|
74
78
|
include ActivityNotification::Models
|
75
|
-
|
76
|
-
targets: ->(comment, key) { ([comment.article.user] + comment.article.commented_users.to_a - [comment.user]).uniq },
|
77
|
-
group: :article, notifier: :user, email_allowed: true,
|
78
|
-
action_cable_allowed: true,
|
79
|
-
parameters: { 'test_default_param' => '1' },
|
80
|
-
notifiable_path: :article_notifiable_path,
|
81
|
-
printable_name: ->(comment) { "comment \"#{comment.body}\"" },
|
82
|
-
dependent_notifications: :update_group_and_delete_all
|
83
|
-
|
84
|
-
require 'custom_optional_targets/console_output'
|
85
|
-
optional_targets = { CustomOptionalTarget::ConsoleOutput => {} }
|
86
|
-
if ENV['OPTIONAL_TARGET_AMAZON_SNS']
|
87
|
-
require 'activity_notification/optional_targets/amazon_sns'
|
88
|
-
if ENV['OPTIONAL_TARGET_AMAZON_SNS_TOPIC_ARN']
|
89
|
-
optional_targets = optional_targets.merge(
|
90
|
-
ActivityNotification::OptionalTarget::AmazonSNS => { topic_arn: ENV['OPTIONAL_TARGET_AMAZON_SNS_TOPIC_ARN'] }
|
91
|
-
)
|
92
|
-
elsif ENV['OPTIONAL_TARGET_AMAZON_SNS_PHONE_NUMBER']
|
93
|
-
optional_targets = optional_targets.merge(
|
94
|
-
ActivityNotification::OptionalTarget::AmazonSNS => { phone_number: :phone_number }
|
95
|
-
)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
if ENV['OPTIONAL_TARGET_SLACK']
|
99
|
-
require 'activity_notification/optional_targets/slack'
|
100
|
-
optional_targets = optional_targets.merge(
|
101
|
-
ActivityNotification::OptionalTarget::Slack => {
|
102
|
-
webhook_url: ENV['OPTIONAL_TARGET_SLACK_WEBHOOK_URL'], target_username: :slack_username,
|
103
|
-
channel: ENV['OPTIONAL_TARGET_SLACK_CHANNEL'] || 'activity_notification',
|
104
|
-
username: 'ActivityNotification', icon_emoji: ":ghost:"
|
105
|
-
}
|
106
|
-
)
|
107
|
-
end
|
108
|
-
acts_as_notifiable :admins,
|
109
|
-
targets: Admin.all.to_a,
|
110
|
-
group: :article, notifier: :user, notifiable_path: :article_notifiable_path,
|
111
|
-
action_cable_allowed: true,
|
112
|
-
tracked: { only: [:create], action_cable_rendering: { fallback: :default } },
|
113
|
-
printable_name: ->(comment) { "comment \"#{comment.body}\"" },
|
114
|
-
dependent_notifications: :delete_all,
|
115
|
-
optional_targets: optional_targets
|
116
|
-
|
117
|
-
# For testing
|
118
|
-
acts_as_group
|
119
|
-
|
120
|
-
def article_notifiable_path
|
121
|
-
article_path(article)
|
122
|
-
end
|
123
|
-
|
124
|
-
def author?(user)
|
125
|
-
self.user == user
|
126
|
-
end
|
79
|
+
include CommentModel
|
127
80
|
end
|
128
81
|
end
|
@@ -1,30 +1,47 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
module UserModel
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
devise :database_authenticatable, :confirmable
|
6
|
+
include DeviseTokenAuth::Concerns::User
|
4
7
|
validates :email, presence: true
|
5
|
-
has_many :articles, dependent: :destroy
|
6
8
|
has_one :admin, dependent: :destroy
|
9
|
+
has_many :articles, dependent: :destroy
|
10
|
+
|
11
|
+
acts_as_target email: :email,
|
12
|
+
email_allowed: :confirmed_at, batch_email_allowed: :confirmed_at,
|
13
|
+
subscription_allowed: true,
|
14
|
+
action_cable_allowed: true, action_cable_with_devise: true,
|
15
|
+
printable_name: :name
|
7
16
|
|
8
|
-
acts_as_target email: :email, email_allowed: :confirmed_at, batch_email_allowed: :confirmed_at,
|
9
|
-
subscription_allowed: true, printable_name: :name,
|
10
|
-
action_cable_allowed: true, action_cable_with_devise: true
|
11
17
|
acts_as_notifier printable_name: :name
|
18
|
+
end
|
12
19
|
|
13
|
-
|
14
|
-
|
15
|
-
|
20
|
+
def admin?
|
21
|
+
admin.present?
|
22
|
+
end
|
23
|
+
|
24
|
+
def as_json(options = {})
|
25
|
+
options[:include] = (options[:include] || {}).merge(admin: { methods: [:printable_target_name, :notification_action_cable_allowed?, :notification_action_cable_with_devise?] })
|
26
|
+
options[:methods] = (options[:methods] || []).push(:printable_target_name, :notification_action_cable_allowed?, :notification_action_cable_with_devise?)
|
27
|
+
super(options)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
unless ENV['AN_TEST_DB'] == 'mongodb'
|
32
|
+
class User < ActiveRecord::Base
|
33
|
+
include UserModel
|
34
|
+
default_scope { order(:id) }
|
16
35
|
end
|
17
36
|
else
|
18
37
|
require 'mongoid'
|
38
|
+
require 'mongoid-locker'
|
19
39
|
class User
|
20
40
|
include Mongoid::Document
|
21
41
|
include Mongoid::Timestamps
|
42
|
+
include Mongoid::Locker
|
22
43
|
include GlobalID::Identification
|
23
44
|
|
24
|
-
devise :database_authenticatable, :registerable, :confirmable
|
25
|
-
has_many :articles, dependent: :destroy
|
26
|
-
has_one :admin, dependent: :destroy
|
27
|
-
validates :email, presence: true
|
28
45
|
# Devise
|
29
46
|
## Database authenticatable
|
30
47
|
field :email, type: String, default: ""
|
@@ -33,17 +50,23 @@ else
|
|
33
50
|
field :confirmation_token, type: String
|
34
51
|
field :confirmed_at, type: Time
|
35
52
|
field :confirmation_sent_at, type: Time
|
53
|
+
## Required
|
54
|
+
field :provider, type: String, default: "email"
|
55
|
+
field :uid, type: String, default: ""
|
56
|
+
## Tokens
|
57
|
+
field :tokens, type: Hash, default: {}
|
36
58
|
# Apps
|
37
59
|
field :name, type: String
|
38
60
|
|
39
61
|
include ActivityNotification::Models
|
40
|
-
|
41
|
-
subscription_allowed: true, printable_name: :name,
|
42
|
-
action_cable_allowed: true, action_cable_with_devise: true
|
43
|
-
acts_as_notifier printable_name: :name
|
62
|
+
include UserModel
|
44
63
|
|
45
|
-
|
46
|
-
|
64
|
+
# To avoid Devise Token Auth issue
|
65
|
+
# https://github.com/lynndylanhurley/devise_token_auth/issues/1335
|
66
|
+
if Rails::VERSION::MAJOR == 6
|
67
|
+
def saved_change_to_attribute?(attr_name, **options)
|
68
|
+
true
|
69
|
+
end
|
47
70
|
end
|
48
71
|
end
|
49
72
|
end
|
data/spec/rails_app/app/views/activity_notification/notifications/default/article/_update.html.erb
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
<% content_for :notification_content, flush: true do %>
|
2
|
+
<div class='notification_list <%= notification.opened? ? "opened" : "unopened" %>'>
|
3
|
+
<div class="notification_list_cover"></div>
|
4
|
+
<div class="list_image"></div>
|
5
|
+
<div class="list_text_wrapper">
|
6
|
+
<p class="list_text">
|
7
|
+
<strong><%= notification.notifier.name %></strong> updated his or her article "<%= notification.notifiable.title %>".
|
8
|
+
<br>
|
9
|
+
<span><%= notification.created_at.strftime("%b %d %H:%M") %></span>
|
10
|
+
</p>
|
11
|
+
</div>
|
12
|
+
</div>
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
<div class='<%= "notification_#{notification.id}" %>'>
|
16
|
+
<% if notification.unopened? %>
|
17
|
+
<%= link_to open_notification_path_for(notification, parameters.slice(:routing_scope, :devise_default_routes).merge(reload: false)), method: :put, remote: true, class: "unopened_wrapper" do %>
|
18
|
+
<div class="unopened_circle"></div>
|
19
|
+
<div class="unopened_description_wrapper">
|
20
|
+
<p class="unopened_description">Open</p>
|
21
|
+
</div>
|
22
|
+
<% end %>
|
23
|
+
<%= link_to open_notification_path_for(notification, parameters.slice(:routing_scope, :devise_default_routes).merge(move: true)), method: :put do %>
|
24
|
+
<%= yield :notification_content %>
|
25
|
+
<% end %>
|
26
|
+
<div class="unopened_wrapper"></div>
|
27
|
+
<% else %>
|
28
|
+
<%= link_to move_notification_path_for(notification, parameters.slice(:routing_scope, :devise_default_routes)) do %>
|
29
|
+
<%= yield :notification_content %>
|
30
|
+
<% end %>
|
31
|
+
<% end %>
|
32
|
+
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<style>
|
36
|
+
/* unopened_circle */
|
37
|
+
.unopened_wrapper{
|
38
|
+
position: absolute;
|
39
|
+
margin-top: 20px;
|
40
|
+
margin-left: 56px;
|
41
|
+
}
|
42
|
+
.unopened_wrapper .unopened_circle {
|
43
|
+
display: block;
|
44
|
+
width: 10px;
|
45
|
+
height: 10px;
|
46
|
+
position: absolute;
|
47
|
+
border-radius: 50%;
|
48
|
+
background-color: #27a5eb;
|
49
|
+
z-index: 2;
|
50
|
+
}
|
51
|
+
.unopened_wrapper:hover > .unopened_description_wrapper{
|
52
|
+
display: block;
|
53
|
+
}
|
54
|
+
.unopened_wrapper .unopened_description_wrapper {
|
55
|
+
display: none;
|
56
|
+
position: absolute;
|
57
|
+
margin-top: 26px;
|
58
|
+
margin-left: -24px;
|
59
|
+
}
|
60
|
+
.unopened_wrapper .unopened_description_wrapper .unopened_description {
|
61
|
+
position: absolute;
|
62
|
+
color: #fff;
|
63
|
+
font-size: 12px;
|
64
|
+
text-align: center;
|
65
|
+
|
66
|
+
border-radius: 4px;
|
67
|
+
background: rgba(0, 0, 0, 0.8);
|
68
|
+
padding: 4px 12px;
|
69
|
+
z-index: 999;
|
70
|
+
}
|
71
|
+
.unopened_wrapper .unopened_description_wrapper .unopened_description:before {
|
72
|
+
border: solid transparent;
|
73
|
+
border-top-width: 0;
|
74
|
+
content: "";
|
75
|
+
display: block;
|
76
|
+
position: absolute;
|
77
|
+
width: 0;
|
78
|
+
left: 50%;
|
79
|
+
top: -5px;
|
80
|
+
margin-left: -5px;
|
81
|
+
height: 0;
|
82
|
+
border-width: 0 5px 5px 5px;
|
83
|
+
border-color: transparent transparent rgba(0, 0, 0, 0.8) transparent;
|
84
|
+
z-index: 0;
|
85
|
+
}
|
86
|
+
|
87
|
+
/* list */
|
88
|
+
.notification_list {
|
89
|
+
padding: 15px 10px;
|
90
|
+
position: relative;
|
91
|
+
border-bottom: 1px solid #e5e5e5;
|
92
|
+
}
|
93
|
+
.notification_list.unopened {
|
94
|
+
background-color: #eeeff4;
|
95
|
+
}
|
96
|
+
.notification_list:hover {
|
97
|
+
background-color: #f8f9fb;
|
98
|
+
}
|
99
|
+
.notification_list:last-child {
|
100
|
+
border-bottom: none;
|
101
|
+
}
|
102
|
+
.notification_list:after{
|
103
|
+
content: "";
|
104
|
+
clear: both;
|
105
|
+
display: block;
|
106
|
+
}
|
107
|
+
.notification_list .notification_list_cover{
|
108
|
+
position: absolute;
|
109
|
+
opacity: 0;
|
110
|
+
top: 0;
|
111
|
+
left: 0;
|
112
|
+
width: 100%;
|
113
|
+
height: 100%;
|
114
|
+
z-index: 1;
|
115
|
+
|
116
|
+
}
|
117
|
+
.notification_list .list_image {
|
118
|
+
float: left;
|
119
|
+
width: 40px;
|
120
|
+
height: 40px;
|
121
|
+
background-position: center;
|
122
|
+
background-repeat: no-repeat;
|
123
|
+
background-size: cover;
|
124
|
+
background-color: #979797;
|
125
|
+
}
|
126
|
+
.notification_list .list_text_wrapper {
|
127
|
+
float: left;
|
128
|
+
width: calc(100% - 60px);
|
129
|
+
margin-left: 20px;
|
130
|
+
}
|
131
|
+
.notification_list .list_text_wrapper .list_text {
|
132
|
+
color: #4f4f4f;
|
133
|
+
font-size: 14px;
|
134
|
+
line-height: 1.4;
|
135
|
+
margin-top: 0;
|
136
|
+
height: auto;
|
137
|
+
font-weight: normal;
|
138
|
+
}
|
139
|
+
.notification_list .list_text_wrapper .list_text strong{
|
140
|
+
font-weight: bold;
|
141
|
+
}
|
142
|
+
.notification_list .list_text_wrapper .list_text span {
|
143
|
+
color: #979797;
|
144
|
+
font-size: 13px;
|
145
|
+
}
|
146
|
+
</style>
|
@@ -1,4 +1,26 @@
|
|
1
|
-
<% if @
|
1
|
+
<% if @exists_notifications_routes %>
|
2
|
+
<section>
|
3
|
+
<h1>Authentecated User</h1>
|
4
|
+
<div class="list_wrapper">
|
5
|
+
<div class="list_image"></div>
|
6
|
+
<div class="list_description_wrapper">
|
7
|
+
<p class="list_description">
|
8
|
+
<% if user_signed_in? %>
|
9
|
+
<span><%= current_user.name %></span> · <%= current_user.email %> · <%= link_to 'Logout', destroy_user_session_path, method: :delete %><br>
|
10
|
+
<% else %>
|
11
|
+
<span>Not logged in</span> · <%= link_to 'Login', new_user_session_path %><br>
|
12
|
+
<% end %>
|
13
|
+
<%= link_to 'Notifications', notifications_path %> /
|
14
|
+
<% if User.subscription_enabled? %>
|
15
|
+
<%= link_to 'Subscriptions', subscriptions_path %>
|
16
|
+
<% end %>
|
17
|
+
</p>
|
18
|
+
</div>
|
19
|
+
</div>
|
20
|
+
</section>
|
21
|
+
<% end %>
|
22
|
+
|
23
|
+
<% if @exists_user_notifications_routes %>
|
2
24
|
<section>
|
3
25
|
<h1>Listing Users</h1>
|
4
26
|
<% User.all.each do |user| %>
|
@@ -7,7 +29,7 @@
|
|
7
29
|
<div class="list_description_wrapper">
|
8
30
|
<p class="list_description">
|
9
31
|
<span><%= user.name %></span> · <%= user.email %><br>
|
10
|
-
<%= link_to 'Notifications', user_notifications_path(user) %>
|
32
|
+
<%= link_to 'Notifications', user_notifications_path(user) %> /
|
11
33
|
<% if User.subscription_enabled? %>
|
12
34
|
<%= link_to 'Subscriptions', user_subscriptions_path(user) %>
|
13
35
|
<% end %>
|
@@ -18,7 +40,29 @@
|
|
18
40
|
</section>
|
19
41
|
<% end %>
|
20
42
|
|
21
|
-
<% if @
|
43
|
+
<% if @exists_admins_notifications_routes %>
|
44
|
+
<section>
|
45
|
+
<h1>Authentecated User as Admin</h1>
|
46
|
+
<div class="list_wrapper">
|
47
|
+
<div class="list_image"></div>
|
48
|
+
<div class="list_description_wrapper">
|
49
|
+
<p class="list_description">
|
50
|
+
<% if user_signed_in? %>
|
51
|
+
<span><%= current_user.name %></span> · <%= current_user.email %> <span><%= current_user.admin? ? "(admin)" : "(not admin)" %></span><br>
|
52
|
+
<% else %>
|
53
|
+
<span>Not logged in</span> · <%= link_to 'Login', new_user_session_path %><br>
|
54
|
+
<% end %>
|
55
|
+
<%= link_to 'Notifications', admins_notifications_path %> /
|
56
|
+
<% if User.subscription_enabled? %>
|
57
|
+
<%= link_to 'Subscriptions', admins_subscriptions_path %>
|
58
|
+
<% end %>
|
59
|
+
</p>
|
60
|
+
</div>
|
61
|
+
</div>
|
62
|
+
</section>
|
63
|
+
<% end %>
|
64
|
+
|
65
|
+
<% if @exists_admin_notifications_routes %>
|
22
66
|
<section>
|
23
67
|
<h1>Listing Admins</h1>
|
24
68
|
<% Admin.all.each do |admin| %>
|
@@ -27,7 +71,7 @@
|
|
27
71
|
<div class="list_description_wrapper">
|
28
72
|
<p class="list_description">
|
29
73
|
<span><%= admin.user.name %></span> · <%= admin.user.email %><br>
|
30
|
-
<%= link_to 'Notifications', admin_notifications_path(admin) %>
|
74
|
+
<%= link_to 'Notifications', admin_notifications_path(admin) %> /
|
31
75
|
<% if Admin.subscription_enabled? %>
|
32
76
|
<%= link_to 'Subscriptions', admin_subscriptions_path(admin) %>
|
33
77
|
<% end %>
|
@@ -59,9 +103,9 @@
|
|
59
103
|
<% if user_signed_in? and article.author?(current_user) %>
|
60
104
|
<%= link_to 'Edit Article', edit_article_path(article), class: "gray_button" %>
|
61
105
|
<% end %>
|
62
|
-
|
63
|
-
|
64
|
-
|
106
|
+
<%# if user_signed_in? and (article.author?(current_user) or current_user.admin?) %>
|
107
|
+
<%#= link_to 'Destroy Article', article, method: :delete, data: { confirm: 'Are you sure?' }, class: "gray_button" %>
|
108
|
+
<%# end %>
|
65
109
|
</div>
|
66
110
|
</div>
|
67
111
|
</div>
|