enju_question 0.1.0.pre5 → 0.1.0.pre6
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.
- checksums.yaml +4 -4
- data/app/models/enju_question/ability.rb +44 -0
- data/lib/enju_question.rb +4 -0
- data/lib/enju_question/item.rb +14 -0
- data/lib/enju_question/manifestation.rb +33 -0
- data/lib/enju_question/version.rb +1 -1
- data/spec/dummy/app/models/ability.rb +40 -38
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/solr/data/test/index/{_3e.fdt → _4m.fdt} +0 -0
- data/spec/dummy/solr/data/test/index/{_3e.fdx → _4m.fdx} +0 -0
- data/spec/dummy/solr/data/test/index/{_3e.fnm → _4m.fnm} +0 -0
- data/spec/dummy/solr/data/test/index/{_3e.frq → _4m.frq} +0 -0
- data/spec/dummy/solr/data/test/index/{_3e.nrm → _4m.nrm} +0 -0
- data/spec/dummy/solr/data/test/index/{_3e.prx → _4m.prx} +0 -0
- data/spec/dummy/solr/data/test/index/{_3e.tii → _4m.tii} +0 -0
- data/spec/dummy/solr/data/test/index/{_3e.tis → _4m.tis} +0 -0
- data/spec/dummy/solr/data/test/index/segments.gen +0 -0
- data/spec/dummy/solr/data/test/index/{segments_6t → segments_99} +0 -0
- metadata +25 -22
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ac98a495fd5e15eebfb7fbb906fdf553318224f3
|
|
4
|
+
data.tar.gz: 0dd06e0911c3a478cdfbdfa1aa01a87de9672c8e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fa616ed9597483be2c7e47d7ba270a4a6b289c4f8650371b0e6ca4932dda26e4074c9503b1f629d3e7b577708fa06bb495d941a98060ef542ba460e68d659662
|
|
7
|
+
data.tar.gz: 01565cefe42e83e5a87cb5b3937ef1eec64491a3fd5f9581187c41484f7a106515f8d138aeee9bd08f6e6b01136adefc0e2c03005043f4c4de73313c17f2956b
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
module EnjuQuestion
|
|
2
|
+
class Ability
|
|
3
|
+
include CanCan::Ability
|
|
4
|
+
|
|
5
|
+
def initialize(user, ip_address = nil)
|
|
6
|
+
case user.try(:role).try(:name)
|
|
7
|
+
when 'Administrator'
|
|
8
|
+
can :manage, Answer
|
|
9
|
+
can :manage, Question
|
|
10
|
+
when 'Librarian'
|
|
11
|
+
can :manage, Answer
|
|
12
|
+
can :manage, Question
|
|
13
|
+
when 'User'
|
|
14
|
+
can [:index, :create], Answer
|
|
15
|
+
can :show, Answer do |answer|
|
|
16
|
+
if answer.user == user
|
|
17
|
+
true
|
|
18
|
+
elsif answer.question.shared
|
|
19
|
+
true
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
can [:update, :destroy], Answer do |answer|
|
|
23
|
+
answer.user == user
|
|
24
|
+
end
|
|
25
|
+
can [:index, :create], Question
|
|
26
|
+
can [:update, :destroy], Question do |question|
|
|
27
|
+
question.user == user
|
|
28
|
+
end
|
|
29
|
+
can :show, Question do |question|
|
|
30
|
+
question.user == user or question.shared
|
|
31
|
+
end
|
|
32
|
+
else
|
|
33
|
+
can :index, Answer
|
|
34
|
+
can :show, Answer do |answer|
|
|
35
|
+
answer.question.shared
|
|
36
|
+
end
|
|
37
|
+
can :index, Question
|
|
38
|
+
can :show, Question do |question|
|
|
39
|
+
question.shared
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
data/lib/enju_question.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
require "enju_question/engine"
|
|
2
2
|
require "enju_question/user"
|
|
3
|
+
require "enju_question/manifestation"
|
|
4
|
+
require "enju_question/item"
|
|
3
5
|
|
|
4
6
|
module EnjuQuestion
|
|
5
7
|
def self.included(base)
|
|
@@ -24,3 +26,5 @@ end
|
|
|
24
26
|
|
|
25
27
|
ActionController::Base.send(:include, EnjuQuestion)
|
|
26
28
|
ActiveRecord::Base.send :include, EnjuQuestion::QuestionUser
|
|
29
|
+
ActiveRecord::Base.send :include, EnjuQuestion::QuestionManifestation
|
|
30
|
+
ActiveRecord::Base.send :include, EnjuQuestion::QuestionItem
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module EnjuQuestion
|
|
2
|
+
module QuestionItem
|
|
3
|
+
def self.included(base)
|
|
4
|
+
base.extend ClassMethods
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
module ClassMethods
|
|
8
|
+
def enju_question_item_model
|
|
9
|
+
has_many :answer_has_items, :dependent => :destroy
|
|
10
|
+
has_many :answers, :through => :answer_has_items
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module EnjuQuestion
|
|
2
|
+
module QuestionManifestation
|
|
3
|
+
def self.included(base)
|
|
4
|
+
base.extend ClassMethods
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
module ClassMethods
|
|
8
|
+
def enju_question_manifestation_model
|
|
9
|
+
include InstanceMethods
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
module InstanceMethods
|
|
14
|
+
def questions(options = {})
|
|
15
|
+
id = self.id
|
|
16
|
+
options = {:page => 1, :per_page => Question.default_per_page}.merge(options)
|
|
17
|
+
page = options[:page]
|
|
18
|
+
per_page = options[:per_page]
|
|
19
|
+
user = options[:user]
|
|
20
|
+
Question.search do
|
|
21
|
+
with(:manifestation_id).equal_to id
|
|
22
|
+
any_of do
|
|
23
|
+
unless user.try(:has_role?, 'Librarian')
|
|
24
|
+
with(:shared).equal_to true
|
|
25
|
+
# with(:username).equal_to user.try(:username)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
paginate :page => page, :per_page => per_page
|
|
29
|
+
end.results
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -1,42 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
#module EnjuQuestion
|
|
2
|
+
class Ability
|
|
3
|
+
include CanCan::Ability
|
|
4
|
+
|
|
5
|
+
def initialize(user, ip_address = nil)
|
|
6
|
+
case user.try(:role).try(:name)
|
|
7
|
+
when 'Administrator'
|
|
8
|
+
can :manage, Answer
|
|
9
|
+
can :manage, Question
|
|
10
|
+
when 'Librarian'
|
|
11
|
+
can :manage, Answer
|
|
12
|
+
can :manage, Question
|
|
13
|
+
when 'User'
|
|
14
|
+
can [:index, :create], Answer
|
|
15
|
+
can :show, Answer do |answer|
|
|
16
|
+
if answer.user == user
|
|
17
|
+
true
|
|
18
|
+
elsif answer.question.shared
|
|
19
|
+
true
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
can [:update, :destroy], Answer do |answer|
|
|
23
|
+
answer.user == user
|
|
24
|
+
end
|
|
25
|
+
can [:index, :create], Question
|
|
26
|
+
can [:update, :destroy], Question do |question|
|
|
27
|
+
question.user == user
|
|
28
|
+
end
|
|
29
|
+
can :show, Question do |question|
|
|
30
|
+
question.user == user or question.shared
|
|
31
|
+
end
|
|
32
|
+
else
|
|
33
|
+
can :index, Answer
|
|
34
|
+
can :show, Answer do |answer|
|
|
35
|
+
answer.question.shared
|
|
36
|
+
end
|
|
37
|
+
can :index, Question
|
|
38
|
+
can :show, Question do |question|
|
|
39
|
+
question.shared
|
|
19
40
|
end
|
|
20
|
-
end
|
|
21
|
-
can [:update, :destroy], Answer do |answer|
|
|
22
|
-
answer.user == user
|
|
23
|
-
end
|
|
24
|
-
can [:index, :create], Question
|
|
25
|
-
can [:update, :destroy], Question do |question|
|
|
26
|
-
question.user == user
|
|
27
|
-
end
|
|
28
|
-
can :show, Question do |question|
|
|
29
|
-
question.user == user or question.shared
|
|
30
|
-
end
|
|
31
|
-
else
|
|
32
|
-
can :index, Answer
|
|
33
|
-
can :show, Answer do |answer|
|
|
34
|
-
answer.question.shared
|
|
35
|
-
end
|
|
36
|
-
can :index, Question
|
|
37
|
-
can :show, Question do |question|
|
|
38
|
-
question.shared
|
|
39
41
|
end
|
|
40
42
|
end
|
|
41
43
|
end
|
|
42
|
-
end
|
|
44
|
+
#end
|
data/spec/dummy/db/test.sqlite3
CHANGED
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: enju_question
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.0.
|
|
4
|
+
version: 0.1.0.pre6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kosuke Tanabe
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2013-03-
|
|
11
|
+
date: 2013-03-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -128,14 +128,14 @@ dependencies:
|
|
|
128
128
|
requirements:
|
|
129
129
|
- - ~>
|
|
130
130
|
- !ruby/object:Gem::Version
|
|
131
|
-
version: 0.1.0.
|
|
131
|
+
version: 0.1.0.pre23
|
|
132
132
|
type: :development
|
|
133
133
|
prerelease: false
|
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
|
135
135
|
requirements:
|
|
136
136
|
- - ~>
|
|
137
137
|
- !ruby/object:Gem::Version
|
|
138
|
-
version: 0.1.0.
|
|
138
|
+
version: 0.1.0.pre23
|
|
139
139
|
- !ruby/object:Gem::Dependency
|
|
140
140
|
name: enju_ndl
|
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -189,6 +189,7 @@ files:
|
|
|
189
189
|
- app/controllers/questions_controller.rb
|
|
190
190
|
- app/models/answer.rb
|
|
191
191
|
- app/models/answer_has_item.rb
|
|
192
|
+
- app/models/enju_question/ability.rb
|
|
192
193
|
- app/models/question.rb
|
|
193
194
|
- app/models/question_sweeper.rb
|
|
194
195
|
- app/views/answers/_form.html.erb
|
|
@@ -223,6 +224,8 @@ files:
|
|
|
223
224
|
- db/migrate/20100217054028_create_answer_has_items.rb
|
|
224
225
|
- db/migrate/20120418124018_add_answer_feed_token_to_user.rb
|
|
225
226
|
- lib/enju_question/engine.rb
|
|
227
|
+
- lib/enju_question/item.rb
|
|
228
|
+
- lib/enju_question/manifestation.rb
|
|
226
229
|
- lib/enju_question/user.rb
|
|
227
230
|
- lib/enju_question/version.rb
|
|
228
231
|
- lib/enju_question.rb
|
|
@@ -367,16 +370,16 @@ files:
|
|
|
367
370
|
- spec/dummy/solr/conf/spellings.txt
|
|
368
371
|
- spec/dummy/solr/conf/stopwords.txt
|
|
369
372
|
- spec/dummy/solr/conf/synonyms.txt
|
|
370
|
-
- spec/dummy/solr/data/test/index/
|
|
371
|
-
- spec/dummy/solr/data/test/index/
|
|
372
|
-
- spec/dummy/solr/data/test/index/
|
|
373
|
-
- spec/dummy/solr/data/test/index/
|
|
374
|
-
- spec/dummy/solr/data/test/index/
|
|
375
|
-
- spec/dummy/solr/data/test/index/
|
|
376
|
-
- spec/dummy/solr/data/test/index/
|
|
377
|
-
- spec/dummy/solr/data/test/index/
|
|
373
|
+
- spec/dummy/solr/data/test/index/_4m.fdt
|
|
374
|
+
- spec/dummy/solr/data/test/index/_4m.fdx
|
|
375
|
+
- spec/dummy/solr/data/test/index/_4m.fnm
|
|
376
|
+
- spec/dummy/solr/data/test/index/_4m.frq
|
|
377
|
+
- spec/dummy/solr/data/test/index/_4m.nrm
|
|
378
|
+
- spec/dummy/solr/data/test/index/_4m.prx
|
|
379
|
+
- spec/dummy/solr/data/test/index/_4m.tii
|
|
380
|
+
- spec/dummy/solr/data/test/index/_4m.tis
|
|
378
381
|
- spec/dummy/solr/data/test/index/segments.gen
|
|
379
|
-
- spec/dummy/solr/data/test/index/
|
|
382
|
+
- spec/dummy/solr/data/test/index/segments_99
|
|
380
383
|
- spec/dummy/solr/data/test/spellchecker/segments.gen
|
|
381
384
|
- spec/dummy/solr/data/test/spellchecker/segments_1
|
|
382
385
|
- spec/factories/answer.rb
|
|
@@ -555,16 +558,16 @@ test_files:
|
|
|
555
558
|
- spec/dummy/solr/conf/spellings.txt
|
|
556
559
|
- spec/dummy/solr/conf/stopwords.txt
|
|
557
560
|
- spec/dummy/solr/conf/synonyms.txt
|
|
558
|
-
- spec/dummy/solr/data/test/index/
|
|
559
|
-
- spec/dummy/solr/data/test/index/
|
|
560
|
-
- spec/dummy/solr/data/test/index/
|
|
561
|
-
- spec/dummy/solr/data/test/index/
|
|
562
|
-
- spec/dummy/solr/data/test/index/
|
|
563
|
-
- spec/dummy/solr/data/test/index/
|
|
564
|
-
- spec/dummy/solr/data/test/index/
|
|
565
|
-
- spec/dummy/solr/data/test/index/
|
|
561
|
+
- spec/dummy/solr/data/test/index/_4m.fdt
|
|
562
|
+
- spec/dummy/solr/data/test/index/_4m.fdx
|
|
563
|
+
- spec/dummy/solr/data/test/index/_4m.fnm
|
|
564
|
+
- spec/dummy/solr/data/test/index/_4m.frq
|
|
565
|
+
- spec/dummy/solr/data/test/index/_4m.nrm
|
|
566
|
+
- spec/dummy/solr/data/test/index/_4m.prx
|
|
567
|
+
- spec/dummy/solr/data/test/index/_4m.tii
|
|
568
|
+
- spec/dummy/solr/data/test/index/_4m.tis
|
|
566
569
|
- spec/dummy/solr/data/test/index/segments.gen
|
|
567
|
-
- spec/dummy/solr/data/test/index/
|
|
570
|
+
- spec/dummy/solr/data/test/index/segments_99
|
|
568
571
|
- spec/dummy/solr/data/test/spellchecker/segments.gen
|
|
569
572
|
- spec/dummy/solr/data/test/spellchecker/segments_1
|
|
570
573
|
- spec/factories/answer.rb
|