mongoid-forums 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/mongoid_forums/admin/forums_controller.rb +2 -1
- data/app/controllers/mongoid_forums/admin/groups_controller.rb +2 -2
- data/app/controllers/mongoid_forums/admin/topics_controller.rb +48 -0
- data/app/controllers/mongoid_forums/topics_controller.rb +3 -1
- data/app/models/mongoid_forums/forum.rb +2 -0
- data/app/models/mongoid_forums/topic.rb +5 -0
- data/app/views/mongoid_forums/forums/index.haml +3 -2
- data/app/views/mongoid_forums/forums/show.haml +24 -23
- data/app/views/mongoid_forums/posts/_post.haml +1 -1
- data/app/views/mongoid_forums/topics/show.haml +5 -0
- data/config/locales/en.yml +192 -0
- data/config/routes.rb +8 -0
- data/lib/mongoid_forums/version.rb +1 -1
- data/test/dummy/log/development.log +7803 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73b738bfa58a6743dcb67ec79b38604287d6f666
|
4
|
+
data.tar.gz: 3999f2852e03a0bfddf5e24d0e788e61e4c891f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c49e8ef5e09919a913a55bc7ff9ae13761004b0efa788aac080b8fe05ffae95fad4c9c6ac2123230977bdbd47746cc612982e5e81fb659c8dfd425115e2c60c0
|
7
|
+
data.tar.gz: 43cfa20eda79aec5f0985b5d046bea08fbc3a59dd3f52c712df888c39fb376fb8dff9c5d65809d36ec970309f1aabb9d493a346627f0870a7c36d886ac6d32ab
|
@@ -14,7 +14,8 @@ module MongoidForums
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def create
|
17
|
-
|
17
|
+
@forum = Forum.new(name: params[:forum][:name], category: params[:forum][:category])
|
18
|
+
if @forum.save
|
18
19
|
flash[:notice] = "Forum created successfully"
|
19
20
|
redirect_to [:admin, @forum]
|
20
21
|
else
|
@@ -39,8 +39,8 @@ module MongoidForums
|
|
39
39
|
|
40
40
|
def show
|
41
41
|
@group = Group.find(params[:id])
|
42
|
-
@group_members = @group.members.map
|
43
|
-
@users = User.all
|
42
|
+
@group_members = @group.members.map{|member_id| User.find(member_id) }
|
43
|
+
@users = User.all.select{ |user| !@group.members.include?(user.id) }
|
44
44
|
end
|
45
45
|
|
46
46
|
def destroy
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module MongoidForums
|
2
|
+
module Admin
|
3
|
+
class TopicsController < BaseController
|
4
|
+
before_filter :find_topic
|
5
|
+
|
6
|
+
def edit
|
7
|
+
end
|
8
|
+
|
9
|
+
def update
|
10
|
+
@topic.subject = params[:topic][:subject]
|
11
|
+
@topic.pinned = params[:topic][:pinned]
|
12
|
+
@topic.locked = params[:topic][:locked]
|
13
|
+
@topic.hidden = params[:topic][:hidden]
|
14
|
+
@topic.forum_id = params[:topic][:forum_id]
|
15
|
+
if @topic.save
|
16
|
+
flash[:notice] = t("mongoid_forums.topic.updated")
|
17
|
+
redirect_to topic_path(@topic)
|
18
|
+
else
|
19
|
+
flash.alert = t("mongoid_forums.topic.not_updated")
|
20
|
+
render :action => "edit"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def toggle_hide
|
25
|
+
@topic.toggle!(:hidden)
|
26
|
+
flash[:notice] = t("mongoid_forums.topic.hidden.#{@topic.hidden?}")
|
27
|
+
redirect_to topic_path(@topic)
|
28
|
+
end
|
29
|
+
|
30
|
+
def toggle_lock
|
31
|
+
@topic.toggle!(:locked)
|
32
|
+
flash[:notice] = t("mongoid_forums.topic.locked.#{@topic.locked?}")
|
33
|
+
redirect_to topic_path(@topic)
|
34
|
+
end
|
35
|
+
|
36
|
+
def toggle_pin
|
37
|
+
@topic.toggle!(:pinned)
|
38
|
+
flash[:notice] = t("mongoid_forums.topic.pinned.#{@topic.pinned?}")
|
39
|
+
redirect_to topic_path(@topic)
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
def find_topic
|
44
|
+
@topic = Topic.find(params[:format])
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -5,6 +5,7 @@ module MongoidForums
|
|
5
5
|
before_filter :find_forum, :except => [:my_subscriptions, :my_posts, :my_topics]
|
6
6
|
|
7
7
|
def show
|
8
|
+
|
8
9
|
if find_topic
|
9
10
|
register_view
|
10
11
|
|
@@ -18,7 +19,7 @@ module MongoidForums
|
|
18
19
|
end
|
19
20
|
|
20
21
|
def destroy
|
21
|
-
|
22
|
+
|
22
23
|
end
|
23
24
|
|
24
25
|
def my_subscriptions
|
@@ -61,6 +62,7 @@ module MongoidForums
|
|
61
62
|
begin
|
62
63
|
scope = @forum.topics # TODO: pending review stuff
|
63
64
|
@topic = scope.find(params[:id])
|
65
|
+
authorize! :read, @topic
|
64
66
|
rescue Mongoid::Errors::DocumentNotFound
|
65
67
|
flash.alert = t("forem.topic.not_found")
|
66
68
|
redirect_to @forum and return
|
@@ -4,6 +4,8 @@ module MongoidForums
|
|
4
4
|
include MongoidForums::Concerns::Viewable
|
5
5
|
|
6
6
|
belongs_to :category, :class_name => "MongoidForums::Category"
|
7
|
+
validates :category, :presence => true
|
8
|
+
|
7
9
|
has_many :topics, :class_name => "MongoidForums::Topic", dependent: :destroy
|
8
10
|
|
9
11
|
# Caching
|
@@ -24,6 +24,11 @@ module MongoidForums
|
|
24
24
|
!locked?
|
25
25
|
end
|
26
26
|
|
27
|
+
def toggle!(field)
|
28
|
+
send "#{field}=", !self.send("#{field}?")
|
29
|
+
save :validation => false
|
30
|
+
end
|
31
|
+
|
27
32
|
def unread_post_count(user)
|
28
33
|
view = View.where(:viewable_id => id, :user_id => user.id).first
|
29
34
|
return posts.count unless view.present?
|
@@ -26,8 +26,9 @@
|
|
26
26
|
%td
|
27
27
|
= link_to forum.name, forum
|
28
28
|
%td
|
29
|
-
-
|
30
|
-
-
|
29
|
+
- if forum.topics.select {|topic| can?(:read, topic) }.last
|
30
|
+
- last_topic = forum.topics.select {|topic| can?(:read, topic) }.last
|
31
|
+
- last_post = last_topic.posts.last
|
31
32
|
= time_ago_in_words ( last_post.created_at )
|
32
33
|
ago on
|
33
34
|
= link_to last_post.topic.name, last_post.topic
|
@@ -22,26 +22,27 @@
|
|
22
22
|
Views
|
23
23
|
|
24
24
|
- @topics.each do |topic|
|
25
|
-
|
26
|
-
%
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
25
|
+
- if can?(:read, topic)
|
26
|
+
%tr
|
27
|
+
%td
|
28
|
+
- if topic.locked
|
29
|
+
🔒
|
30
|
+
- if topic.hidden
|
31
|
+
⚠
|
32
|
+
- if topic.pinned
|
33
|
+
*
|
34
|
+
= link_to topic.name, topic
|
35
|
+
%td
|
36
|
+
= topic.user.forum_display_name
|
37
|
+
= time_ago_in_words( topic.created_at )
|
38
|
+
ago
|
39
|
+
%td
|
40
|
+
= topic.posts.last.user.forum_display_name
|
41
|
+
= time_ago_in_words( topic.posts.last.created_at )
|
42
|
+
ago
|
43
|
+
%td
|
44
|
+
= mongoid_forums_user ? topic.unread_post_count(mongoid_forums_user) : ""
|
45
|
+
%td
|
46
|
+
= topic.posts.count
|
47
|
+
%td
|
48
|
+
= topic.views_count ? topic.views_count : "None"
|
@@ -8,7 +8,7 @@
|
|
8
8
|
ago
|
9
9
|
|
10
10
|
= link_to 'Quote', new_topic_post_path(post.topic_id, :reply_to_id => post.id)
|
11
|
-
- if post.owner_or_admin?(mongoid_forums_user)
|
11
|
+
- if mongoid_forums_user && post.owner_or_admin?(mongoid_forums_user)
|
12
12
|
- if can?(:edit_post, post.topic.forum)
|
13
13
|
= link_to "Edit", edit_topic_post_path(post.topic_id, post)
|
14
14
|
- if can?(:destroy_post, post.topic.forum)
|
@@ -1,4 +1,9 @@
|
|
1
1
|
%h1 Viewing Topic "#{@topic.name}"
|
2
|
+
- if mongoid_forums_admin?
|
3
|
+
= link_to t("mongoid_forums.topics.actions.hide.#{@topic.hidden}"), toggle_hide_admin_topic_path(@forum, @topic), :class => "btn"
|
4
|
+
= link_to t("mongoid_forums.topics.actions.lock.#{@topic.locked}"), toggle_lock_admin_topic_path(@forum, @topic), :class => "btn"
|
5
|
+
= link_to t("mongoid_forums.topics.actions.pin.#{@topic.pinned}"), toggle_pin_admin_topic_path(@forum, @topic), :class => "btn"
|
6
|
+
|
2
7
|
- if @topic.can_be_replied_to? && can?(:reply, @topic)
|
3
8
|
= link_to "Reply to topic", new_topic_post_path(@topic)
|
4
9
|
- if mongoid_forums_user && @topic.subscriber?(mongoid_forums_user.id)
|
@@ -0,0 +1,192 @@
|
|
1
|
+
en:
|
2
|
+
mongoid_forums:
|
3
|
+
general:
|
4
|
+
forum: Forum
|
5
|
+
topics: Topics
|
6
|
+
topic: Topic
|
7
|
+
posts: Posts
|
8
|
+
posts_count:
|
9
|
+
zero: No posts
|
10
|
+
one: 1 post
|
11
|
+
other: "%{count} posts"
|
12
|
+
flagged_for_spam: Your account has been flagged for spam.
|
13
|
+
cannot_create_topic: You cannot create a new topic at this time.
|
14
|
+
cannot_create_post: You cannot create a new post at this time.
|
15
|
+
|
16
|
+
access_denied: "You are not allowed to do that."
|
17
|
+
admin:
|
18
|
+
area: Admin Area
|
19
|
+
welcome: "Welcome to mongoid_forum's Admin Area."
|
20
|
+
forum:
|
21
|
+
index: Manage Forums
|
22
|
+
new: Creating a new forum
|
23
|
+
new_link: New Forum
|
24
|
+
deleted: The selected forum has been deleted.
|
25
|
+
created: This forum has been created.
|
26
|
+
not_created: This forum could not be created.
|
27
|
+
updated: That forum has been updated.
|
28
|
+
not_updated: This forum could not be updated.
|
29
|
+
forums:
|
30
|
+
edit: Edit
|
31
|
+
delete: Delete
|
32
|
+
category: Category
|
33
|
+
delete_confirm: Are you sure you want to delete this forum?
|
34
|
+
index:
|
35
|
+
last_post: Last post
|
36
|
+
none: None
|
37
|
+
group:
|
38
|
+
index: Manage Groups
|
39
|
+
created: The group was successfully created.
|
40
|
+
not_created: Group could not be created.
|
41
|
+
deleted: The selected group has been deleted.
|
42
|
+
groups:
|
43
|
+
show:
|
44
|
+
add_member: Add
|
45
|
+
category:
|
46
|
+
index: Manage Forum Categories
|
47
|
+
new: Creating a new Forum Category
|
48
|
+
new_link: New Forum Category
|
49
|
+
deleted: The selected forum category has been deleted.
|
50
|
+
created: This forum category has been created.
|
51
|
+
not_created: This forum category could not be created.
|
52
|
+
updated: That forum category has been updated.
|
53
|
+
not_updated: This forum category could not be updated.
|
54
|
+
categories:
|
55
|
+
edit: Edit
|
56
|
+
delete: Delete
|
57
|
+
category: Category
|
58
|
+
delete_confirm: Are you sure you want to delete this forum category?
|
59
|
+
common:
|
60
|
+
pages: Pages
|
61
|
+
errors:
|
62
|
+
not_signed_in: You must sign in first.
|
63
|
+
access_denied: Access denied.
|
64
|
+
forum:
|
65
|
+
header: "Viewing %{title}"
|
66
|
+
forums: Forums
|
67
|
+
new: Creating a new forum
|
68
|
+
edit: "Editing the %{title} forum"
|
69
|
+
topics_count:
|
70
|
+
zero: 0 topics
|
71
|
+
one: 1 topic
|
72
|
+
other: "%{count} topics"
|
73
|
+
posts_count:
|
74
|
+
zero: 0 posts
|
75
|
+
one: 1 post
|
76
|
+
other: "%{count} posts"
|
77
|
+
moderator_tools: "Moderation Tools"
|
78
|
+
forums:
|
79
|
+
index:
|
80
|
+
title: Forums
|
81
|
+
forum: Forum
|
82
|
+
views: Views
|
83
|
+
last_post: 'Last Post:'
|
84
|
+
none: None
|
85
|
+
topic:
|
86
|
+
headings:
|
87
|
+
topic: Topic
|
88
|
+
latest: Latest
|
89
|
+
posts: Posts
|
90
|
+
views: Views
|
91
|
+
moderation:
|
92
|
+
success: The selected topic has been moderated.
|
93
|
+
reply: Reply
|
94
|
+
quote: Quote
|
95
|
+
delete: Delete
|
96
|
+
created: This topic has been created.
|
97
|
+
new: Creating a new topic
|
98
|
+
edit: Editing topic
|
99
|
+
not_created: This topic could not be created.
|
100
|
+
deleted: Your topic has been deleted.
|
101
|
+
cannot_delete: You cannot delete a topic you do not own.
|
102
|
+
updated: This topic has been updated.
|
103
|
+
not_updated: This topic could not be updated.
|
104
|
+
subscribed: You have subscribed to this topic.
|
105
|
+
unsubscribed: You have unsubscribed from this topic.
|
106
|
+
none: There are no topics in this forum currently.
|
107
|
+
links:
|
108
|
+
new: New topic
|
109
|
+
back_to_topics: Back to topics
|
110
|
+
edit: Edit topic
|
111
|
+
not_found: The topic you are looking for could not be found.
|
112
|
+
hidden:
|
113
|
+
'true': This topic is now hidden.
|
114
|
+
'false': This topic is now visible.
|
115
|
+
locked:
|
116
|
+
'true': This topic is now locked.
|
117
|
+
'false': This topic is now unlocked.
|
118
|
+
pinned:
|
119
|
+
'true': This topic is now pinned.
|
120
|
+
'false': This topic is now unpinned.
|
121
|
+
topics:
|
122
|
+
show:
|
123
|
+
reply: Reply
|
124
|
+
delete: Delete
|
125
|
+
subscribe: Subscribe
|
126
|
+
unsubscribe: Unsubscribe
|
127
|
+
reply_to_topic: Reply to Topic
|
128
|
+
pending_review: This topic is currently pending review. Only the user who created it and moderators can view it.
|
129
|
+
actions:
|
130
|
+
hide:
|
131
|
+
'true': Show this topic
|
132
|
+
'false': Hide this topic
|
133
|
+
lock:
|
134
|
+
'true': Unlock this topic
|
135
|
+
'false': Lock this topic
|
136
|
+
pin:
|
137
|
+
'true': Unpin this topic
|
138
|
+
'false': Pin this topic
|
139
|
+
post:
|
140
|
+
buttons:
|
141
|
+
reply: Post Reply
|
142
|
+
edit: Edit
|
143
|
+
created: Your reply has been posted.
|
144
|
+
new: Post reply
|
145
|
+
edit: Edit
|
146
|
+
not_created: Your reply could not be posted.
|
147
|
+
not_created_topic_locked: You cannot reply to a locked topic.
|
148
|
+
edited: Your post has been edited.
|
149
|
+
not_edited: Your post could not be edited.
|
150
|
+
deleted: Your post has been deleted.
|
151
|
+
deleted_with_topic: Only post in topic deleted. Topic also deleted.
|
152
|
+
cannot_delete: You cannot delete a post you do not own.
|
153
|
+
in_reply_to: In reply to
|
154
|
+
posts:
|
155
|
+
moderation:
|
156
|
+
moderate: Moderate
|
157
|
+
approve: Approve
|
158
|
+
success: The selected posts have been moderated.
|
159
|
+
post:
|
160
|
+
pending_review: This post is currently pending review. Only the user who posted it and moderators can view it.
|
161
|
+
moderation:
|
162
|
+
title: "Moderation tools for %{forum}"
|
163
|
+
helpers:
|
164
|
+
submit:
|
165
|
+
forum:
|
166
|
+
create: Create Forum
|
167
|
+
update: Update Forum
|
168
|
+
topic:
|
169
|
+
create: Create Topic
|
170
|
+
update: Update Topic
|
171
|
+
simple_form:
|
172
|
+
labels:
|
173
|
+
forum:
|
174
|
+
title: Title
|
175
|
+
description: Description
|
176
|
+
topic:
|
177
|
+
subject: Subject
|
178
|
+
locked: Locked
|
179
|
+
pinned: Pinned
|
180
|
+
hidden: Hidden
|
181
|
+
posts:
|
182
|
+
text: Text
|
183
|
+
post:
|
184
|
+
text: Text
|
185
|
+
|
186
|
+
# General stuff
|
187
|
+
time_ago_in_words: "%{time} ago"
|
188
|
+
ago: " ago"
|
189
|
+
ago_by: " ago by"
|
190
|
+
by: by
|
191
|
+
started_by: "Started by "
|
192
|
+
are_you_sure: Are you sure?
|
data/config/routes.rb
CHANGED
@@ -14,6 +14,14 @@ MongoidForums::Engine.routes.draw do
|
|
14
14
|
post '/add_user' => 'groups#add_member', as: :add_user
|
15
15
|
post '/rem_user' => 'groups#remove_member', as: :rem_user
|
16
16
|
end
|
17
|
+
|
18
|
+
resources :topics do
|
19
|
+
member do
|
20
|
+
get 'toggle_hide' => 'topics#toggle_hide', :as => 'toggle_hide'
|
21
|
+
get 'toggle_lock' => 'topics#toggle_lock', :as => 'toggle_lock'
|
22
|
+
get 'toggle_pin' => 'topics#toggle_pin', :as => 'toggle_pin'
|
23
|
+
end
|
24
|
+
end
|
17
25
|
end
|
18
26
|
|
19
27
|
root :to => "forums#index"
|