Display terms to a user
When terms are present, they can be viewed on `/-/users/terms`.
This commit is contained in:
parent
17b25bd263
commit
3629dc338f
8 changed files with 135 additions and 0 deletions
|
@ -61,3 +61,4 @@
|
|||
@import 'framework/stacked_progress_bar';
|
||||
@import 'framework/ci_variable_list';
|
||||
@import 'framework/feature_highlight';
|
||||
@import 'framework/terms';
|
||||
|
|
37
app/assets/stylesheets/framework/terms.scss
Normal file
37
app/assets/stylesheets/framework/terms.scss
Normal file
|
@ -0,0 +1,37 @@
|
|||
.terms {
|
||||
.panel {
|
||||
.panel-heading {
|
||||
display: -webkit-flex;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
.title {
|
||||
display: -webkit-flex;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 2px 8px;
|
||||
margin: 5px 2px 5px -8px;
|
||||
border-radius: 4px;
|
||||
|
||||
.logo-text {
|
||||
width: 55px;
|
||||
height: 24px;
|
||||
margin: 0 15px;
|
||||
}
|
||||
}
|
||||
|
||||
.navbar-collapse {
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
.nav li a {
|
||||
color: $theme-gray-700;
|
||||
}
|
||||
}
|
||||
|
||||
.panel-content {
|
||||
padding: 0 $gl-padding;
|
||||
}
|
||||
}
|
||||
}
|
19
app/controllers/users/terms_controller.rb
Normal file
19
app/controllers/users/terms_controller.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
module Users
|
||||
class TermsController < ApplicationController
|
||||
before_action :terms
|
||||
|
||||
|
||||
layout 'terms'
|
||||
|
||||
def index
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def terms
|
||||
unless @terms = Gitlab::CurrentSettings.current_application_settings.latest_terms
|
||||
redirect_to request.referer || root_path
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
30
app/views/layouts/terms.html.haml
Normal file
30
app/views/layouts/terms.html.haml
Normal file
|
@ -0,0 +1,30 @@
|
|||
!!! 5
|
||||
- @hide_breadcrumbs = true
|
||||
%html{ lang: I18n.locale, class: page_class }
|
||||
= render "layouts/head"
|
||||
|
||||
%body{ class: "#{user_application_theme} #{@body_class}", data: { page: body_data_page } }
|
||||
= render 'peek/bar'
|
||||
.layout-page.terms
|
||||
.content-wrapper
|
||||
%div{ class: "#{(container_class unless @no_container)} #{@content_class}" }
|
||||
.content{ id: "content-body" }
|
||||
.panel.panel-default
|
||||
.panel-heading
|
||||
.title
|
||||
= brand_header_logo
|
||||
- logo_text = brand_header_logo_type
|
||||
- if logo_text.present?
|
||||
%span.logo-text.hidden-xs
|
||||
= logo_text
|
||||
- if header_link?(:user_dropdown)
|
||||
.navbar-collapse.collapse
|
||||
%ul.nav.navbar-nav
|
||||
%li.header-user.dropdown
|
||||
= link_to current_user, class: user_dropdown_class, data: { toggle: "dropdown" } do
|
||||
= image_tag avatar_icon_for_user(current_user, 23), width: 23, height: 23, class: "header-user-avatar qa-user-avatar"
|
||||
= sprite_icon('angle-down', css_class: 'caret-down')
|
||||
.dropdown-menu-nav.dropdown-menu-align-right
|
||||
= render 'layouts/header/current_user_dropdown'
|
||||
= yield
|
||||
= yield :scripts_body
|
2
app/views/users/terms/index.html.haml
Normal file
2
app/views/users/terms/index.html.haml
Normal file
|
@ -0,0 +1,2 @@
|
|||
.panel-content.rendered-terms
|
||||
= markdown_field(@terms, :terms)
|
|
@ -27,6 +27,13 @@ devise_scope :user do
|
|||
get '/users/almost_there' => 'confirmations#almost_there'
|
||||
end
|
||||
|
||||
scope '-/users', module: :users do
|
||||
resources :terms, only: [:index] do
|
||||
post :accept, on: :member
|
||||
post :decline, on: :member
|
||||
end
|
||||
end
|
||||
|
||||
scope(constraints: { username: Gitlab::PathRegex.root_namespace_route_regex }) do
|
||||
scope(path: 'users/:username',
|
||||
as: :user,
|
||||
|
|
23
spec/controllers/users/terms_controller_spec.rb
Normal file
23
spec/controllers/users/terms_controller_spec.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Users::TermsController do
|
||||
let(:user) { create(:user) }
|
||||
|
||||
before do
|
||||
sign_in user
|
||||
end
|
||||
|
||||
describe 'GET #index' do
|
||||
it 'redirects when no terms exist' do
|
||||
get :index
|
||||
|
||||
expect(response).to have_gitlab_http_status(:redirect)
|
||||
end
|
||||
|
||||
it 'shows terms when they exist' do
|
||||
create(:term)
|
||||
|
||||
expect(response).to have_gitlab_http_status(:success)
|
||||
end
|
||||
end
|
||||
end
|
16
spec/features/users/terms_spec.rb
Normal file
16
spec/features/users/terms_spec.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'Users > Terms' do
|
||||
let(:user) { create(:user) }
|
||||
let!(:term) { create(:term, terms: 'By accepting, you promise to be nice!') }
|
||||
|
||||
before do
|
||||
sign_in(user)
|
||||
|
||||
visit terms_path
|
||||
end
|
||||
|
||||
it 'shows the terms' do
|
||||
expect(page).to have_content('By accepting, you promise to be nice!')
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue