terms of use/privacy policy endpoints and extension point

this commit adds terms_of_use_url and privacy_policy_url helpers
that can be customized by plugins.  it also provides controller
actions to redirect to these, so that custom URLs can be
computed on demand instead of on every page load

closes CNVS-17882

test plan:
 - without any authentication, /terms_of_use and /privacy_policy
   should redirect to the default documents on canvaslms.com
   (custom documents based on geographic location and account
   license type will come later.)

Change-Id: I72654168d244b5196f841e1a159c14c4c4b29cb3
Reviewed-on: https://gerrit.instructure.com/47331
Reviewed-by: James Williams  <jamesw@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: Jahnavi Yetukuri <jyetukuri@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
This commit is contained in:
Jeremy Stanley 2015-01-16 11:25:53 -07:00
parent f6399e749e
commit d9916a9543
5 changed files with 100 additions and 0 deletions

View File

@ -33,6 +33,7 @@ class ApplicationController < ActionController::Base
include Api::V1::User
include Api::V1::WikiPage
include Lti::MessageHelper
include LegalInformationHelper
around_filter :set_locale
helper :all

View File

@ -0,0 +1,27 @@
#
# Copyright (C) 2015 Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
class LegalInformationController < ApplicationController
def terms_of_use
redirect_to terms_of_use_url
end
def privacy_policy
redirect_to privacy_policy_url
end
end

View File

@ -0,0 +1,33 @@
#
# Copyright (C) 2015 Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
module LegalInformationHelper
def terms_of_use_url
Setting.get('terms_of_use_url', 'http://www.canvaslms.com/policies/terms-of-use')
end
def privacy_policy_url
Setting.get('privacy_policy_url', 'http://www.canvaslms.com/policies/privacy-policy')
end
protected
# extension point
def legal_information
{}
end
end

View File

@ -757,6 +757,9 @@ CanvasRails::Application.routes.draw do
get 'courses/:course_id/outcome_rollups' => 'outcome_results#rollups', as: 'course_outcome_rollups'
get 'terms_of_use' => 'legal_information#terms_of_use', as: 'terms_of_use_redirect'
get 'privacy_policy' => 'legal_information#privacy_policy', as: 'privacy_policy_redirect'
### API routes ###
# TODO: api routes can't yet take advantage of concerns for DRYness, because of

View File

@ -0,0 +1,36 @@
#
# Copyright (C) 2015 Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe LegalInformationController do
describe "GET 'terms_of_use'" do
it "should redirect to terms_of_use_url, no authorization required" do
get 'terms_of_use'
expect(response).to redirect_to controller.terms_of_use_url
end
end
describe "GET 'privacy_policy'" do
it "should redirect to privacy_policy_url, no authorization required" do
get 'privacy_policy'
expect(response).to redirect_to controller.privacy_policy_url
end
end
end