radiant-reader_group-extension 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/app/models/group.rb +1 -1
- data/app/views/admin/groups/show.html.haml +4 -2
- data/lib/grouped_message.rb +1 -1
- data/lib/grouped_model.rb +22 -13
- data/lib/readers_controller_extensions.rb +1 -1
- data/radiant-reader_group-extension.gemspec +2 -2
- data/reader_group_extension.rb +2 -2
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0
|
1
|
+
1.1.0
|
data/app/models/group.rb
CHANGED
@@ -10,6 +10,8 @@
|
|
10
10
|
- render_region :main do |main|
|
11
11
|
- main.messages do
|
12
12
|
#group_messages.box
|
13
|
+
.actions
|
14
|
+
= link_to image('plus') + ' ' + t("create_new_message"), new_admin_group_message_url(@group), :class => 'action create'
|
13
15
|
%h3
|
14
16
|
=t('admin_messages').titlecase
|
15
17
|
- ['welcome', 'invitation'].each do |func|
|
@@ -31,8 +33,6 @@
|
|
31
33
|
- if message.sent_at
|
32
34
|
= t('last_sent')
|
33
35
|
= l(message.sent_at, :format => :short)
|
34
|
-
%p.ruled
|
35
|
-
= link_to image('plus') + ' ' + t("create_new_message"), new_admin_group_message_url(@group), :class => 'action create'
|
36
36
|
|
37
37
|
- main.pages do
|
38
38
|
#group_pages.box
|
@@ -45,6 +45,8 @@
|
|
45
45
|
|
46
46
|
- main.members do
|
47
47
|
#group_people.box
|
48
|
+
.actions
|
49
|
+
= link_to image('plus') + ' ' + t('add_members'), new_admin_group_group_invitation_url(@group), :class => 'action'
|
48
50
|
%h3
|
49
51
|
=t('group_members').titlecase
|
50
52
|
- readers = Reader.find(:all)
|
data/lib/grouped_message.rb
CHANGED
data/lib/grouped_model.rb
CHANGED
@@ -4,25 +4,32 @@ module GroupedModel
|
|
4
4
|
end
|
5
5
|
|
6
6
|
module ClassMethods
|
7
|
-
def
|
7
|
+
def has_group?
|
8
8
|
false
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
12
|
-
return if
|
11
|
+
def has_group(options={})
|
12
|
+
return if has_group?
|
13
13
|
cattr_accessor :group_recipients, :group_donor
|
14
14
|
|
15
15
|
class_eval {
|
16
16
|
extend GroupedModel::GroupedClassMethods
|
17
17
|
include GroupedModel::GroupedInstanceMethods
|
18
18
|
|
19
|
-
|
20
|
-
|
19
|
+
unless instance_methods.include? 'visible_to?'
|
20
|
+
def visible_to?(reader)
|
21
|
+
return true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def visible_to_with_groups?(reader)
|
26
|
+
value_otherwise = visible_to_without_groups?(reader)
|
27
|
+
return value_otherwise unless group
|
21
28
|
return false unless reader
|
22
|
-
return
|
23
|
-
return true if reader.is_in?(group)
|
29
|
+
return value_otherwise if reader.is_in?(group)
|
24
30
|
return false
|
25
31
|
end
|
32
|
+
alias_method_chain :visible_to?, :groups
|
26
33
|
}
|
27
34
|
|
28
35
|
belongs_to :group
|
@@ -38,27 +45,29 @@ module GroupedModel
|
|
38
45
|
before_create :get_group
|
39
46
|
after_save :give_group
|
40
47
|
end
|
48
|
+
alias :is_grouped :has_group
|
49
|
+
alias :is_grouped? :has_group?
|
41
50
|
end
|
42
51
|
|
43
52
|
module GroupedClassMethods
|
44
|
-
def
|
45
|
-
|
53
|
+
def has_group?
|
54
|
+
true
|
46
55
|
end
|
47
56
|
|
48
|
-
def
|
49
|
-
|
57
|
+
def visible
|
58
|
+
ungrouped
|
50
59
|
end
|
51
60
|
|
52
61
|
def gets_group_from(association_name)
|
53
62
|
association = reflect_on_association(association_name)
|
54
63
|
raise StandardError "can't find group source '#{association_name}" unless association
|
55
|
-
raise StandardError "#{association.klass} is not grouped and cannot be a group donor" unless association.klass.
|
64
|
+
raise StandardError "#{association.klass} is not grouped and cannot be a group donor" unless association.klass.has_group?
|
56
65
|
self.group_donor = association_name
|
57
66
|
end
|
58
67
|
|
59
68
|
def gives_group_to(associations)
|
60
69
|
associations = [associations] unless associations.is_a?(Array)
|
61
|
-
# shall we force
|
70
|
+
# shall we force has_group here?
|
62
71
|
# shall we assume that gets_group_from follows? and find the association somehow?
|
63
72
|
self.group_recipients ||= []
|
64
73
|
self.group_recipients += associations
|
@@ -2,7 +2,7 @@ module ReadersControllerExtensions
|
|
2
2
|
|
3
3
|
def self.included(base)
|
4
4
|
base.class_eval { before_filter :ensure_groups_subscribable, :only => [:update, :create] }
|
5
|
-
base.
|
5
|
+
base.add_edit_partial 'readers/memberships'
|
6
6
|
end
|
7
7
|
|
8
8
|
def ensure_groups_subscribable
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{radiant-reader_group-extension}
|
8
|
-
s.version = "1.0
|
8
|
+
s.version = "1.1.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["spanner"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2011-01-27}
|
13
13
|
s.description = %q{Adds group-based page access control to radiant.}
|
14
14
|
s.email = %q{will@spanner.org}
|
15
15
|
s.extra_rdoc_files = [
|
data/reader_group_extension.rb
CHANGED
@@ -10,13 +10,13 @@ module ReaderGroup
|
|
10
10
|
end
|
11
11
|
|
12
12
|
class ReaderGroupExtension < Radiant::Extension
|
13
|
-
version "1.0
|
13
|
+
version "1.1.0"
|
14
14
|
description "Page (and other) access control for site readers and groups"
|
15
15
|
url "http://spanner.org/radiant/reader_group"
|
16
16
|
|
17
17
|
def activate
|
18
18
|
Group
|
19
|
-
ActiveRecord::Base.send :include, GroupedModel #
|
19
|
+
ActiveRecord::Base.send :include, GroupedModel # has_group mechanism for any model that can belong_to a group
|
20
20
|
|
21
21
|
Reader.send :include, GroupedReader # defines group associations
|
22
22
|
Page.send :include, GroupedPage # group associations and visibility decisions
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: radiant-reader_group-extension
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
- 0
|
9
8
|
- 1
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 1.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- spanner
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-01-27 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|