fixes #834
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -7,5 +7,5 @@
|
||||
Is Public
|
||||
</label>
|
||||
</div>
|
||||
<%= f.button :submit %>
|
||||
<%= f.button :submit, "Submit" %>
|
||||
<% end %>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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"
|
||||
Reference in New Issue
Block a user