mongoid-forums 0.0.5 → 0.0.9
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/assets/javascripts/mongoid_forums/admin/users.js +2 -0
- data/app/assets/stylesheets/mongoid_forums/admin/users.css +4 -0
- data/app/controllers/mongoid_forums/admin/categories_controller.rb +5 -5
- data/app/controllers/mongoid_forums/admin/forums_controller.rb +2 -2
- data/app/controllers/mongoid_forums/admin/users_controller.rb +34 -0
- data/app/controllers/mongoid_forums/application_controller.rb +1 -1
- data/app/controllers/mongoid_forums/forums_controller.rb +8 -8
- data/app/controllers/mongoid_forums/topics_controller.rb +0 -1
- data/app/helpers/mongoid_forums/admin/users_helper.rb +4 -0
- data/app/models/mongoid_forums/category.rb +2 -1
- data/app/models/mongoid_forums/forum.rb +2 -1
- data/app/views/mongoid_forums/admin/base/index.haml +1 -0
- data/app/views/mongoid_forums/admin/categories/edit.haml +1 -0
- data/app/views/mongoid_forums/admin/categories/new.haml +1 -0
- data/app/views/mongoid_forums/admin/forums/edit.haml +1 -0
- data/app/views/mongoid_forums/admin/forums/new.haml +1 -0
- data/app/views/mongoid_forums/admin/groups/show.haml +11 -4
- data/app/views/mongoid_forums/admin/users/index.haml +24 -0
- data/app/views/mongoid_forums/forums/index.haml +1 -1
- data/config/routes.rb +5 -0
- data/lib/mongoid_forums/version.rb +1 -1
- data/lib/mongoid_forums.rb +1 -1
- data/test/controllers/mongoid_forums/admin/users_controller_test.rb +11 -0
- data/test/dummy/app/assets/javascripts/application.js +2 -0
- data/test/dummy/log/development.log +5273 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/0308248096d701ded90989b48340878a +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/1d095746458aab3bdb955bf59c96ca33 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6f9939c59875c2394301c1b6b1bceca3 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/c8a43f513a945814918a659ead2dac85 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e1436ddb13bf91383110676cf21fbe14 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e65def7db46175dc13f1bf5cc4f2f870 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- metadata +35 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9bdf3c71e24211880b870d5f17158a1dbfd49005
|
4
|
+
data.tar.gz: 75379a0a853b6ef2db67c24e25e77dc42fb872ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40ef04419c68fd0bcba32664e6a908bd3110a86e25d3d74be920e75d2cf5d6411fc948b93e292753bb6f0e7dbd518f90a4bfcf7d516ed08f6512f7ed880d2374
|
7
|
+
data.tar.gz: 2f48f9a3800cd093463a8d8cd42ac97e3ab40a72dab696070d5e060e47b8d2fb0afbd568137f0354621e642d4b744455dff863c9d8e5d7e460b6a785ae8cbf13
|
@@ -6,13 +6,13 @@ module MongoidForums
|
|
6
6
|
before_action :set_category, only: [:add_group, :remove_group]
|
7
7
|
|
8
8
|
def index
|
9
|
-
@forums = Forum.
|
10
|
-
@categories = Category.
|
9
|
+
@forums = Forum.asc(:position)
|
10
|
+
@categories = Category.asc(:position)
|
11
11
|
end
|
12
12
|
|
13
13
|
def show
|
14
14
|
@category = Category.find(params[:id])
|
15
|
-
@groups = Group.all.where(moderator: true).select{ |group| !@category.moderator_groups.include?(group) }
|
15
|
+
@groups = Group. all.where(moderator: true).select{ |group| !@category.moderator_groups.include?(group) }
|
16
16
|
end
|
17
17
|
|
18
18
|
def new
|
@@ -20,7 +20,7 @@ module MongoidForums
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def create
|
23
|
-
if @category = Category.create(
|
23
|
+
if @category = Category.create(category_params)
|
24
24
|
flash[:notice] = "Category created successfully"
|
25
25
|
redirect_to admin_categories_path
|
26
26
|
else
|
@@ -76,7 +76,7 @@ module MongoidForums
|
|
76
76
|
private
|
77
77
|
|
78
78
|
def category_params
|
79
|
-
params.require(:category).permit(:name)
|
79
|
+
params.require(:category).permit(:name, :position)
|
80
80
|
end
|
81
81
|
|
82
82
|
def set_category
|
@@ -14,7 +14,7 @@ module MongoidForums
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def create
|
17
|
-
@forum = Forum.new(
|
17
|
+
@forum = Forum.new(forum_params)
|
18
18
|
if @forum.save
|
19
19
|
flash[:notice] = "Forum created successfully"
|
20
20
|
redirect_to [:admin, @forum]
|
@@ -76,7 +76,7 @@ module MongoidForums
|
|
76
76
|
private
|
77
77
|
|
78
78
|
def forum_params
|
79
|
-
params.require(:forum).permit(:name, :category)
|
79
|
+
params.require(:forum).permit(:name, :category, :position)
|
80
80
|
end
|
81
81
|
|
82
82
|
def set_forum
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require_dependency "mongoid_forums/application_controller"
|
2
|
+
|
3
|
+
module MongoidForums
|
4
|
+
module Admin
|
5
|
+
class UsersController < BaseController
|
6
|
+
|
7
|
+
before_action :set_user, only: [:add_admin, :remove_admin]
|
8
|
+
|
9
|
+
def index
|
10
|
+
@admins = User.where(mongoid_admin: true)
|
11
|
+
@non_admins = User.where(mongoid_admin: false)
|
12
|
+
end
|
13
|
+
|
14
|
+
def add_admin
|
15
|
+
@user.mongoid_admin = true
|
16
|
+
@user.save
|
17
|
+
redirect_to admin_users_path
|
18
|
+
end
|
19
|
+
|
20
|
+
def remove_admin
|
21
|
+
@user.mongoid_admin = false
|
22
|
+
@user.save
|
23
|
+
redirect_to admin_users_path
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def set_user
|
29
|
+
@user = User.find(params[:user][:id])
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -6,7 +6,7 @@ module MongoidForums
|
|
6
6
|
before_filter :authenticate_mongoid_forums_user, :only => [:create, :new]
|
7
7
|
|
8
8
|
def index
|
9
|
-
@categories = Category.
|
9
|
+
@categories = Category.asc(:position)
|
10
10
|
end
|
11
11
|
|
12
12
|
def show
|
@@ -51,15 +51,15 @@ module MongoidForums
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
|
54
|
+
private
|
55
55
|
|
56
|
-
|
57
|
-
|
58
|
-
|
56
|
+
def register_view
|
57
|
+
@forum.register_view_by(mongoid_forums_user)
|
58
|
+
end
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
60
|
+
def topic_params
|
61
|
+
params.require(:topic).permit(:name, :posts => [:text])
|
62
|
+
end
|
63
63
|
|
64
64
|
|
65
65
|
end
|
@@ -9,7 +9,8 @@ module MongoidForums
|
|
9
9
|
field :name
|
10
10
|
validates :name, :presence => true
|
11
11
|
|
12
|
-
field :
|
12
|
+
field :position, :type => Integer, :default => 0
|
13
|
+
validates :position, numericality: { only_integer: true }
|
13
14
|
|
14
15
|
def moderator?(user)
|
15
16
|
return false unless user
|
@@ -16,7 +16,8 @@ module MongoidForums
|
|
16
16
|
|
17
17
|
has_and_belongs_to_many :moderator_groups, :class_name => "MongoidForums::Group", inverse_of: nil
|
18
18
|
|
19
|
-
field :
|
19
|
+
field :position, :type => Integer, :default => 0
|
20
|
+
validates :position, numericality: { only_integer: true }
|
20
21
|
|
21
22
|
def unread_topic_count(user)
|
22
23
|
view = View.where(:viewable_id => id, :user_id => user.id).first
|
@@ -13,7 +13,14 @@
|
|
13
13
|
%td
|
14
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
15
|
|
16
|
-
= form_tag admin_group_add_user_path(@group), :method => :post do
|
17
|
-
|
18
|
-
%
|
19
|
-
|
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
|
+
});
|
data/config/routes.rb
CHANGED
@@ -22,6 +22,11 @@ MongoidForums::Engine.routes.draw do
|
|
22
22
|
get 'toggle_pin' => 'topics#toggle_pin', :as => 'toggle_pin'
|
23
23
|
end
|
24
24
|
end
|
25
|
+
|
26
|
+
resources :users do
|
27
|
+
post '/add' => 'users#add_admin', as: 'add_admin'
|
28
|
+
post '/remove' => 'users#remove_admin', as: 'remove_admin'
|
29
|
+
end
|
25
30
|
end
|
26
31
|
|
27
32
|
root :to => "forums#index"
|
data/lib/mongoid_forums.rb
CHANGED
@@ -18,7 +18,7 @@ module MongoidForums
|
|
18
18
|
has_many :mongoid_forums_posts, :class_name => "MongoidForums::Post", :foreign_key => "user_id"
|
19
19
|
has_many :mongoid_forums_topics, :class_name => "MongoidForums::Topic", :foreign_key => "user_id"
|
20
20
|
|
21
|
-
field :mongoid_admin, type: Boolean
|
21
|
+
field :mongoid_admin, type: Boolean, default: false
|
22
22
|
|
23
23
|
def mongoid_forums_admin?
|
24
24
|
mongoid_admin
|