Skip to content

Commit

Permalink
Add internal policy views
Browse files Browse the repository at this point in the history
- Pull latest policy versions on build
  • Loading branch information
mfraezz committed Jan 6, 2025
1 parent bf3c7d8 commit 3bf4fc1
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ RUN set -ex \
libffi-dev

WORKDIR /code

# Policies
ADD https://github.com/CenterForOpenScience/cos.io.git#master ./COS_POLICIES/

COPY pyproject.toml .
COPY poetry.lock .
# Fix: https://github.com/CenterForOpenScience/osf.io/pull/6783
Expand Down
19 changes: 19 additions & 0 deletions website/policies/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import markdown

from website.settings import \
PRIVACY_POLICY_PATH, PRIVACY_POLICY_GITHUB_LINK, \
TERMS_POLICY_PATH, TERMS_POLICY_GITHUB_LINK

def privacy_policy():
with open(PRIVACY_POLICY_PATH, 'r') as policy_file:
return {
'policy_content': markdown.markdown(policy_file.read(), extensions=['toc']),
'POLICY_GITHUB_LINK': PRIVACY_POLICY_GITHUB_LINK
}

def terms_policy():
with open(TERMS_POLICY_PATH, 'r') as policy_file:
return {
'policy_content': markdown.markdown(policy_file.read(), extensions=['toc']),
'POLICY_GITHUB_LINK': TERMS_POLICY_GITHUB_LINK
}
13 changes: 13 additions & 0 deletions website/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
from addons.base import views as addon_views
from website.discovery import views as discovery_views
from website.conferences import views as conference_views
from website.policies import views as policy_views
from website.preprints import views as preprint_views
from website.registries import views as registries_views
from website.reviews import views as reviews_views
Expand Down Expand Up @@ -1145,6 +1146,18 @@ def make_url_map(app):

Rule('/goodbye/', 'get', goodbye, notemplate),

Rule(
'/privacy_policy/',
'get',
policy_views.privacy_policy,
OsfWebRenderer('policies/generic_policy.mako', trust=True)
),
Rule(
'/terms_of_use/',
'get',
policy_views.terms_policy,
OsfWebRenderer('policies/generic_policy.mako', trust=True)
),
Rule(
[
'/project/<pid>/',
Expand Down
11 changes: 8 additions & 3 deletions website/settings/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def parent_dir(path):
STATIC_FOLDER = os.path.join(BASE_PATH, 'static')
STATIC_URL_PATH = '/static'
ASSET_HASH_PATH = os.path.join(APP_PATH, 'webpack-assets.json')
POLICY_PATH = os.path.join(APP_PATH, 'COS_POLICIES')
PRIVACY_POLICY_PATH = os.path.join(POLICY_PATH, 'PRIVACY_POLICY.md')
TERMS_POLICY_PATH = os.path.join(POLICY_PATH, 'TERMS_OF_USE.md')
ROOT = os.path.join(BASE_PATH, '..')
BCRYPT_LOG_ROUNDS = 12
LOG_LEVEL = logging.INFO
Expand Down Expand Up @@ -2048,10 +2051,12 @@ class CeleryConfig:
OSF_REGISTRIES_LOGO = 'osf_registries'
OSF_LOGO_LIST = [OSF_LOGO, OSF_PREPRINTS_LOGO, OSF_MEETINGS_LOGO, OSF_PREREG_LOGO, OSF_REGISTRIES_LOGO]

PRIVACY_POLICY_GITHUB_LINK = 'https://github.com/CenterForOpenScience/centerforopenscience.org/blob/master/PRIVACY_POLICY.md'
TERMS_POLICY_GITHUB_LINK = 'https://github.com/CenterForOpenScience/centerforopenscience.org/blob/master/TERMS_OF_USE.md'
FOOTER_LINKS = {
'terms': 'https://github.com/CenterForOpenScience/centerforopenscience.org/blob/master/TERMS_OF_USE.md',
'privacyPolicy': 'https://github.com/CenterForOpenScience/centerforopenscience.org/blob/master/PRIVACY_POLICY.md',
'cookies': 'https://github.com/CenterForOpenScience/centerforopenscience.org/blob/master/PRIVACY_POLICY.md#f-cookies',
'terms': 'https://osf.io/terms_of_use/',
'privacyPolicy': 'https://osf.io/privacy_policy/',
'cookies': 'https://osf.io/privacy_policy/#f-cookies',
'cos': 'https://cos.io',
'statusPage': 'https://status.cos.io/',
'apiDocs': 'https://developer.osf.io/',
Expand Down
16 changes: 16 additions & 0 deletions website/templates/policies/generic_policy.mako
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<%inherit file="base.mako"/>

<%def name="content()">
<div id="policy" class="container">
<div class="row">
<div class="col-md-12">
<br>
${policy_content}
</div>
<div class="col-md-12">
<br>
Version history for this policy is available <a href='${POLICY_GITHUB_LINK}'>here</a>
</div>
</div>
</div><!-- end container policy -->
</%def>

0 comments on commit 3bf4fc1

Please sign in to comment.