This commit is contained in:
albert
2013-03-11 13:25:34 -04:00
parent c5ce14ac68
commit 17f1069719
6 changed files with 32 additions and 6 deletions

View File

@@ -23,14 +23,30 @@ class TagSubscriptionsController < ApplicationController
def create
@tag_subscription = TagSubscription.create(params[:tag_subscription])
respond_with(@tag_subscription, :location => tag_subscriptions_path)
respond_with(@tag_subscription) do |format|
format.html do
if @tag_subscription.errors.any?
render :action => "new"
else
redirect_to tag_subscriptions_path
end
end
end
end
def update
@tag_subscription = TagSubscription.find(params[:id])
check_privilege(@tag_subscription)
@tag_subscription.update_attributes(params[:tag_subscription])
respond_with(@tag_subscription, :location => tag_subscriptions_path)
respond_with(@tag_subscription) do |format|
format.html do
if @tag_subscription.errors.any?
render :action => "edit"
else
redirect_to tag_subscriptions_path
end
end
end
end
def destroy

View File

@@ -6,6 +6,7 @@ class TagSubscription < ActiveRecord::Base
before_save :limit_tag_count
attr_accessible :name, :tag_query, :post_ids, :is_public, :is_visible_on_profile
validates_presence_of :name, :tag_query, :creator_id
validates_format_of :tag_query, :with => /^(?:\S+\s*){1,20}$/, :message => "can have up to 20 tags"
validate :creator_can_create_subscriptions, :on => :create
def normalize_name
@@ -26,7 +27,7 @@ class TagSubscription < ActiveRecord::Base
def creator_can_create_subscriptions
if TagSubscription.owned_by(creator).count >= Danbooru.config.max_tag_subscriptions
self.errors.add(:creator, "can subscribe up to #{Danbooru.config.max_tag_subscriptions} tags")
self.errors.add(:creator, "can create up to #{Danbooru.config.max_tag_subscriptions} tag subscriptions")
return false
else
return true
@@ -38,7 +39,7 @@ class TagSubscription < ActiveRecord::Base
end
def limit_tag_count
self.tag_query = tag_query_array.slice(0, 20).join(" ")
# self.tag_query = tag_query_array.slice(0, 20).join(" ")
end
def process

View File

@@ -7,5 +7,5 @@
Is Public
</label>
</div>
<%= f.button :submit %>
<%= f.button :submit, "Submit" %>
<% end %>

View File

@@ -1,6 +1,9 @@
<div id="c-tag-subscriptions">
<div id="a-edit">
<h1>Edit Tag Subscription</h1>
<%= error_messages_for "tag_subscription" %>
<%= render "form" %>
</div>
</div>

View File

@@ -1,6 +1,9 @@
<div id="c-tag-subscriptions">
<div id="a-new">
<h1>New Tag Subscription</h1>
<%= error_messages_for "tag_subscription" %>
<%= render "form" %>
</div>
</div>

View File

@@ -25,4 +25,7 @@ en:
post_id: "You"
comment_vote:
comment: "You"
user_id: "You"
user_id: "You"
tag_subscription:
creator: "You"
creator_id: "You"