ack-mongoid-forums 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +35 -0
- data/app/assets/javascripts/mongoid_forums/admin/base.js +2 -0
- data/app/assets/javascripts/mongoid_forums/admin/categories.js +2 -0
- data/app/assets/javascripts/mongoid_forums/admin/forums.js +2 -0
- data/app/assets/javascripts/mongoid_forums/admin/groups.js +2 -0
- data/app/assets/javascripts/mongoid_forums/admin/users.js +2 -0
- data/app/assets/javascripts/mongoid_forums/application.js +15 -0
- data/app/assets/javascripts/mongoid_forums/forums.js +2 -0
- data/app/assets/javascripts/mongoid_forums/posts.js +2 -0
- data/app/assets/javascripts/mongoid_forums/topics.js +2 -0
- data/app/assets/stylesheets/mongoid_forums/admin/base.css +4 -0
- data/app/assets/stylesheets/mongoid_forums/admin/categories.css +4 -0
- data/app/assets/stylesheets/mongoid_forums/admin/forums.css +4 -0
- data/app/assets/stylesheets/mongoid_forums/admin/groups.css +4 -0
- data/app/assets/stylesheets/mongoid_forums/admin/users.css +4 -0
- data/app/assets/stylesheets/mongoid_forums/application.css +15 -0
- data/app/assets/stylesheets/mongoid_forums/forums.css +4 -0
- data/app/assets/stylesheets/mongoid_forums/posts.css +4 -0
- data/app/assets/stylesheets/mongoid_forums/topics.css +4 -0
- data/app/assets/stylesheets/scaffold.css +56 -0
- data/app/controllers/mongoid_forums/admin/base_controller.rb +18 -0
- data/app/controllers/mongoid_forums/admin/categories_controller.rb +83 -0
- data/app/controllers/mongoid_forums/admin/forums_controller.rb +83 -0
- data/app/controllers/mongoid_forums/admin/groups_controller.rb +83 -0
- data/app/controllers/mongoid_forums/admin/topics_controller.rb +48 -0
- data/app/controllers/mongoid_forums/admin/users_controller.rb +34 -0
- data/app/controllers/mongoid_forums/application_controller.rb +57 -0
- data/app/controllers/mongoid_forums/forums_controller.rb +66 -0
- data/app/controllers/mongoid_forums/posts_controller.rb +133 -0
- data/app/controllers/mongoid_forums/redirect_controller.rb +33 -0
- data/app/controllers/mongoid_forums/topics_controller.rb +83 -0
- data/app/decorators/lib/mongoid_forums/user_class_decorator.rb +1 -0
- data/app/helpers/mongoid_forums/admin/base_helper.rb +4 -0
- data/app/helpers/mongoid_forums/admin/categories_helper.rb +4 -0
- data/app/helpers/mongoid_forums/admin/forums_helper.rb +4 -0
- data/app/helpers/mongoid_forums/admin/groups_helper.rb +4 -0
- data/app/helpers/mongoid_forums/admin/users_helper.rb +4 -0
- data/app/helpers/mongoid_forums/application_helper.rb +20 -0
- data/app/helpers/mongoid_forums/formatting_helper.rb +28 -0
- data/app/helpers/mongoid_forums/forums_helper.rb +15 -0
- data/app/helpers/mongoid_forums/posts_helper.rb +4 -0
- data/app/helpers/mongoid_forums/topics_helper.rb +4 -0
- data/app/models/mongoid_forums/ability.rb +65 -0
- data/app/models/mongoid_forums/alert.rb +80 -0
- data/app/models/mongoid_forums/category.rb +31 -0
- data/app/models/mongoid_forums/concerns/subscribable.rb +76 -0
- data/app/models/mongoid_forums/concerns/viewable.rb +60 -0
- data/app/models/mongoid_forums/forum.rb +67 -0
- data/app/models/mongoid_forums/group.rb +15 -0
- data/app/models/mongoid_forums/post.rb +40 -0
- data/app/models/mongoid_forums/subscription.rb +65 -0
- data/app/models/mongoid_forums/topic.rb +55 -0
- data/app/models/mongoid_forums/view.rb +30 -0
- data/app/views/layouts/mongoid_forums/application.haml +21 -0
- data/app/views/mongoid_forums/admin/base/index.haml +6 -0
- data/app/views/mongoid_forums/admin/categories/edit.haml +4 -0
- data/app/views/mongoid_forums/admin/categories/index.haml +21 -0
- data/app/views/mongoid_forums/admin/categories/new.haml +4 -0
- data/app/views/mongoid_forums/admin/categories/show.haml +21 -0
- data/app/views/mongoid_forums/admin/forums/edit.haml +5 -0
- data/app/views/mongoid_forums/admin/forums/index.haml +25 -0
- data/app/views/mongoid_forums/admin/forums/new.haml +5 -0
- data/app/views/mongoid_forums/admin/forums/show.haml +21 -0
- data/app/views/mongoid_forums/admin/groups/edit.haml +4 -0
- data/app/views/mongoid_forums/admin/groups/index.haml +23 -0
- data/app/views/mongoid_forums/admin/groups/new.haml +5 -0
- data/app/views/mongoid_forums/admin/groups/show.haml +26 -0
- data/app/views/mongoid_forums/admin/users/index.haml +24 -0
- data/app/views/mongoid_forums/forums/index.haml +46 -0
- data/app/views/mongoid_forums/forums/new.haml +15 -0
- data/app/views/mongoid_forums/forums/show.haml +47 -0
- data/app/views/mongoid_forums/posts/_form.haml +4 -0
- data/app/views/mongoid_forums/posts/_post.haml +24 -0
- data/app/views/mongoid_forums/posts/_quoted.haml +9 -0
- data/app/views/mongoid_forums/posts/edit.haml +17 -0
- data/app/views/mongoid_forums/posts/new.haml +17 -0
- data/app/views/mongoid_forums/topics/_topic.haml +2 -0
- data/app/views/mongoid_forums/topics/my_posts.haml +6 -0
- data/app/views/mongoid_forums/topics/my_subscriptions.haml +5 -0
- data/app/views/mongoid_forums/topics/my_topics.haml +6 -0
- data/app/views/mongoid_forums/topics/show.haml +16 -0
- data/config/locales/en.yml +196 -0
- data/config/routes.rb +62 -0
- data/lib/ack_mongoid_forums.rb +1 -0
- data/lib/generators/mongoid_forums/install/templates/initializer.rb +5 -0
- data/lib/generators/mongoid_forums/install_generator.rb +90 -0
- data/lib/generators/mongoid_forums/views_generator.rb +27 -0
- data/lib/mongoid_forums.rb +53 -0
- data/lib/mongoid_forums/default_permissions.rb +63 -0
- data/lib/mongoid_forums/engine.rb +20 -0
- data/lib/mongoid_forums/sanitizer.rb +10 -0
- data/lib/mongoid_forums/version.rb +3 -0
- data/lib/tasks/mongoid_forums_tasks.rake +4 -0
- data/test/controllers/mongoid_forums/admin/base_controller_test.rb +11 -0
- data/test/controllers/mongoid_forums/admin/categories_controller_test.rb +31 -0
- data/test/controllers/mongoid_forums/admin/forums_controller_test.rb +31 -0
- data/test/controllers/mongoid_forums/admin/groups_controller_test.rb +41 -0
- data/test/controllers/mongoid_forums/admin/users_controller_test.rb +11 -0
- data/test/controllers/mongoid_forums/forums_controller_test.rb +16 -0
- data/test/controllers/mongoid_forums/posts_controller_test.rb +36 -0
- data/test/controllers/mongoid_forums/topics_controller_test.rb +36 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/javascripts/welcome.js +2 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
- data/test/dummy/app/assets/stylesheets/welcome.css +4 -0
- data/test/dummy/app/controllers/application_controller.rb +11 -0
- data/test/dummy/app/controllers/welcome_controller.rb +4 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/helpers/welcome_helper.rb +2 -0
- data/test/dummy/app/models/concerns/zero_oid_fix.rb +10 -0
- data/test/dummy/app/models/user.rb +43 -0
- data/test/dummy/app/views/layouts/application.haml +13 -0
- data/test/dummy/app/views/partials/_nav.haml +6 -0
- data/test/dummy/app/views/welcome/index.html.erb +2 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +29 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +41 -0
- data/test/dummy/config/environments/production.rb +76 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/devise.rb +259 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/kaminari_config.rb +10 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/mongoid_forums.rb +5 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/simple_form.rb +166 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +9 -0
- data/test/dummy/config/locales/devise.en.yml +60 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/locales/simple_form.en.yml +31 -0
- data/test/dummy/config/mongoid.yml +69 -0
- data/test/dummy/config/routes.rb +7 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/lib/templates/erb/scaffold/_form.html.erb +13 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/test/controllers/welcome_controller_test.rb +9 -0
- data/test/dummy/test/fixtures/users.yml +11 -0
- data/test/dummy/test/models/user_test.rb +7 -0
- data/test/fixtures/mongoid_forums/categories.yml +11 -0
- data/test/fixtures/mongoid_forums/forums.yml +11 -0
- data/test/fixtures/mongoid_forums/posts.yml +11 -0
- data/test/fixtures/mongoid_forums/ranks.yml +11 -0
- data/test/fixtures/mongoid_forums/topics.yml +11 -0
- data/test/integration/navigation_test.rb +9 -0
- data/test/models/mongoid_forums/category_test.rb +9 -0
- data/test/models/mongoid_forums/forum_test.rb +9 -0
- data/test/models/mongoid_forums/post_test.rb +9 -0
- data/test/models/mongoid_forums/rank_test.rb +9 -0
- data/test/models/mongoid_forums/topic_test.rb +9 -0
- data/test/mongoid_forums_test.rb +7 -0
- data/test/test_helper.rb +17 -0
- metadata +442 -0
@@ -0,0 +1,15 @@
|
|
1
|
+
module MongoidForums
|
2
|
+
class Group
|
3
|
+
include Mongoid::Document
|
4
|
+
|
5
|
+
validates :name, :moderator, :presence => true
|
6
|
+
|
7
|
+
field :name, type: String
|
8
|
+
field :moderator, type: Boolean
|
9
|
+
field :members, type: Array, default: []
|
10
|
+
|
11
|
+
def to_s
|
12
|
+
name
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module MongoidForums
|
2
|
+
class Post
|
3
|
+
include Mongoid::Document
|
4
|
+
include Mongoid::Timestamps
|
5
|
+
|
6
|
+
after_create :set_topic_last_post_at
|
7
|
+
|
8
|
+
belongs_to :topic, :class_name => "MongoidForums::Topic"
|
9
|
+
|
10
|
+
belongs_to :user, :class_name => MongoidForums.user_class.to_s
|
11
|
+
|
12
|
+
belongs_to :reply_to, :class_name => "MongoidForums::Post"
|
13
|
+
|
14
|
+
has_many :replies, :class_name => "MongoidForums::Post",
|
15
|
+
:foreign_key => "reply_to_id",
|
16
|
+
:dependent => :nullify
|
17
|
+
|
18
|
+
field :text, type: String
|
19
|
+
validates :text, :presence => true
|
20
|
+
|
21
|
+
class << self
|
22
|
+
def by_created_at
|
23
|
+
order_by([:created_at, :asc])
|
24
|
+
end
|
25
|
+
|
26
|
+
def by_updated_at
|
27
|
+
order_by([:updated_at, :desc])
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def owner_or_admin?(other_user)
|
32
|
+
user == other_user || (other_user.mongoid_forums_admin? || topic.forum.moderator?(other_user))
|
33
|
+
end
|
34
|
+
|
35
|
+
protected
|
36
|
+
def set_topic_last_post_at
|
37
|
+
self.topic.update_attribute(:last_post_at, self.created_at)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
Copyright 2011 Ryan Bigg, Philip Arndt and Josh Adams
|
4
|
+
|
5
|
+
This code was obtained from: https://github.com/kultus/forem-2/blob/master/app/models/forem/subscription.rb
|
6
|
+
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
8
|
+
a copy of this software and associated documentation files (the
|
9
|
+
"Software"), to deal in the Software without restriction, including
|
10
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
11
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
12
|
+
permit persons to whom the Software is furnished to do so, subject to
|
13
|
+
the following conditions:
|
14
|
+
|
15
|
+
The above copyright notice and this permission notice shall be
|
16
|
+
included in all copies or substantial portions of the Software.
|
17
|
+
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
19
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
20
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
21
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
22
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
23
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
24
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
25
|
+
|
26
|
+
|
27
|
+
=end
|
28
|
+
|
29
|
+
module MongoidForums
|
30
|
+
class Subscription
|
31
|
+
include Mongoid::Document
|
32
|
+
include Mongoid::Timestamps
|
33
|
+
|
34
|
+
field :unsubscribed, :type => Boolean, :default => false
|
35
|
+
|
36
|
+
belongs_to :subscribable, :polymorphic => true, :index => true
|
37
|
+
belongs_to :subscriber, :class_name => MongoidForums.user_class.to_s, :index => true
|
38
|
+
|
39
|
+
validates :subscriber_id, :presence => true
|
40
|
+
validates :subscribable_id, :presence => true
|
41
|
+
validates :subscribable_type, :presence => true
|
42
|
+
|
43
|
+
#attr_accessible :subscriber_id
|
44
|
+
|
45
|
+
def alert_subscriber(*args)
|
46
|
+
alert = MongoidForums::Alert.where(:subscription_id => self.id, :read => false).first
|
47
|
+
puts "ALERTING SUBSCRIBERS WITH"
|
48
|
+
puts alert
|
49
|
+
case self.subscribable_type
|
50
|
+
when "MongoidForums::Topic"
|
51
|
+
if alert == nil
|
52
|
+
last_post = self.subscribable.posts.last
|
53
|
+
return if last_post.user.id == self.subscriber_id
|
54
|
+
MongoidForums::Alert.create(:subscription_id => self.id, :user_id => self.subscriber_id, :mongoid_forums_topic_post => last_post, :mongoid_forums_topic_replier => last_post.user.forum_display_name)
|
55
|
+
else
|
56
|
+
alert.updated_at = Time.now
|
57
|
+
alert.mongoid_forums_topic_count += 1
|
58
|
+
alert.save
|
59
|
+
end
|
60
|
+
else
|
61
|
+
raise TypeError, 'This object is not subscribable!'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module MongoidForums
|
2
|
+
class Topic
|
3
|
+
include Mongoid::Document
|
4
|
+
include Mongoid::Timestamps
|
5
|
+
include MongoidForums::Concerns::Subscribable
|
6
|
+
include MongoidForums::Concerns::Viewable
|
7
|
+
|
8
|
+
after_create :subscribe_creator
|
9
|
+
|
10
|
+
belongs_to :forum, :class_name => "MongoidForums::Forum"
|
11
|
+
has_many :posts, :class_name => "MongoidForums::Post", dependent: :destroy
|
12
|
+
|
13
|
+
belongs_to :user, :class_name => MongoidForums.user_class.to_s
|
14
|
+
|
15
|
+
field :name
|
16
|
+
|
17
|
+
field :locked, type: Boolean, default: false
|
18
|
+
field :pinned, type: Boolean, default: false
|
19
|
+
field :hidden, type: Boolean, default: false
|
20
|
+
|
21
|
+
validates :name, :presence => true, :length => { maximum: 255 }
|
22
|
+
validates :user, :presence => true
|
23
|
+
|
24
|
+
def can_be_replied_to?
|
25
|
+
!locked?
|
26
|
+
end
|
27
|
+
|
28
|
+
def toggle!(field)
|
29
|
+
send "#{field}=", !self.send("#{field}?")
|
30
|
+
save :validation => false
|
31
|
+
end
|
32
|
+
|
33
|
+
def unread_post_count(user)
|
34
|
+
view = View.where(:viewable_id => id, :user_id => user.id).first
|
35
|
+
return posts.count unless view.present?
|
36
|
+
count = 0
|
37
|
+
posts.each do |post|
|
38
|
+
if post.created_at > view.current_viewed_at
|
39
|
+
count+=1
|
40
|
+
end
|
41
|
+
end
|
42
|
+
return count
|
43
|
+
end
|
44
|
+
|
45
|
+
class << self
|
46
|
+
def by_most_recent_post
|
47
|
+
order_by([:last_post_at, :desc])
|
48
|
+
end
|
49
|
+
|
50
|
+
def by_pinned_or_most_recent_post
|
51
|
+
order_by([:pinned, :desc], [:last_post_at, :desc])
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module MongoidForums
|
2
|
+
class View
|
3
|
+
include Mongoid::Document
|
4
|
+
include Mongoid::Timestamps
|
5
|
+
|
6
|
+
field :current_viewed_at, :type => DateTime
|
7
|
+
field :past_viewed_at, :type => DateTime
|
8
|
+
|
9
|
+
before_create :set_viewed_at_to_now
|
10
|
+
|
11
|
+
belongs_to :viewable, :polymorphic => true, :index => true
|
12
|
+
belongs_to :user, :class_name => MongoidForums.user_class.to_s, :index => true
|
13
|
+
|
14
|
+
validates :viewable_id, :presence => true
|
15
|
+
validates :viewable_type, :presence => true
|
16
|
+
|
17
|
+
#attr_accessible :user, :current_viewed_at, :count
|
18
|
+
#field :count, type: Integer
|
19
|
+
|
20
|
+
def viewed_at
|
21
|
+
updated_at
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def set_viewed_at_to_now
|
26
|
+
self.current_viewed_at = Time.now
|
27
|
+
self.past_viewed_at = current_viewed_at
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
!!!
|
2
|
+
%html
|
3
|
+
%head
|
4
|
+
%title Forums
|
5
|
+
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
|
6
|
+
= javascript_include_tag 'application', 'data-turbolinks-track' => true
|
7
|
+
= csrf_meta_tags
|
8
|
+
%body
|
9
|
+
- if mongoid_forums_user.present?
|
10
|
+
- @alerts.each do |al|
|
11
|
+
= al.mongoid_forums_topic_replier
|
12
|
+
replied to
|
13
|
+
- topic = MongoidForums::Post.find(al.mongoid_forums_topic_post_id).topic
|
14
|
+
= link_to topic.name, al.link
|
15
|
+
= time_ago_in_words(al.created_at)
|
16
|
+
ago
|
17
|
+
|
18
|
+
- flash.each do |name, msg|
|
19
|
+
= content_tag :p, msg if msg.is_a?(String)
|
20
|
+
|
21
|
+
= yield
|
@@ -0,0 +1,21 @@
|
|
1
|
+
%h1 Manage categories
|
2
|
+
|
3
|
+
%h2 Create a new category
|
4
|
+
= link_to "New category", new_admin_category_path
|
5
|
+
|
6
|
+
%h2 Listing all categories
|
7
|
+
%table{:border => "1"}
|
8
|
+
%tr
|
9
|
+
%th
|
10
|
+
Name
|
11
|
+
|
12
|
+
- @categories.each do |category|
|
13
|
+
%tr
|
14
|
+
%td
|
15
|
+
= link_to category.name, [:admin, category]
|
16
|
+
%td
|
17
|
+
= link_to "Show", admin_category_path(category)
|
18
|
+
%td
|
19
|
+
= link_to "Edit", edit_admin_category_path(category)
|
20
|
+
%td
|
21
|
+
= button_to "Destroy", admin_category_path(category), method: :delete, data: { confirm: 'Are you certain you want to delete this?' }
|
@@ -0,0 +1,21 @@
|
|
1
|
+
%h2 Listing all moderator groups for: #{@category.name}
|
2
|
+
%table{:border => "1"}
|
3
|
+
%tr
|
4
|
+
%th
|
5
|
+
Name
|
6
|
+
|
7
|
+
- @category.moderator_groups.each do |group|
|
8
|
+
%tr
|
9
|
+
%td
|
10
|
+
= link_to group.name, [:admin, group]
|
11
|
+
%td
|
12
|
+
= link_to "Show", admin_group_path(group)
|
13
|
+
%td
|
14
|
+
= link_to "Edit", edit_admin_group_path(group)
|
15
|
+
%td
|
16
|
+
= button_to "Remove", admin_category_rem_group_path(category_id: params[:id], group: {id: group.id}), method: :post, data: { confirm: 'Are you certain you want to delete this?' }
|
17
|
+
|
18
|
+
= form_tag admin_category_add_group_path(@category), :method => :post do
|
19
|
+
= collection_select(:group, :id, @groups, :id, :name, {:prompt => true})
|
20
|
+
%button
|
21
|
+
Add
|
@@ -0,0 +1,25 @@
|
|
1
|
+
%h1 Manage forums
|
2
|
+
|
3
|
+
%h2 Create a new forum
|
4
|
+
= link_to "New forum", new_admin_forum_path
|
5
|
+
|
6
|
+
%h2 Listing all forums
|
7
|
+
%table{:border => "1"}
|
8
|
+
%tr
|
9
|
+
%th
|
10
|
+
Name
|
11
|
+
%th
|
12
|
+
Category
|
13
|
+
|
14
|
+
- @forums.each do |forum|
|
15
|
+
%tr
|
16
|
+
%td
|
17
|
+
= link_to forum.name, [:admin, forum]
|
18
|
+
%td
|
19
|
+
= link_to forum.category.name, [:admin, forum.category]
|
20
|
+
%td
|
21
|
+
= link_to "Show", admin_forum_path(forum)
|
22
|
+
%td
|
23
|
+
= link_to "Edit", edit_admin_forum_path(forum)
|
24
|
+
%td
|
25
|
+
= button_to "Destroy", admin_forum_path(forum), method: :delete, data: { confirm: 'Are you certain you want to delete this?' }
|
@@ -0,0 +1,21 @@
|
|
1
|
+
%h2 Listing all moderator groups for: #{@forum.name}
|
2
|
+
%table{:border => "1"}
|
3
|
+
%tr
|
4
|
+
%th
|
5
|
+
Name
|
6
|
+
|
7
|
+
- @forum.moderator_groups.each do |group|
|
8
|
+
%tr
|
9
|
+
%td
|
10
|
+
= link_to group.name, [:admin, group]
|
11
|
+
%td
|
12
|
+
= link_to "Show", admin_group_path(group)
|
13
|
+
%td
|
14
|
+
= link_to "Edit", edit_admin_group_path(group)
|
15
|
+
%td
|
16
|
+
= button_to "Remove", admin_forum_rem_group_path(forum_id: params[:id], group: {id: group.id}), method: :post, data: { confirm: 'Are you certain you want to delete this?' }
|
17
|
+
|
18
|
+
= form_tag admin_forum_add_group_path(@forum), :method => :post do
|
19
|
+
= collection_select(:group, :id, @groups, :id, :name, {:prompt => true})
|
20
|
+
%button
|
21
|
+
Add
|
@@ -0,0 +1,23 @@
|
|
1
|
+
%h1 Manage groups
|
2
|
+
|
3
|
+
%h2 Create a new group
|
4
|
+
= link_to "New group", new_admin_group_path
|
5
|
+
|
6
|
+
%h2 Listing all groups
|
7
|
+
%table{:border => "1"}
|
8
|
+
%tr
|
9
|
+
%th
|
10
|
+
Name
|
11
|
+
%th
|
12
|
+
Moderator
|
13
|
+
|
14
|
+
- @groups.each_with_index do |group, i|
|
15
|
+
%tr
|
16
|
+
%td
|
17
|
+
= link_to group.name, [:admin, group]
|
18
|
+
%td
|
19
|
+
= group.moderator
|
20
|
+
%td
|
21
|
+
= link_to "Edit", edit_admin_group_path(group)
|
22
|
+
%td
|
23
|
+
= button_to "Destroy", admin_group_path(group), method: :delete, data: { confirm: 'Are you certain you want to delete this?' }
|
@@ -0,0 +1,26 @@
|
|
1
|
+
%h2
|
2
|
+
= @group.name
|
3
|
+
%h3 Listing all members
|
4
|
+
%table{:border => "1"}
|
5
|
+
%tr
|
6
|
+
%th
|
7
|
+
Name
|
8
|
+
|
9
|
+
- @group.members.each do |member|
|
10
|
+
%tr
|
11
|
+
%td
|
12
|
+
= MongoidForums.user_class.find(member).forum_display_name
|
13
|
+
%td
|
14
|
+
= button_to "Remove", admin_group_rem_user_path(group_id: @group.id, user: {id: member}), method: :post, data: { confirm: 'Are you certain you want to delete this?' }
|
15
|
+
|
16
|
+
= form_tag admin_group_add_user_path(@group), :method => :post, :id => "form_add_user" do
|
17
|
+
%input{:id => "userinput", :list => "users", :name => "[user][id]"}/
|
18
|
+
%datalist#users
|
19
|
+
- @users.each do |user|
|
20
|
+
%option{:id => user.id, :value => user.forum_display_name}
|
21
|
+
= submit_tag("Add User")
|
22
|
+
|
23
|
+
:javascript
|
24
|
+
$("#form_add_user").submit(function(){
|
25
|
+
$("#userinput").val($('#users').find('option[value="' + $('#userinput').val() + '"]').attr('id'));
|
26
|
+
});
|
@@ -0,0 +1,24 @@
|
|
1
|
+
%h3 Listing all admins
|
2
|
+
%table{:border => "1"}
|
3
|
+
%tr
|
4
|
+
%th
|
5
|
+
Name
|
6
|
+
|
7
|
+
- @admins.each do |admin|
|
8
|
+
%tr
|
9
|
+
%td
|
10
|
+
= admin.forum_display_name
|
11
|
+
%td
|
12
|
+
= button_to "Remove", admin_user_remove_admin_path("dummy", user: {id: admin.id}), method: :post, data: { confirm: 'Are you certain you want to delete this?' }
|
13
|
+
|
14
|
+
= form_tag admin_user_add_admin_path("dummy"), :method => :post, :id => "form_add_user" do
|
15
|
+
%input{:id => "userinput", :list => "users", :name => "[user][id]"}/
|
16
|
+
%datalist#users
|
17
|
+
- @non_admins.each do |user|
|
18
|
+
%option{:id => user.id, :value => user.forum_display_name}
|
19
|
+
= submit_tag("Add Admin")
|
20
|
+
|
21
|
+
:javascript
|
22
|
+
$("#form_add_user").submit(function(){
|
23
|
+
$("#userinput").val($('#users').find('option[value="' + $('#userinput').val() + '"]').attr('id'));
|
24
|
+
});
|