Adjusts from review

This commit is contained in:
Rafael dos Santos Silva 2016-08-05 02:12:35 -03:00
parent acc70cc3de
commit 2a5a0bebb3
6 changed files with 12 additions and 12 deletions

View File

@ -134,9 +134,10 @@ const Topic = RestModel.extend({
return this.get('url') + (user ? '?u=' + user.get('username_lower') : '');
}.property('url'),
printUrl: function(){
return this.get('url') + '/print';
}.property('url'),
@computed('url')
printUrl(url) {
return url + '/print';
},
url: function() {
let slug = this.get('slug') || '';

View File

@ -7,7 +7,6 @@ export default ContainerView.extend({
@on('init')
createButtons() {
const mobileView = this.site.mobileView;
const { siteSettings } = this;
const topic = this.get('topic');
@ -33,7 +32,7 @@ export default ContainerView.extend({
this.attachViewClass('invite-reply-button');
}
if (!mobileView && siteSettings.allow_print_page) {
if (!mobileView && this.siteSettings.max_prints_per_hour_per_user > 0) {
this.attachViewClass('print-button');
}

View File

@ -70,9 +70,9 @@ class TopicsController < ApplicationController
end
if opts[:print]
raise Discourse::InvalidAccess unless SiteSetting.allow_print_page
raise Discourse::InvalidAccess unless SiteSetting.max_prints_per_hour_per_user > 0
begin
RateLimiter.new(current_user, "print-topic-per-hour", 10, 1.hour).performed! unless current_user.admin?
RateLimiter.new(current_user, "print-topic-per-hour", 10, 1.hour).performed! unless @guardian.is_admin?
rescue RateLimiter::LimitExceeded
render_json_error(I18n.t("rate_limiter.slow_down"))
end

View File

@ -1312,7 +1312,7 @@ en:
topic_page_title_includes_category: "Topic page title includes the category name."
allow_print_page: "Enable a special topic page for printing"
max_prints_per_hour_per_user: "Maximum number of /print page impressions (set to 0 to disable)"
full_name_required: "Full name is a required field of a user's profile."
enable_names: "Show the user's full name on their profile, user card, and emails. Disable to hide full name everywhere."

View File

@ -909,6 +909,9 @@ rate_limits:
client: true
shadowed_by_global: true
default: 0
max_prints_per_hour_per_user:
default: 0
client: true
developer:
force_hostname:
@ -1220,9 +1223,6 @@ uncategorized:
topic_page_title_includes_category: true
allow_print_page:
default: true
client: true
user_preferences:
default_email_digest_frequency:

View File

@ -51,7 +51,7 @@ class TopicView
@page = 1 if (!@page || @page.zero?)
@chunk_size = case
when options[:slow_platform] then TopicView.slow_chunk_size
when @print then 1000
when @print then TopicView.print_chunk_size
else TopicView.chunk_size
end
@limit ||= @chunk_size