aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
authorKir2011-11-16 14:41:29 +0400
committerKir2011-11-16 14:41:29 +0400
commit661590c630f022fc678c4d5664b497db13de6eec (patch)
tree0c434d3e4560b6cb13c7184c31472dd824b5bbe5 /app/controllers
parent61bd4dd67fdaee93af6994d539b86d46cd1c45f1 (diff)
downloadinboxes-661590c630f022fc678c4d5664b497db13de6eec.tar.bz2
Faye integration, resources under modulev0.0.1
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/inboxes/base_controller.rb3
-rw-r--r--app/controllers/inboxes/discussions_controller.rb (renamed from app/controllers/discussions_controller.rb)18
-rw-r--r--app/controllers/inboxes/messages_controller.rb (renamed from app/controllers/messages_controller.rb)2
-rw-r--r--app/controllers/inboxes/speakers_controller.rb (renamed from app/controllers/speakers_controller.rb)2
4 files changed, 14 insertions, 11 deletions
diff --git a/app/controllers/inboxes/base_controller.rb b/app/controllers/inboxes/base_controller.rb
new file mode 100644
index 0000000..54767d2
--- /dev/null
+++ b/app/controllers/inboxes/base_controller.rb
@@ -0,0 +1,3 @@
+class Inboxes::BaseController < ApplicationController
+
+end \ No newline at end of file
diff --git a/app/controllers/discussions_controller.rb b/app/controllers/inboxes/discussions_controller.rb
index 5e769fb..d901a80 100644
--- a/app/controllers/discussions_controller.rb
+++ b/app/controllers/inboxes/discussions_controller.rb
@@ -1,7 +1,6 @@
-class DiscussionsController < ApplicationController
+class Inboxes::DiscussionsController < Inboxes::BaseController
before_filter :authenticate_user!
- # before_filter :check_permissions, :only => :show
-
+ before_filter :init_and_check_permissions, :only => :show
before_filter :load_and_check_discussion_recipient, :only => [:create, :new]
def index
@@ -11,10 +10,7 @@ class DiscussionsController < ApplicationController
# GET /discussions/1
# GET /discussions/1.json
def show
- @discussion = Discussion.includes(:messages, :speakers).find(params[:id])
- redirect_to discussions_url, :notice => t("inboxes.discussions.can_not_participate") unless @discussion.can_participate?(current_user)
-
- # @discussion.mark_as_read_for(current_user)
+ @discussion.mark_as_read_for(current_user)
end
# GET /discussions/new
@@ -44,6 +40,11 @@ class DiscussionsController < ApplicationController
private
+ def init_and_check_permissions
+ @discussion = Discussion.includes(:messages, :speakers).find(params[:id])
+ redirect_to discussions_url, :notice => t("inboxes.discussions.can_not_participate") unless @discussion.can_participate?(current_user)
+ end
+
def load_and_check_discussion_recipient
# initializing model fir new and create actions
@discussion = Discussion.new((params[:discussion] ? params[:discussion] : {}))
@@ -63,5 +64,4 @@ class DiscussionsController < ApplicationController
end
end
end
-
-end
+end \ No newline at end of file
diff --git a/app/controllers/messages_controller.rb b/app/controllers/inboxes/messages_controller.rb
index 7baf8df..1c63221 100644
--- a/app/controllers/messages_controller.rb
+++ b/app/controllers/inboxes/messages_controller.rb
@@ -1,4 +1,4 @@
-class MessagesController < ApplicationController
+class Inboxes::MessagesController < Inboxes::BaseController
def create
@discussion = Discussion.find(params[:discussion_id])
diff --git a/app/controllers/speakers_controller.rb b/app/controllers/inboxes/speakers_controller.rb
index db90dbe..035df98 100644
--- a/app/controllers/speakers_controller.rb
+++ b/app/controllers/inboxes/speakers_controller.rb
@@ -1,4 +1,4 @@
-class SpeakersController < ApplicationController
+class Inboxes::SpeakersController < Inboxes::BaseController
before_filter :init_and_check_permissions
def create