tag subscription listing limited to current user
This commit is contained in:
@@ -16,7 +16,7 @@ class TagSubscriptionsController < ApplicationController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@user = CurrentUser.user
|
@user = CurrentUser.user
|
||||||
@search = TagSubscription.visible_to(@user).search(params[:search])
|
@search = TagSubscription.owned_by(@user).search(params[:search])
|
||||||
@tag_subscriptions = @search.paginate(params[:page])
|
@tag_subscriptions = @search.paginate(params[:page])
|
||||||
respond_with(@tag_subscriptions)
|
respond_with(@tag_subscriptions)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -60,6 +60,10 @@ class TagSubscription < ActiveRecord::Base
|
|||||||
def self.visible_to(user)
|
def self.visible_to(user)
|
||||||
where("(is_public = TRUE OR creator_id = ? OR ?)", user.id, user.is_moderator?)
|
where("(is_public = TRUE OR creator_id = ? OR ?)", user.id, user.is_moderator?)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.owned_by(user)
|
||||||
|
where("creator_id = ?", user.id)
|
||||||
|
end
|
||||||
|
|
||||||
def self.find_tags(subscription_name)
|
def self.find_tags(subscription_name)
|
||||||
if subscription_name =~ /^(.+?):(.+)$/
|
if subscription_name =~ /^(.+?):(.+)$/
|
||||||
|
|||||||
Reference in New Issue
Block a user