summaryrefslogtreecommitdiff
path: root/app/controllers/snippets_controller.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-06-05 22:25:27 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-06-05 22:25:27 +0300
commite7bcbb95c88a42fc31bc0ccbdf6a819780a612ec (patch)
tree3d29ffada6edbd662c692a1bc3adb63696511b84 /app/controllers/snippets_controller.rb
parent36e832cc280115673e96f3adf624b9737d40f7fd (diff)
downloadgitlab-ce-e7bcbb95c88a42fc31bc0ccbdf6a819780a612ec.tar.gz
Restyle snippets
Diffstat (limited to 'app/controllers/snippets_controller.rb')
-rw-r--r--app/controllers/snippets_controller.rb33
1 files changed, 21 insertions, 12 deletions
diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb
index 70525beea15..49b740af046 100644
--- a/app/controllers/snippets_controller.rb
+++ b/app/controllers/snippets_controller.rb
@@ -15,19 +15,28 @@ class SnippetsController < ApplicationController
def user_index
@user = User.find_by_username(params[:username])
-
- @snippets = @current_user.snippets.fresh.non_expired
-
- @snippets = case params[:scope]
- when 'public' then
- @snippets.public
- when 'private' then
- @snippets.private
- else
- @snippets
- end
+ @snippets = @user.snippets.fresh.non_expired
+
+ if @user == current_user
+ @snippets = case params[:scope]
+ when 'public' then
+ @snippets.public
+ when 'private' then
+ @snippets.private
+ else
+ @snippets
+ end
+ else
+ @snippets = @snippets.public
+ end
@snippets = @snippets.page(params[:page]).per(20)
+
+ if @user == current_user
+ render 'current_user_index'
+ else
+ render 'user_index'
+ end
end
def new
@@ -79,7 +88,7 @@ class SnippetsController < ApplicationController
protected
def snippet
- @snippet ||= PersonalSnippet.find(params[:id])
+ @snippet ||= PersonalSnippet.where('author_id = :user_id or private is false', user_id: current_user.id).find(params[:id])
end
def authorize_modify_snippet!