Compare commits

...

2 commits

Author SHA1 Message Date
4ae5acfdc3 Disallow email addresses in closet list descriptions
Just another attempt to communicate the rules!
2024-04-16 17:04:31 -07:00
1cbcb5bcd6 Add trade warning to closet list form
Just a lil blurb to make sure it's clear that NC sales and stuff are
forbidden! I imagine the people doing it know this, but I want to make
sure we're being explicit, in case there's any element of
miscommunication.
2024-04-16 16:53:30 -07:00
5 changed files with 41 additions and 3 deletions

View file

@ -0,0 +1,7 @@
document.addEventListener("change", ({ target }) => {
if (target.matches('select[name="closet_list[visibility]"]')) {
target
.closest("form")
.setAttribute("data-list-visibility", target.value);
}
});

View file

@ -1,4 +1,5 @@
@import "../partials/secondary_nav"
@import "../partials/clean/mixins"
body.closet_lists-new, body.closet_lists-create, body.closet_lists-edit, body.closet_lists-update
+secondary-nav
@ -30,3 +31,15 @@ body.closet_lists-new, body.closet_lists-create, body.closet_lists-edit, body.cl
font:
size: 85%
.trade-warning
+warning
margin-bottom: 1em
padding: .75em .5em
text-align: center
p:last-of-type
margin-bottom: 0
// Only show the trade warning when the list is marked as Trading!
form:not([data-list-visibility="2"]) .trade-warning
display: none

View file

@ -8,7 +8,7 @@ class ClosetListsController < ApplicationController
save_successful!
else
save_failed!
render :action => :new
render action: :new, status: :unprocessable_entity
end
end
@ -28,7 +28,7 @@ class ClosetListsController < ApplicationController
save_successful!
else
save_failed!
render :action => :edit
render action: :edit, status: :unprocessable_entity
end
end

View file

@ -5,6 +5,12 @@ class ClosetList < ApplicationRecord
validates :name, :presence => true, :uniqueness => {:scope => :user_id}
validates :user, :presence => true
validates :hangers_owned, :inclusion => {:in => [true, false], :message => "can't be blank"}
validates :description, format: {
# This isn't a very careful email filter! It's easy to avoid. But the
# purpose is to communicate the rules, more than actual prevention.
without: /\b([\w+\-].?)+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\b/i, # from emailregex.com
message: "must not contain email addresses"
}
delegate :log_trade_activity, to: :user

View file

@ -1,7 +1,8 @@
- secondary_nav do
= link_to t('.your_items_link'), user_closet_hangers_path(current_user), :class => 'button'
= form_for [@closet_list.user, @closet_list] do |f|
= form_for [@closet_list.user, @closet_list],
html: {data: {"list-visibility" => @closet_list.visibility}} do |f|
%ul.fields
%li
= f.label :name
@ -18,5 +19,16 @@
%span.hint= t '.description.hint'
= f.text_area :description
%span.hint= t '.description.markup_hint_html'
%li.trade-warning
:markdown
Please use these lists *only* for real NC trades, negotiated on
Neopets.com! We need to keep users safe, so we'll delete *any* list
that seems suspicious.
If you're doing something more creative, please do so in another
setting, where traders can better manage reputation and trust. Thank
you!
= f.submit t('.submit')
- content_for :javascripts do
= javascript_include_tag "closet_lists/form"