Migrate tosAccepted to new user fields

This commit is contained in:
Robin Ward 2014-09-29 16:59:03 -04:00
parent edb34c178a
commit 8b5a1cd20f
9 changed files with 19 additions and 29 deletions

View file

@ -14,7 +14,6 @@ export default DiscourseController.extend(ModalFunctionality, {
rejectedEmails: Em.A([]),
rejectedPasswords: Em.A([]),
prefilledUsername: null,
tosAccepted: false,
userFields: null,
hasAuthOptions: Em.computed.notEmpty('authOptions'),
@ -42,9 +41,6 @@ export default DiscourseController.extend(ModalFunctionality, {
},
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('formSubmitted')) return true;
if (this.get('nameValidation.failed')) return true;
@ -62,7 +58,7 @@ export default DiscourseController.extend(ModalFunctionality, {
if (anyEmpty) { return true; }
}
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() {
return this.blank('authOptions.auth_provider');
@ -343,8 +339,6 @@ export default DiscourseController.extend(ModalFunctionality, {
});
},
tosAcceptRequired: Discourse.computed.setting('tos_accept_required'),
actions: {
externalLogin: function(provider) {
this.get('controllers.login').send('externalLogin', provider);

View file

@ -1,3 +1,3 @@
<label>
{{input checked=value type="checkbox"}} {{field.name}}
{{input checked=value type="checkbox"}} {{{field.name}}}
</label>

View file

@ -1,4 +1,4 @@
<label>
{{field.name}}
{{{field.name}}}
{{input value=value}}
</label>

View file

@ -88,14 +88,6 @@
{{#if showCreateForm}}
<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>
{{#if formSubmitted}}
&nbsp; <i class='fa fa-spinner fa-spin'></i>

View file

@ -260,10 +260,6 @@ class ApplicationController < ActionController::Base
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
data.merge! DiscoursePluginRegistry.custom_html
end

View file

@ -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_reply, default_18n_key: 'education.new-reply'
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 :bottom, allow_blank: true, format: :html
add_text_type :head, allow_blank: true, format: :html

View file

@ -626,9 +626,6 @@ en:
bottom:
title: "Bottom of the pages"
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:
title: "Notification Email Top"
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_whitelist_selector: "CSS selector for elements that are allowed in 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."
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."

View file

@ -632,9 +632,6 @@ legal:
privacy_policy_url:
client: true
default: ''
tos_accept_required:
client: true
default: false
faq_url:
client: true
default: ''

View 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