mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
Remove add link when maximum tags is reached
This commit is contained in:
parent
460dea3f5e
commit
019ceff01c
2 changed files with 9 additions and 5 deletions
|
@ -128,6 +128,8 @@ class Site < Sequel::Model
|
||||||
|
|
||||||
BLOCK_JERK_THRESHOLD = 3
|
BLOCK_JERK_THRESHOLD = 3
|
||||||
|
|
||||||
|
MAXIMUM_TAGS = 5
|
||||||
|
|
||||||
def self.newsletter_sites
|
def self.newsletter_sites
|
||||||
Site.select(:email).
|
Site.select(:email).
|
||||||
exclude(email: 'nil').exclude(is_banned: true).
|
exclude(email: 'nil').exclude(is_banned: true).
|
||||||
|
@ -962,8 +964,8 @@ class Site < Sequel::Model
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if ((new? ? 0 : tags_dataset.count) + new_tags.length > 5)
|
if ((new? ? 0 : tags_dataset.count) + new_tags.length > MAXIMUM_TAGS)
|
||||||
errors.add :new_tags_string, 'Cannot have more than 5 tags for your site.'
|
errors.add :new_tags_string, "Cannot have more than #{MAXIMUM_TAGS} tags for your site."
|
||||||
end
|
end
|
||||||
|
|
||||||
new_tags.each do |tag|
|
new_tags.each do |tag|
|
||||||
|
|
|
@ -9,13 +9,15 @@
|
||||||
|
|
||||||
<% if is_current_site %>
|
<% if is_current_site %>
|
||||||
<div class="clear">
|
<div class="clear">
|
||||||
<a href="#addTag" data-toggle="modal">Add</a>
|
<% if is_current_site && current_site.tags_dataset.count < Site::MAXIMUM_TAGS %>
|
||||||
|
<a href="#addTag" data-toggle="modal">Add</a>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<a href="#removeTag" data-toggle="modal">Remove</a>
|
<a href="#removeTag" data-toggle="modal">Remove</a>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="modal hide fade" id="addTag" tabindex="-1" role="dialog" aria-labelledby="addTagLabel" aria-hidden="true">
|
<div class="modal hide fade" id="addTag" tabindex="-1" role="dialog" aria-labelledby="addTagLabel" aria-hidden="true">
|
||||||
<form method="POST" action="/tags/add">
|
<form method="POST" action="/tags/add">
|
||||||
|
@ -58,4 +60,4 @@
|
||||||
<button type="submit" class="btn-Action">Remove Tag(s)</button>
|
<button type="submit" class="btn-Action">Remove Tag(s)</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue