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
|
||||
|
||||
MAXIMUM_TAGS = 5
|
||||
|
||||
def self.newsletter_sites
|
||||
Site.select(:email).
|
||||
exclude(email: 'nil').exclude(is_banned: true).
|
||||
|
@ -962,8 +964,8 @@ class Site < Sequel::Model
|
|||
end
|
||||
end
|
||||
|
||||
if ((new? ? 0 : tags_dataset.count) + new_tags.length > 5)
|
||||
errors.add :new_tags_string, 'Cannot have more than 5 tags for your site.'
|
||||
if ((new? ? 0 : tags_dataset.count) + new_tags.length > MAXIMUM_TAGS)
|
||||
errors.add :new_tags_string, "Cannot have more than #{MAXIMUM_TAGS} tags for your site."
|
||||
end
|
||||
|
||||
new_tags.each do |tag|
|
||||
|
|
|
@ -9,13 +9,15 @@
|
|||
|
||||
<% if is_current_site %>
|
||||
<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>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<div class="modal hide fade" id="addTag" tabindex="-1" role="dialog" aria-labelledby="addTagLabel" aria-hidden="true">
|
||||
<form method="POST" action="/tags/add">
|
||||
|
@ -58,4 +60,4 @@
|
|||
<button type="submit" class="btn-Action">Remove Tag(s)</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Reference in a new issue