From 60029628b912f0c5d61fce7ae3fcaaa44761904e Mon Sep 17 00:00:00 2001 From: albert Date: Mon, 18 Feb 2013 15:17:14 -0500 Subject: [PATCH] reorganized ui for tag subscriptions --- app/controllers/tag_subscriptions_controller.rb | 2 +- app/models/tag_subscription.rb | 6 +++++- app/views/tag_subscriptions/index.html.erb | 13 +++++++++++-- app/views/tag_subscriptions/posts.html.erb | 2 +- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/app/controllers/tag_subscriptions_controller.rb b/app/controllers/tag_subscriptions_controller.rb index 2396bdc94..8de447389 100644 --- a/app/controllers/tag_subscriptions_controller.rb +++ b/app/controllers/tag_subscriptions_controller.rb @@ -23,7 +23,7 @@ class TagSubscriptionsController < ApplicationController def create @tag_subscription = TagSubscription.create(params[:tag_subscription]) - respond_with(@tag_subscription) + respond_with(@tag_subscription, :location => tag_subscriptions_path) end def update diff --git a/app/models/tag_subscription.rb b/app/models/tag_subscription.rb index 53df2302e..7d300c6d9 100644 --- a/app/models/tag_subscription.rb +++ b/app/models/tag_subscription.rb @@ -4,7 +4,7 @@ class TagSubscription < ActiveRecord::Base before_validation :initialize_post_ids, :on => :create before_save :normalize_name before_save :limit_tag_count - attr_accessible :name, :tag_query, :post_ids, :is_visible_on_profile + attr_accessible :name, :tag_query, :post_ids, :is_public, :is_visible_on_profile validates_presence_of :name, :tag_query, :is_public, :creator_id def normalize_name @@ -42,6 +42,10 @@ class TagSubscription < ActiveRecord::Base user.is_moderator? || creator_id == user.id end + def post_id_array + post_ids.split(/,/) + end + def self.search(params) q = scoped return q if params.blank? diff --git a/app/views/tag_subscriptions/index.html.erb b/app/views/tag_subscriptions/index.html.erb index cc8d132f3..c91e11320 100644 --- a/app/views/tag_subscriptions/index.html.erb +++ b/app/views/tag_subscriptions/index.html.erb @@ -7,14 +7,23 @@ Creator Name Tag Query + <% if CurrentUser.is_admin? %> + Count + <% end %> + <% @tag_subscriptions.each do |tag_subscription| %> <%= link_to tag_subscription.creator.name, user_path(tag_subscription.creator_id) %> - <%= link_to tag_subscription.name, edit_tag_subscription_path(tag_subscription) %> - <%= link_to tag_subscription.tag_query, posts_path(:tags => "sub:#{tag_subscription.creator.name}:#{tag_subscription.name}") %> + <%= tag_subscription.name %> + <%= tag_subscription.tag_query %> + <%= tag_subscription.post_id_array.size %> + + <%= link_to "edit", edit_tag_subscription_path(tag_subscription) %> + | <%= link_to "posts", posts_path(:tags => "sub:#{tag_subscription.creator.name}:#{tag_subscription.name}") %> + <% end %> diff --git a/app/views/tag_subscriptions/posts.html.erb b/app/views/tag_subscriptions/posts.html.erb index b2b6881e3..9fa1d8b10 100644 --- a/app/views/tag_subscriptions/posts.html.erb +++ b/app/views/tag_subscriptions/posts.html.erb @@ -9,7 +9,7 @@
-

Tag Subscriptions

+

Tag Subscriptions [<%= link_to "edit", tag_subscriptions_path %>]

<%= @post_set.presenter.post_previews_html(self) %>