mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Migrate tosAccepted
to new user fields
This commit is contained in:
parent
edb34c178a
commit
8b5a1cd20f
@ -14,7 +14,6 @@ export default DiscourseController.extend(ModalFunctionality, {
|
|||||||
rejectedEmails: Em.A([]),
|
rejectedEmails: Em.A([]),
|
||||||
rejectedPasswords: Em.A([]),
|
rejectedPasswords: Em.A([]),
|
||||||
prefilledUsername: null,
|
prefilledUsername: null,
|
||||||
tosAccepted: false,
|
|
||||||
userFields: null,
|
userFields: null,
|
||||||
|
|
||||||
hasAuthOptions: Em.computed.notEmpty('authOptions'),
|
hasAuthOptions: Em.computed.notEmpty('authOptions'),
|
||||||
@ -42,9 +41,6 @@ export default DiscourseController.extend(ModalFunctionality, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
submitDisabled: function() {
|
submitDisabled: function() {
|
||||||
// Even if password is required, we respect the tos setting
|
|
||||||
if (this.get('tosAcceptRequired') && !this.get('tosAccepted')) return true;
|
|
||||||
|
|
||||||
if (!this.get('passwordRequired')) return false; // 3rd party auth
|
if (!this.get('passwordRequired')) return false; // 3rd party auth
|
||||||
if (this.get('formSubmitted')) return true;
|
if (this.get('formSubmitted')) return true;
|
||||||
if (this.get('nameValidation.failed')) return true;
|
if (this.get('nameValidation.failed')) return true;
|
||||||
@ -62,7 +58,7 @@ export default DiscourseController.extend(ModalFunctionality, {
|
|||||||
if (anyEmpty) { return true; }
|
if (anyEmpty) { return true; }
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}.property('passwordRequired', 'nameValidation.failed', 'emailValidation.failed', 'usernameValidation.failed', 'passwordValidation.failed', 'formSubmitted', 'tosAccepted', 'userFields.@each.value'),
|
}.property('passwordRequired', 'nameValidation.failed', 'emailValidation.failed', 'usernameValidation.failed', 'passwordValidation.failed', 'formSubmitted', 'userFields.@each.value'),
|
||||||
|
|
||||||
passwordRequired: function() {
|
passwordRequired: function() {
|
||||||
return this.blank('authOptions.auth_provider');
|
return this.blank('authOptions.auth_provider');
|
||||||
@ -343,8 +339,6 @@ export default DiscourseController.extend(ModalFunctionality, {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
tosAcceptRequired: Discourse.computed.setting('tos_accept_required'),
|
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
externalLogin: function(provider) {
|
externalLogin: function(provider) {
|
||||||
this.get('controllers.login').send('externalLogin', provider);
|
this.get('controllers.login').send('externalLogin', provider);
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
<label>
|
<label>
|
||||||
{{input checked=value type="checkbox"}} {{field.name}}
|
{{input checked=value type="checkbox"}} {{{field.name}}}
|
||||||
</label>
|
</label>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<label>
|
<label>
|
||||||
{{field.name}}
|
{{{field.name}}}
|
||||||
{{input value=value}}
|
{{input value=value}}
|
||||||
</label>
|
</label>
|
||||||
|
@ -88,14 +88,6 @@
|
|||||||
|
|
||||||
{{#if showCreateForm}}
|
{{#if showCreateForm}}
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
{{#if tosAcceptRequired}}
|
|
||||||
<div class="tos-agree">
|
|
||||||
<label>
|
|
||||||
{{input type="checkbox" checked=tosAccepted}}
|
|
||||||
{{custom-html "tos_signup_form_message"}}
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
{{/if}}
|
|
||||||
<button class='btn btn-large btn-primary' {{bind-attr disabled="submitDisabled"}} {{action createAccount}}>{{i18n create_account.title}}</button>
|
<button class='btn btn-large btn-primary' {{bind-attr disabled="submitDisabled"}} {{action createAccount}}>{{i18n create_account.title}}</button>
|
||||||
{{#if formSubmitted}}
|
{{#if formSubmitted}}
|
||||||
<i class='fa fa-spinner fa-spin'></i>
|
<i class='fa fa-spinner fa-spin'></i>
|
||||||
|
@ -260,10 +260,6 @@ class ApplicationController < ActionController::Base
|
|||||||
bottom: SiteText.text_for(:bottom)
|
bottom: SiteText.text_for(:bottom)
|
||||||
}
|
}
|
||||||
|
|
||||||
if SiteSetting.tos_accept_required && !current_user
|
|
||||||
data[:tos_signup_form_message] = SiteText.text_for(:tos_signup_form_message)
|
|
||||||
end
|
|
||||||
|
|
||||||
if DiscoursePluginRegistry.custom_html
|
if DiscoursePluginRegistry.custom_html
|
||||||
data.merge! DiscoursePluginRegistry.custom_html
|
data.merge! DiscoursePluginRegistry.custom_html
|
||||||
end
|
end
|
||||||
|
@ -15,7 +15,6 @@ class SiteText < ActiveRecord::Base
|
|||||||
add_text_type :education_new_topic, default_18n_key: 'education.new-topic'
|
add_text_type :education_new_topic, default_18n_key: 'education.new-topic'
|
||||||
add_text_type :education_new_reply, default_18n_key: 'education.new-reply'
|
add_text_type :education_new_reply, default_18n_key: 'education.new-reply'
|
||||||
add_text_type :login_required_welcome_message, default_18n_key: 'login_required.welcome_message'
|
add_text_type :login_required_welcome_message, default_18n_key: 'login_required.welcome_message'
|
||||||
add_text_type :tos_signup_form_message, default_18n_key: 'terms_of_service.signup_form_message', format: :html
|
|
||||||
add_text_type :top, allow_blank: true, format: :html
|
add_text_type :top, allow_blank: true, format: :html
|
||||||
add_text_type :bottom, allow_blank: true, format: :html
|
add_text_type :bottom, allow_blank: true, format: :html
|
||||||
add_text_type :head, allow_blank: true, format: :html
|
add_text_type :head, allow_blank: true, format: :html
|
||||||
|
@ -626,9 +626,6 @@ en:
|
|||||||
bottom:
|
bottom:
|
||||||
title: "Bottom of the pages"
|
title: "Bottom of the pages"
|
||||||
description: "HTML that will be added at the bottom of every page."
|
description: "HTML that will be added at the bottom of every page."
|
||||||
tos_signup_form_message:
|
|
||||||
title: "Signup Form: Terms of Service Message"
|
|
||||||
description: "The message that will appear beside a checkbox on the signup form if the tos_accept_required site setting is enabled."
|
|
||||||
notification_email_top:
|
notification_email_top:
|
||||||
title: "Notification Email Top"
|
title: "Notification Email Top"
|
||||||
description: "A message that will be displayed at the top of all notification emails."
|
description: "A message that will be displayed at the top of all notification emails."
|
||||||
@ -998,7 +995,6 @@ en:
|
|||||||
embed_post_limit: "Maximum number of posts to embed."
|
embed_post_limit: "Maximum number of posts to embed."
|
||||||
embed_whitelist_selector: "CSS selector for elements that are allowed in embeds."
|
embed_whitelist_selector: "CSS selector for elements that are allowed in embeds."
|
||||||
embed_blacklist_selector: "CSS selector for elements that are removed from embeds."
|
embed_blacklist_selector: "CSS selector for elements that are removed from embeds."
|
||||||
tos_accept_required: "If enabled, users will need to check a box on the signup form to confirm that they accept the terms of service. Edit 'Signup Form: Terms of Service Message' in the Content tab to change the message."
|
|
||||||
notify_about_flags_after: "If there are flags that haven't been handled after this many hours, send an email to the contact_email. Set to 0 to disable."
|
notify_about_flags_after: "If there are flags that haven't been handled after this many hours, send an email to the contact_email. Set to 0 to disable."
|
||||||
enable_cdn_js_debugging: "Allow /logs to display proper errors by adding crossorigin permissions on all js includes."
|
enable_cdn_js_debugging: "Allow /logs to display proper errors by adding crossorigin permissions on all js includes."
|
||||||
show_create_topics_notice: "If the site has fewer than 5 public topics, show a notice asking admins to create some topics."
|
show_create_topics_notice: "If the site has fewer than 5 public topics, show a notice asking admins to create some topics."
|
||||||
|
@ -632,9 +632,6 @@ legal:
|
|||||||
privacy_policy_url:
|
privacy_policy_url:
|
||||||
client: true
|
client: true
|
||||||
default: ''
|
default: ''
|
||||||
tos_accept_required:
|
|
||||||
client: true
|
|
||||||
default: false
|
|
||||||
faq_url:
|
faq_url:
|
||||||
client: true
|
client: true
|
||||||
default: ''
|
default: ''
|
||||||
|
16
db/migrate/20140929204155_migrate_tos_setting.rb
Normal file
16
db/migrate/20140929204155_migrate_tos_setting.rb
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
class MigrateTosSetting < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
res = execute("SELECT * FROM site_settings WHERE name = 'tos_accept_required' AND value = 't'")
|
||||||
|
if res.present? && res[0].present?
|
||||||
|
label = I18n.t("terms_of_service.signup_form_message")
|
||||||
|
res = execute("SELECT value FROM site_texts WHERE text_type = 'tos_signup_form_message'")
|
||||||
|
if res.present? && res.cmd_tuples == 1
|
||||||
|
label = res[0]['value']
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
label = PG::Connection.escape_string(label)
|
||||||
|
execute("INSERT INTO user_fields (name, field_type, editable) VALUES ('#{label}', 'confirm', false)")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user