-
Notifications
You must be signed in to change notification settings - Fork 519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AO3-5860 Prevent leaving comments or kudos when logged in as admin #4378
Changes from 46 commits
cc10ee2
1fba796
1ee02e0
9142a82
12c31ba
7aa02d3
4ed8ade
33b89e0
0228eed
731229a
d43483b
60da2d0
f33f7d3
f50f30b
f876634
1416d90
2bbe0f8
05d8843
485ff75
dde9452
bac38ce
45d007d
75ba8e7
5d79d12
987c85e
21a2048
68c056b
a1c39fa
face994
6a402bd
24c925b
ba071ea
079c090
bdb5b41
5ddfb2e
70f4e2a
8923da3
8ab8775
493d6fa
5e8e94f
0ec17bf
9266392
b329103
7155047
9c7a080
55b0885
ce366d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,9 @@ | |
<div class="post comment" id="comment_form_for_<%= commentable.id %>"> | ||
<%= form_for value_for_comment_form(commentable, comment), remote: !comment.new_record?, authenticity_token: true, html: { id: "comment_for_#{commentable.id}" } do |f| %> | ||
<fieldset> | ||
<legend><%= ts("Post Comment") %></legend> | ||
<legend><%= t(".legend") %></legend> | ||
|
||
<% # here come the hacks (hidden fields to transmit various info to the create action) %> | ||
<%# here come the hacks (hidden fields to transmit various info to the create action) %> | ||
<% if commentable.is_a?(Tag) %> | ||
<%= hidden_field_tag :tag_id, commentable.name %> | ||
<% end %> | ||
|
@@ -28,88 +28,77 @@ | |
|
||
<% if comments_are_moderated(commentable) && !current_user_is_work_creator(commentable) %> | ||
<p class="notice"> | ||
<%= ts("This work's creator has chosen to moderate comments on the work. Your comment will not appear until it has been approved by the creator.") %> | ||
<%= t(".moderation_forewarning") %> | ||
</p> | ||
<% end %> | ||
|
||
<% if logged_in? %> | ||
<% if current_user_is_anonymous_creator(commentable) %> | ||
<p class="notice"> | ||
<%= ts("While this work is anonymous, comments you post will also be listed anonymously.") %> | ||
<%= t(".anonymous_forewarning") %> | ||
</p> | ||
<% end %> | ||
|
||
<% if current_user.pseuds.count > 1 %> | ||
<h4 class="heading"><%= ts("Comment as") %> <%= f.collection_select :pseud_id, current_user.pseuds, :id, :name, {:selected => (comment.pseud ? comment.pseud.id.to_s : current_user.default_pseud.id.to_s)}, :id => "comment_pseud_id_for_#{commentable.id}", :title => ts("Choose Name") %> | ||
<h4 class="heading"><%= t(".comment_as") %> <%= f.collection_select :pseud_id, current_user.pseuds, :id, :name, { selected: (comment.pseud ? comment.pseud.id.to_s : current_user.default_pseud.id.to_s) }, id: "comment_pseud_id_for_#{commentable.id}", title: t(".choose_name_field_title") %> | ||
<% if controller.controller_name == "inbox" %> | ||
<% if commentable.by_anonymous_creator? %> | ||
<span><%= ts("to") %> <%= "Anonymous Creator" %> <%= ts("on") %> <%= commentable_description_link(commentable) %></span> | ||
<% else %> | ||
<span><%= ts("to") %> <%= get_commenter_pseud_or_name(commentable) %> <%= ts("on") %> <%= commentable_description_link(commentable) %></span> | ||
<% end %> | ||
<span><%= t ".inbox_reference", | ||
commentable_creator: commentable.by_anonymous_creator? ? "Anonymous Creator" : get_commenter_pseud_or_name(commentable), | ||
ceithir marked this conversation as resolved.
Show resolved
Hide resolved
|
||
commentable_link: commentable_description_link(commentable) %></span> | ||
<% end %> | ||
(<%= allowed_html_instructions %>) | ||
</h4> | ||
<% else %> | ||
<h4 class="heading"><%= ts("Comment as") %> <span class="byline"><%= current_user.default_pseud.name %></span> | ||
<%= f.hidden_field :pseud_id, :value => "#{current_user.default_pseud.id}", :id => "comment_pseud_id_for_#{commentable.id}" %> | ||
<h4 class="heading"><%= t(".comment_as") %> <span class="byline"><%= current_user.default_pseud.name %></span> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure on this, but making a note anyway: |
||
<%= f.hidden_field :pseud_id, value: current_user.default_pseud.id.to_s, id: "comment_pseud_id_for_#{commentable.id}" %> | ||
<% if controller.controller_name == "inbox" %> | ||
<% if commentable.by_anonymous_creator? %> | ||
<span><%= ts("to") %> <%= "Anonymous Creator" %> <%= ts("on") %> <%= commentable_description_link(commentable) %></span> | ||
<% else %> | ||
<span><%= ts("to") %> <%= get_commenter_pseud_or_name(commentable) %> <%= ts("on") %> <%= commentable_description_link(commentable) %></span> | ||
<% end %> | ||
<span><%= t ".inbox_reference", | ||
commentable_creator: commentable.by_anonymous_creator? ? "Anonymous Creator" : get_commenter_pseud_or_name(commentable), | ||
commentable_link: commentable_description_link(commentable) %></span> | ||
<% end %> | ||
</h4> | ||
<p class="footnote">(<%= allowed_html_instructions %>)</p> | ||
<% end %> | ||
|
||
<% elsif logged_in_as_admin? %> | ||
<h4 class="heading"><%= ts("Comment as") %> <span class="byline"><%= current_admin.login %></span> | ||
<%= f.hidden_field :name, :value => "#{current_admin.login}", :id => "comment_name_for_#{commentable.id}" %> | ||
<%= f.hidden_field :email, :value => "#{current_admin.email}", :id => "comment_email_for_#{commentable.id}" %> | ||
</h4> | ||
<p class="footnote">(<%= allowed_html_instructions %>)</p> | ||
|
||
<% else %> | ||
<dl> | ||
<dt class="landmark"><%= ts("Note") %>:</dt> | ||
<dd class="instructions comment_form"><%=ts("All fields are required. Your email address will not be published.") %></dd> | ||
<dt><%= f.label "name_for_#{commentable.id}", ts("Guest name: ") %></dt> | ||
<dt class="landmark"><%= t(".landmark.note") %>:</dt> | ||
<dd class="instructions comment_form"><%= t(".guest_instructions") %></dd> | ||
<dt><%= f.label "name_for_#{commentable.id}", t(".guest_name") %></dt> | ||
<dd> | ||
<%= f.text_field :name, :id => "comment_name_for_#{commentable.id}" %> | ||
<%= live_validation_for_field("comment_name_for_#{commentable.id}", :failureMessage => ts('Please enter your name.')) %> | ||
<%= f.text_field :name, id: "comment_name_for_#{commentable.id}" %> | ||
<%= live_validation_for_field("comment_name_for_#{commentable.id}", failureMessage: t(".guest_name_failure")) %> | ||
</dd> | ||
<dt><%= f.label "email_for_#{commentable.id}", ts("Guest email: ") %></dt> | ||
<dt><%= f.label "email_for_#{commentable.id}", t(".guest_email") %></dt> | ||
<dd> | ||
<%= f.text_field :email, :id => "comment_email_for_#{commentable.id}" %> | ||
<%= live_validation_for_field("comment_email_for_#{commentable.id}", :failureMessage => ts('Please enter your email address.')) %> | ||
<%= f.text_field :email, id: "comment_email_for_#{commentable.id}" %> | ||
<%= live_validation_for_field("comment_email_for_#{commentable.id}", failureMessage: t(".guest_email_failure")) %> | ||
</dd> | ||
</dl> | ||
<p class="footnote">(<%= allowed_html_instructions %>)</p> | ||
<% end %> | ||
|
||
<p> | ||
<% content_id = "comment_content_for_#{commentable.id}" %> | ||
<label for="<%= content_id %>" class="landmark"><%= ts("Comment") %></label> | ||
<%= f.text_area :comment_content, :id => content_id, :class => "comment_form observe_textlength", :title => ts("Enter Comment") %> | ||
<label for="<%= content_id %>" class="landmark"><%= t(".landmark.comment") %></label> | ||
<%= f.text_area :comment_content, id: content_id, class: "comment_form observe_textlength", title: t(".comment_field_title") %> | ||
<input type="hidden" id="controller_name_for_<%= commentable.id %>" name="controller_name" value="<%= @controller_name ||= controller.controller_name %>" /> | ||
</p> | ||
<%= generate_countdown_html("comment_content_for_#{commentable.id}", ArchiveConfig.COMMENT_MAX) %> | ||
<%= live_validation_for_field("comment_content_for_#{commentable.id}", | ||
:failureMessage => ts('Brevity is the soul of wit, but we need your comment to have text in it.'), | ||
:maximum_length => ArchiveConfig.COMMENT_MAX, | ||
:tooLongMessage => ts("must be less than %{count} characters long.", :count => ArchiveConfig.COMMENT_MAX)) %> | ||
<%= live_validation_for_field "comment_content_for_#{commentable.id}", | ||
failureMessage: t(".comment_too_short"), | ||
maximum_length: ArchiveConfig.COMMENT_MAX, | ||
tooLongMessage: t(".comment_too_long", count: ArchiveConfig.COMMENT_MAX) %> | ||
<p class="submit actions"> | ||
<%= f.submit button_name, :id => "comment_submit_for_#{commentable.id}", data: {disable_with: ts("Please wait...")} %> | ||
<% if controller.controller_name == 'inbox' %> | ||
<a name="comment_cancel" id="comment_cancel"><%= ts("Cancel") %></a> | ||
<% elsif comment.persisted? %> | ||
<%= cancel_edit_comment_link(comment) %> | ||
<% elsif commentable.is_a?(Comment) || commentable.is_a?(CommentDecorator) %> | ||
<%= cancel_comment_reply_link(commentable) %> | ||
<% end %> | ||
</p> | ||
<%= f.submit button_name, id: "comment_submit_for_#{commentable.id}", data: { disable_with: t(".processing_message") } %> | ||
<% if controller.controller_name == 'inbox' %> | ||
<a name="comment_cancel" id="comment_cancel"><%= t(".cancel_action") %></a> | ||
<% elsif comment.persisted? %> | ||
<%= cancel_edit_comment_link(comment) %> | ||
<% elsif commentable.is_a?(Comment) || commentable.is_a?(CommentDecorator) %> | ||
<%= cancel_comment_reply_link(commentable) %> | ||
<% end %> | ||
</p> | ||
</fieldset> | ||
<% end %> | ||
</div> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(In both spots) this translation key needs to be ".inbox_reference_html" so that the html of the links is not escaped. According to the i18n wiki page, the t function call should use parens
()
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be good to add it to Rubocop then? I'm not sure if there's an elegant way to force https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Style/MethodCallWithArgsParentheses for a single specific function.