From cf37bef287d7dd5d2dce3e2276489767b8c0671f Mon Sep 17 00:00:00 2001 From: Bob Van Landuyt Date: Tue, 24 Apr 2018 11:37:41 +0200 Subject: [PATCH] Add `Term` model to keep track of terms That way we can link a users acceptance of terms directly to a terms record. --- app/models/application_setting/term.rb | 5 +++++ .../application_settings/_terms.html.haml | 22 +++++++++++++++++++ ...134533_create_application_setting_terms.rb | 13 +++++++++++ db/schema.rb | 6 +++++ 4 files changed, 46 insertions(+) create mode 100644 app/models/application_setting/term.rb create mode 100644 app/views/admin/application_settings/_terms.html.haml create mode 100644 db/migrate/20180424134533_create_application_setting_terms.rb diff --git a/app/models/application_setting/term.rb b/app/models/application_setting/term.rb new file mode 100644 index 00000000000..1f3d20e2b75 --- /dev/null +++ b/app/models/application_setting/term.rb @@ -0,0 +1,5 @@ +class ApplicationSetting + class Term < ActiveRecord::Base + validates :terms, presence: true + end +end diff --git a/app/views/admin/application_settings/_terms.html.haml b/app/views/admin/application_settings/_terms.html.haml new file mode 100644 index 00000000000..39a3fb147bd --- /dev/null +++ b/app/views/admin/application_settings/_terms.html.haml @@ -0,0 +1,22 @@ += form_for @application_setting, url: admin_application_settings_path, html: { class: 'form-horizontal fieldset-form' } do |f| + = form_errors(@application_setting) + + %fieldset + .form-group + .col-sm-12 + .checkbox + = f.label :enforce_terms do + = f.check_box :enforce_terms + = _("Require all users to accept Terms of Service when they access GitLab.") + .help-block + When enabled, users cannot use GitLab until the terms have been accepted. + .form-group + .col-sm-12 + = f.label :terms do + = _("Terms of Service Agreement") + .col-sm-12 + = f.text_area :terms, class: 'form-control', rows: 8 + .help-block + Markdown enabled + + = f.submit 'Save changes', class: "btn btn-success" diff --git a/db/migrate/20180424134533_create_application_setting_terms.rb b/db/migrate/20180424134533_create_application_setting_terms.rb new file mode 100644 index 00000000000..f29335cfc51 --- /dev/null +++ b/db/migrate/20180424134533_create_application_setting_terms.rb @@ -0,0 +1,13 @@ +class CreateApplicationSettingTerms < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + create_table :application_setting_terms do |t| + t.integer :cached_markdown_version + t.text :terms, null: false + t.text :terms_html + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 3d85ffbfee0..18c15dcd22f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -40,6 +40,12 @@ ActiveRecord::Schema.define(version: 20180503150427) do t.text "new_project_guidelines_html" end + create_table "application_setting_terms", force: :cascade do |t| + t.integer "cached_markdown_version" + t.text "terms", null: false + t.text "terms_html" + end + create_table "application_settings", force: :cascade do |t| t.integer "default_projects_limit" t.boolean "signup_enabled" -- GitLab