mongoid-forums 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 45a00ce068be722969563d03aa5b241dc8458bc5
4
- data.tar.gz: 997217696967e803e059181b22ef5a078ee7867c
3
+ metadata.gz: c266cda2076fe7b0bb1cdad4798d635db146f328
4
+ data.tar.gz: f19e5cb56aebfc83d236ffb054b462a5deb24f64
5
5
  SHA512:
6
- metadata.gz: 599d86aadd02dd03575a51b777fa20f5034edf536438edb936a14aa62301bf13ed62303cd9d7f9d7b9839e31fc683ff3fe00fc9a0616fa1ff016d4318583e72b
7
- data.tar.gz: 12df9211a061dcad6acb25983aadd4d5bfdbe687cdd5ac7297c113fb416ffa6fcc5b86bb37c031282c09dfbb950cd53e2a2079a04b3f1fade1da22735c4aed01
6
+ metadata.gz: f671646679c467022155880c3981cacd7f630d9dd0d64de91dfb2b33bf3cecff302ea9ba8be199cfa506b49d89e0d75f73491213e870d8a578ec317bf5d7dcb1
7
+ data.tar.gz: 6b508b2572cbcc9c1b0ae9ea0acfe8f5af5afb23429a1c8fa06949ee067d3b7d6cecd8ddeea210e2271b254734fc50b413e7c9c19b57a55ec14ffeffb1b54640
@@ -21,10 +21,10 @@ module MongoidForums
21
21
 
22
22
  def create
23
23
  if @category = Category.create(category_params)
24
- flash[:notice] = "Category created successfully"
24
+ flash[:notice] = t("mongoid_forums.admin.category.created")
25
25
  redirect_to admin_categories_path
26
26
  else
27
- flash.now.alert = "Category could not be created"
27
+ flash.now.alert = t("mongoid_forums.admin.category.not_created")
28
28
  render :action => "new"
29
29
  end
30
30
  end
@@ -36,23 +36,19 @@ module MongoidForums
36
36
  def update
37
37
  @category = Category.find(params[:id])
38
38
  if @category.update(category_params)
39
- flash[:notice] = "Category updated successfully"
39
+ flash[:notice] = t("mongoid_forums.admin.category.updated")
40
40
  redirect_to admin_categories_path
41
41
  else
42
- flash.now.alert = "Category could not be updated"
42
+ flash[:notice] = t("mongoid_forums.admin.category.not_updated")
43
43
  render :action => "edit"
44
44
  end
45
45
  end
46
46
 
47
47
  def destroy
48
48
  @category = Category.find(params[:id])
49
- if @category.destroy
50
- flash[:notice] = "Category destroyed successfully"
51
- redirect_to admin_categories_path
52
- else
53
- flash.now.alert = "Category could not be destroyed"
54
- render :action => "index"
55
- end
49
+ @category.destroy
50
+ flash[:notice] = t("mongoid_forums.admin.category.deleted")
51
+ redirect_to admin_categories_path
56
52
  end
57
53
 
58
54
  ### Temporary Methods - Try Not To Cringe Too Much <3 ###
@@ -16,10 +16,10 @@ module MongoidForums
16
16
  def create
17
17
  @forum = Forum.new(forum_params)
18
18
  if @forum.save
19
- flash[:notice] = "Forum created successfully"
19
+ flash[:notice] = t("mongoid_forums.admin.forum.created")
20
20
  redirect_to [:admin, @forum]
21
21
  else
22
- flash.now.alert = "Forum could not be created"
22
+ flash.now.alert = t("mongoid_forums.admin.forum.not_created")
23
23
  render :action => "new"
24
24
  end
25
25
  end
@@ -36,23 +36,19 @@ module MongoidForums
36
36
  def update
37
37
  @forum = Forum.find(params[:id])
38
38
  if @forum.update(forum_params)
39
- flash[:notice] = "Forum updated successfully"
39
+ flash[:notice] = t("mongoid_forums.admin.forum.updated")
40
40
  redirect_to @forum
41
41
  else
42
- flash.now.alert = "Forum could not be updated"
42
+ flash.now.alert = t("mongoid_forums.admin.forum.not_updated")
43
43
  render :action => "edit"
44
44
  end
45
45
  end
46
46
 
47
47
  def destroy
48
48
  @forum = Forum.find(params[:id])
49
- if @forum.destroy
50
- flash[:notice] = "Forum destroyed successfully"
51
- redirect_to admin_forums_path
52
- else
53
- flash.now.alert = "Forum could not be destroyed"
54
- render :action => "index"
55
- end
49
+ @forum.destroy
50
+ flash[:notice] = t("mongoid_forums.admin.forum.deleted")
51
+ redirect_to admin_forums_path
56
52
  end
57
53
 
58
54
  ### Temporary Methods - Try Not To Cringe Too Much <3 ###
@@ -13,11 +13,12 @@ module MongoidForums
13
13
  end
14
14
 
15
15
  def create
16
- if @group = Group.create(params.require(:group).permit(:name, :moderator, :members))
17
- flash[:notice] = "Group created successfully"
16
+ @group = Group.new(params.require(:group).permit(:name, :moderator, :members))
17
+ if @group.save
18
+ flash[:notice] = t("mongoid_forums.admin.group.created")
18
19
  redirect_to [:admin, @group]
19
20
  else
20
- flash.now.alert = "Group could not be created"
21
+ flash[:notice] = t("mongoid_forums.admin.group.not_created")
21
22
  render :action => "new"
22
23
  end
23
24
  end
@@ -29,10 +30,10 @@ module MongoidForums
29
30
  def update
30
31
  @group = Group.find(params[:id])
31
32
  if @group.update_attributes(params.require(:group).permit(:name, :members))
32
- flash[:notice] = "Group updated successfully"
33
+ flash[:notice] = t("mongoid_forums.admin.group.updated")
33
34
  redirect_to [:admin, @group]
34
35
  else
35
- flash[:notice] = "Group could not be updated"
36
+ flash[:notice] = t("mongoid_forums.admin.group.not_updated")
36
37
  render :action => "edit"
37
38
  end
38
39
  end
@@ -45,14 +46,9 @@ module MongoidForums
45
46
 
46
47
  def destroy
47
48
  @group = Group.find(params[:id])
48
-
49
- if @group.destroy
50
- flash[:notice] = "Group destroyed successfully"
51
- redirect_to admin_groups_path
52
- else
53
- flash.now.alert = "Group could not be destroyed"
54
- redirect_to admin_groups_path
55
- end
49
+ @group.destroy
50
+ flash[:notice] = t("mongoid_forums.admin.group.deleted")
51
+ redirect_to admin_groups_path
56
52
  end
57
53
 
58
54
  ### Temporary Methods - Try Not To Cringe Too Much <3 ###
@@ -29,7 +29,7 @@ class MongoidForums::ApplicationController < ApplicationController
29
29
  def authenticate_mongoid_forums_user
30
30
  if !mongoid_forums_user
31
31
  session["user_return_to"] = request.fullpath
32
- flash.alert = "You must be signed in"
32
+ flash.alert = t("mongoid_forums.errors.not_signed_in")
33
33
  devise_route = "new_#{MongoidForums.user_class.to_s.underscore}_session_path"
34
34
  sign_in_path = MongoidForums.sign_in_path ||
35
35
  (main_app.respond_to?(devise_route) && main_app.send(devise_route)) ||
@@ -43,10 +43,10 @@ module MongoidForums
43
43
  @topic.posts << @post
44
44
 
45
45
  if @topic.save && @topic.posts.first.save
46
- flash[:notice] = "Topic created successfully"
46
+ flash[:notice] = t("mongoid_forums.topic.created")
47
47
  redirect_to @topic
48
48
  else
49
- flash.now.alert = "Topic could not be created"
49
+ flash.now.alert = t("mongoid_forums.topic.not_created")
50
50
  render :action => "new"
51
51
  end
52
52
  end
@@ -4,6 +4,7 @@ module MongoidForums
4
4
  class PostsController < ApplicationController
5
5
  before_filter :find_topic
6
6
  before_filter :authenticate_mongoid_forums_user, except: :show
7
+ before_filter :reject_locked_topic!, only: [:new, :create]
7
8
 
8
9
  def new
9
10
  authorize! :reply, @topic
@@ -11,33 +12,34 @@ module MongoidForums
11
12
  @post.topic = @topic.id
12
13
  if params[:reply_to_id]
13
14
  find_reply_to_post
14
- end
15
- end
16
-
17
- def create
18
- authorize! :reply, @topic
19
- @post = @topic.posts.build(post_params)
20
- @post.user = mongoid_forums_user
21
15
 
22
- if @post.reply_to_id && @post.reply_to_id == @topic.posts.first.id
23
- flash[:alert] = "You may not quote the original post"
24
- redirect_to @topic
25
- return
16
+ if @reply_to.id && @reply_to.id == @topic.posts.first.id
17
+ flash[:alert] = t("mongoid_forums.post.not_created_quote_original_post")
18
+ redirect_to @topic
19
+ return
20
+ end
26
21
  end
27
22
 
28
23
  if @topic.locked
29
- flash[:alert] = "You may not post on a locked topic"
24
+ flash[:alert] = t("mongoid_forums.post.not_created_topic_locked")
30
25
  redirect_to @topic
31
26
  return
32
27
  end
33
28
 
29
+ end
30
+
31
+ def create
32
+ authorize! :reply, @topic
33
+ @post = @topic.posts.build(post_params)
34
+ @post.user = mongoid_forums_user
35
+
34
36
  if @post.save
35
37
  @topic.alert_subscribers(mongoid_forums_user.id)
36
38
  @topic.forum.increment_posts_count
37
- flash[:notice] = "Reply created successfully"
39
+ flash[:notice] = t("mongoid_forums.post.created")
38
40
  redirect_to @topic
39
41
  else
40
- flash.now.alert = "Reply could not be created"
42
+ flash.now.alert = t("mongoid_forums.post.not_created")
41
43
  render :action => "new"
42
44
  end
43
45
  end
@@ -51,19 +53,13 @@ module MongoidForums
51
53
  end
52
54
 
53
55
  def update
54
- if @topic.locked?
55
- flash.alert = "You may not update a post on a locked topic!"
56
- redirect_to [@topic] and return
57
- end
58
-
59
56
  authorize! :edit_post, @topic.forum
60
57
  find_post
61
58
 
62
59
  if @post.owner_or_admin?(mongoid_forums_user) && @post.update_attributes(post_params)
63
- flash[:notice] = "Reply updated successfully"
64
- redirect_to @topic
60
+ redirect_to @topic, :notice => t('edited', :scope => 'mongoid_forums.post')
65
61
  else
66
- flash[:notice] = "Reply could not be updated"
62
+ flash.now.alert = t("mongoid_forums.post.not_edited")
67
63
  render :action => "edit"
68
64
  end
69
65
  end
@@ -71,7 +67,7 @@ module MongoidForums
71
67
  def destroy
72
68
  find_post
73
69
  if @topic.posts.first == @post
74
- flash[:alert] = "You may not delete the first post!"
70
+ flash[:alert] = t("mongoid_forums.post.cannot_delete_first_post")
75
71
  redirect_to @topic
76
72
  return
77
73
  end
@@ -84,24 +80,32 @@ module MongoidForums
84
80
  end
85
81
 
86
82
  if @post.destroy
87
- flash[:notice] = "Post deleted successfully"
83
+ flash[:notice] = t("mongoid_forums.post.deleted")
88
84
  redirect_to @topic
89
85
  else
90
- flash[:notice] = "Post could not be deleted"
86
+ flash[:notice] = t("mongoid_forums.post.cannot_delete")
91
87
  redirect_to @topic
92
88
  end
93
89
  end
94
90
 
95
91
  private
96
92
 
93
+ #TODO: Decide if this should be used
97
94
  def destroy_successful
98
95
  if @post.topic.posts.count == 0
99
96
  @post.topic.destroy
100
97
  flash[:notice] = "Post was deleted successfully along with it's topic."
101
- redirect_to [@topic.forum]
98
+ redirect_to @topic.forum
102
99
  else
103
100
  flash[:notice] = "Post was deleted successfully"
104
- redirect_to [@topic.forum, @topic]
101
+ redirect_to @topic
102
+ end
103
+ end
104
+
105
+ def reject_locked_topic!
106
+ if @topic.locked?
107
+ flash.alert = t("mongoid_forums.post.not_created_topic_locked")
108
+ redirect_to @topic and return
105
109
  end
106
110
  end
107
111
 
@@ -38,7 +38,7 @@ module MongoidForums
38
38
  def subscribe
39
39
  if find_topic
40
40
  @topic.subscribe_user(mongoid_forums_user.id)
41
- flash[:notice] = "Successfully subscribed to topic"
41
+ flash[:notice] = t("mongoid_forums.topic.subscribed")
42
42
  redirect_to topic_url(@topic)
43
43
  end
44
44
  end
@@ -46,7 +46,7 @@ module MongoidForums
46
46
  def unsubscribe
47
47
  if find_topic
48
48
  @topic.unsubscribe_user(mongoid_forums_user.id)
49
- flash[:notice] = "Successfully unsubscribed to topic"
49
+ flash[:notice] = t("mongoid_forums.topic.unsubscribed")
50
50
  redirect_to topic_url(@topic)
51
51
  end
52
52
  end
@@ -63,7 +63,7 @@ module MongoidForums
63
63
  @topic = scope.find(params[:id])
64
64
  authorize! :read, @topic
65
65
  rescue Mongoid::Errors::DocumentNotFound
66
- flash.alert = t("forem.topic.not_found")
66
+ flash.alert = t("mongoid_forums.topic.not_found")
67
67
  redirect_to @forum and return
68
68
  end
69
69
  end
@@ -38,6 +38,8 @@ en:
38
38
  index: Manage Groups
39
39
  created: The group was successfully created.
40
40
  not_created: Group could not be created.
41
+ updated: The group was successfully updated.
42
+ not_updated: Group could not be updated.
41
43
  deleted: The selected group has been deleted.
42
44
  groups:
43
45
  show:
@@ -145,11 +147,13 @@ en:
145
147
  edit: Edit
146
148
  not_created: Your reply could not be posted.
147
149
  not_created_topic_locked: You cannot reply to a locked topic.
150
+ not_created_quote_original_post: You cannot quote the original post.
148
151
  edited: Your post has been edited.
149
152
  not_edited: Your post could not be edited.
150
153
  deleted: Your post has been deleted.
151
154
  deleted_with_topic: Only post in topic deleted. Topic also deleted.
152
155
  cannot_delete: You cannot delete a post you do not own.
156
+ cannot_delete_first_post: You cannot delete the first post in a topic.
153
157
  in_reply_to: In reply to
154
158
  posts:
155
159
  moderation:
@@ -1,4 +1,3 @@
1
1
  module MongoidForums
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
4
-