radiant-group_forum-extension 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/group_forum_extension.rb +3 -1
- data/lib/grouped_post.rb +28 -0
- data/lib/grouped_topic.rb +28 -0
- data/radiant-group_forum-extension.gemspec +10 -8
- data/spec/models/forum_spec.rb +11 -2
- metadata +15 -9
data/Rakefile
CHANGED
@@ -8,8 +8,8 @@ begin
|
|
8
8
|
gem.homepage = "http://github.com/spanner/radiant-group_forum-extension"
|
9
9
|
gem.authors = ["spanner"]
|
10
10
|
gem.add_dependency "radiant", ">= 0.9.0"
|
11
|
-
gem.add_dependency 'radiant-forum-extension'
|
12
|
-
gem.add_dependency 'radiant-reader_group-extension'
|
11
|
+
gem.add_dependency 'radiant-forum-extension', ">= 2.0.0"
|
12
|
+
gem.add_dependency 'radiant-reader_group-extension', ">= 1.2.0"
|
13
13
|
end
|
14
14
|
rescue LoadError
|
15
15
|
puts "Jeweler (or a dependency) not available. This is only required if you plan to package group_forum as a gem."
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
data/group_forum_extension.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
class GroupForumExtension < Radiant::Extension
|
2
|
-
version "0.
|
2
|
+
version "0.6.0"
|
3
3
|
description "Just a bit of access-control glue joining reader_groups to forum"
|
4
4
|
url "http://spanner.org/radiant/group_forums"
|
5
5
|
|
6
6
|
def activate
|
7
7
|
Forum.send :has_groups
|
8
|
+
Topic.send :include, GroupedTopic # scopes and retrieval methods that check forum group permissions
|
9
|
+
Post.send :include, GroupedPost # (giving Post and Topic the same visibility calls as Forum even though they don't have direct group links)
|
8
10
|
Page.send :include, GroupForumTags # a few tags for listing forums and latest topics on group pages
|
9
11
|
ForumBaseController.send :include, GroupedControllerExtensions
|
10
12
|
|
data/lib/grouped_post.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
module GroupedPost
|
2
|
+
|
3
|
+
def self.included(base)
|
4
|
+
base.class_eval {
|
5
|
+
# this overwrites the similarly named stub method in Topic
|
6
|
+
named_scope :visible_to, lambda { |reader|
|
7
|
+
if reader.nil? || reader.groups.empty?
|
8
|
+
conditions = "pp.group_id IS NULL"
|
9
|
+
else
|
10
|
+
ids = reader.group_ids
|
11
|
+
conditions = reader.nil? ? "pp.group_id IS NULL" : ["pp.group_id IS NULL OR pp.group_id IN(#{ids.map{"?"}.join(',')})", *ids]
|
12
|
+
end
|
13
|
+
{
|
14
|
+
:joins => "INNER JOIN topics on posts.topic_id = topics.id INNER JOIN forums on topics.forum_id = forums.id LEFT OUTER JOIN permissions as pp on pp.permitted_id = forums.id AND pp.permitted_type = 'Forum'",
|
15
|
+
:group => column_names.map { |n| self.table_name + '.' + n }.join(','),
|
16
|
+
:conditions => conditions
|
17
|
+
}
|
18
|
+
} do
|
19
|
+
def count
|
20
|
+
length
|
21
|
+
end
|
22
|
+
end
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module GroupedTopic
|
2
|
+
|
3
|
+
def self.included(base)
|
4
|
+
base.class_eval {
|
5
|
+
# this overwrites the similarly named stub method in Topic
|
6
|
+
named_scope :visible_to, lambda { |reader|
|
7
|
+
if reader.nil? || reader.groups.empty?
|
8
|
+
conditions = "pp.group_id IS NULL"
|
9
|
+
else
|
10
|
+
ids = reader.group_ids
|
11
|
+
conditions = reader.nil? ? "pp.group_id IS NULL" : ["pp.group_id IS NULL OR pp.group_id IN(#{ids.map{"?"}.join(',')})", *ids]
|
12
|
+
end
|
13
|
+
{
|
14
|
+
:joins => "INNER JOIN forums on topics.forum_id = forums.id LEFT OUTER JOIN permissions as pp on pp.permitted_id = forums.id AND pp.permitted_type = 'Forum'",
|
15
|
+
:group => column_names.map { |n| self.table_name + '.' + n }.join(','),
|
16
|
+
:conditions => conditions
|
17
|
+
}
|
18
|
+
} do
|
19
|
+
def count
|
20
|
+
length
|
21
|
+
end
|
22
|
+
end
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{radiant-group_forum-extension}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.6.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{2011-02-
|
12
|
+
s.date = %q{2011-02-16}
|
13
13
|
s.description = %q{A bit of glue to add group-based access control to the radiant forum.}
|
14
14
|
s.email = %q{will@spanner.org}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -27,6 +27,8 @@ Gem::Specification.new do |s|
|
|
27
27
|
"group_forum_extension.rb",
|
28
28
|
"lib/group_forum_tags.rb",
|
29
29
|
"lib/grouped_controller_extensions.rb",
|
30
|
+
"lib/grouped_post.rb",
|
31
|
+
"lib/grouped_topic.rb",
|
30
32
|
"lib/tasks/group_forum_extension_tasks.rake",
|
31
33
|
"radiant-group_forum-extension.gemspec",
|
32
34
|
"spec/datasets/group_forum_forums_dataset.rb",
|
@@ -59,17 +61,17 @@ Gem::Specification.new do |s|
|
|
59
61
|
|
60
62
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
61
63
|
s.add_runtime_dependency(%q<radiant>, [">= 0.9.0"])
|
62
|
-
s.add_runtime_dependency(%q<radiant-forum-extension>, [">= 0"])
|
63
|
-
s.add_runtime_dependency(%q<radiant-reader_group-extension>, [">= 0"])
|
64
|
+
s.add_runtime_dependency(%q<radiant-forum-extension>, [">= 2.0.0"])
|
65
|
+
s.add_runtime_dependency(%q<radiant-reader_group-extension>, [">= 1.2.0"])
|
64
66
|
else
|
65
67
|
s.add_dependency(%q<radiant>, [">= 0.9.0"])
|
66
|
-
s.add_dependency(%q<radiant-forum-extension>, [">= 0"])
|
67
|
-
s.add_dependency(%q<radiant-reader_group-extension>, [">= 0"])
|
68
|
+
s.add_dependency(%q<radiant-forum-extension>, [">= 2.0.0"])
|
69
|
+
s.add_dependency(%q<radiant-reader_group-extension>, [">= 1.2.0"])
|
68
70
|
end
|
69
71
|
else
|
70
72
|
s.add_dependency(%q<radiant>, [">= 0.9.0"])
|
71
|
-
s.add_dependency(%q<radiant-forum-extension>, [">= 0"])
|
72
|
-
s.add_dependency(%q<radiant-reader_group-extension>, [">= 0"])
|
73
|
+
s.add_dependency(%q<radiant-forum-extension>, [">= 2.0.0"])
|
74
|
+
s.add_dependency(%q<radiant-reader_group-extension>, [">= 1.2.0"])
|
73
75
|
end
|
74
76
|
end
|
75
77
|
|
data/spec/models/forum_spec.rb
CHANGED
@@ -11,8 +11,17 @@ describe Forum do
|
|
11
11
|
Forum.reflect_on_association(:groups).should_not be_nil
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
describe "without a grouped reader" do
|
15
|
+
it "should list only the ungrouped forums" do
|
16
|
+
Forum.visible.count.should == 1
|
17
|
+
Forum.visible_to(readers(:ungrouped)).count.should == 1
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "to a grouped reader" do
|
22
|
+
it "should list also the forums of that group" do
|
23
|
+
Forum.visible_to(readers(:normal)).count.should == 3
|
24
|
+
end
|
16
25
|
end
|
17
26
|
|
18
27
|
describe "with a group" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: radiant-group_forum-extension
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 6
|
9
|
+
- 0
|
10
|
+
version: 0.6.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: 2011-02-
|
18
|
+
date: 2011-02-16 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -42,10 +42,12 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
hash:
|
45
|
+
hash: 15
|
46
46
|
segments:
|
47
|
+
- 2
|
48
|
+
- 0
|
47
49
|
- 0
|
48
|
-
version:
|
50
|
+
version: 2.0.0
|
49
51
|
type: :runtime
|
50
52
|
version_requirements: *id002
|
51
53
|
- !ruby/object:Gem::Dependency
|
@@ -56,10 +58,12 @@ dependencies:
|
|
56
58
|
requirements:
|
57
59
|
- - ">="
|
58
60
|
- !ruby/object:Gem::Version
|
59
|
-
hash:
|
61
|
+
hash: 31
|
60
62
|
segments:
|
63
|
+
- 1
|
64
|
+
- 2
|
61
65
|
- 0
|
62
|
-
version:
|
66
|
+
version: 1.2.0
|
63
67
|
type: :runtime
|
64
68
|
version_requirements: *id003
|
65
69
|
description: A bit of glue to add group-based access control to the radiant forum.
|
@@ -82,6 +86,8 @@ files:
|
|
82
86
|
- group_forum_extension.rb
|
83
87
|
- lib/group_forum_tags.rb
|
84
88
|
- lib/grouped_controller_extensions.rb
|
89
|
+
- lib/grouped_post.rb
|
90
|
+
- lib/grouped_topic.rb
|
85
91
|
- lib/tasks/group_forum_extension_tasks.rake
|
86
92
|
- radiant-group_forum-extension.gemspec
|
87
93
|
- spec/datasets/group_forum_forums_dataset.rb
|