Support for custom Privacy Policies

This commit is contained in:
Robin Ward 2013-06-26 10:57:35 -04:00
parent 196a8f4ba5
commit 89f182899f
16 changed files with 50 additions and 11 deletions

View File

@ -9,8 +9,8 @@
Discourse.AdminSiteContentEditController = Discourse.Controller.extend({ Discourse.AdminSiteContentEditController = Discourse.Controller.extend({
saveDisabled: function() { saveDisabled: function() {
if (this.get('saving')) return true; if (this.get('saving')) { return true; }
if (this.blank('content.content')) return true; if ((!this.get('content.allow_blank')) && this.blank('content.content')) { return true; }
return false; return false;
}.property('saving', 'content.content'), }.property('saving', 'content.content'),

View File

@ -123,6 +123,7 @@
{{#titledLinkTo "list.latest" titleKey="filters.latest.help"}}{{i18n filters.latest.title}}{{/titledLinkTo}} {{#titledLinkTo "list.latest" titleKey="filters.latest.help"}}{{i18n filters.latest.title}}{{/titledLinkTo}}
</li> </li>
<li>{{#linkTo 'faq'}}{{i18n faq}}{{/linkTo}}</li> <li>{{#linkTo 'faq'}}{{i18n faq}}{{/linkTo}}</li>
{{#if categories}} {{#if categories}}
<li class='heading' title="{{i18n filters.categories.help}}"> <li class='heading' title="{{i18n filters.categories.help}}">
{{#linkTo "list.categories"}}{{i18n filters.categories.title}}{{/linkTo}} {{#linkTo "list.categories"}}{{i18n filters.categories.title}}{{/linkTo}}

View File

@ -7,8 +7,14 @@ class Admin::SiteContentsController < Admin::AdminController
def update def update
site_content = SiteContent.find_or_new(params[:id].to_s) site_content = SiteContent.find_or_new(params[:id].to_s)
# Updating to nothing is the same as removing it
if params[:content].present?
site_content.content = params[:content] site_content.content = params[:content]
site_content.save! site_content.save!
else
site_content.destroy
end
render nothing: true render nothing: true
end end

View File

@ -73,8 +73,12 @@ module ApplicationHelper
result result
end end
# Look up site content for a key. If the key is blank, you can supply a block and that
# will be rendered instead.
def markdown_content(key, replacements=nil) def markdown_content(key, replacements=nil)
PrettyText.cook(SiteContent.content_for(key, replacements || {})).html_safe result = PrettyText.cook(SiteContent.content_for(key, replacements || {})).html_safe
result = yield if result.blank? && block_given?
result
end end
def faq_path def faq_path

View File

@ -18,6 +18,7 @@ class SiteContent < ActiveRecord::Base
add_content_type :tos_user_content_license, default_18n_key: 'terms_of_service.user_content_license' add_content_type :tos_user_content_license, default_18n_key: 'terms_of_service.user_content_license'
add_content_type :tos_miscellaneous, default_18n_key: 'terms_of_service.miscellaneous' add_content_type :tos_miscellaneous, default_18n_key: 'terms_of_service.miscellaneous'
add_content_type :login_required_welcome_message, default_18n_key: 'login_required.welcome_message' add_content_type :login_required_welcome_message, default_18n_key: 'login_required.welcome_message'
add_content_type :privacy_policy, allow_blank: true
def site_content_type def site_content_type
@site_content_type ||= SiteContent.content_types.find {|t| t.content_type == content_type.to_sym} @site_content_type ||= SiteContent.content_types.find {|t| t.content_type == content_type.to_sym}

View File

@ -16,6 +16,10 @@ class SiteContentType
I18n.t("content_types.#{content_type}.description") I18n.t("content_types.#{content_type}.description")
end end
def allow_blank?
!!@opts[:allow_blank]
end
def default_content def default_content
if @opts[:default_18n_key].present? if @opts[:default_18n_key].present?
return I18n.t(@opts[:default_18n_key]) return I18n.t(@opts[:default_18n_key])

View File

@ -4,7 +4,8 @@ class SiteContentSerializer < ApplicationSerializer
:title, :title,
:description, :description,
:content, :content,
:format :format,
:allow_blank?
def title def title
object.site_content_type.title object.site_content_type.title
@ -22,4 +23,8 @@ class SiteContentSerializer < ApplicationSerializer
return object.content if object.content.present? return object.content if object.content.present?
object.site_content_type.default_content object.site_content_type.default_content
end end
def allow_blank?
object.site_content_type.allow_blank?
end
end end

View File

@ -5,6 +5,7 @@ class SiteSerializer < ApplicationSerializer
:post_types, :post_types,
:uncategorized_slug :uncategorized_slug
has_many :categories, serializer: BasicCategorySerializer, embed: :objects has_many :categories, serializer: BasicCategorySerializer, embed: :objects
has_many :post_action_types, embed: :objects has_many :post_action_types, embed: :objects
has_many :trust_levels, embed: :objects has_many :trust_levels, embed: :objects

View File

@ -4,6 +4,8 @@
<li><a class="active" href="<%=privacy_path%>">Ochrana soukromí</a></li> <li><a class="active" href="<%=privacy_path%>">Ochrana soukromí</a></li>
</ul> </ul>
<%= markdown_content(:privacy_policy) do %>
<div id="collect"></div> <div id="collect"></div>
<h2><a href="#collect">Jaké osobní informace sbíráme?</a></h2> <h2><a href="#collect">Jaké osobní informace sbíráme?</a></h2>
<p> <p>
@ -76,3 +78,5 @@
<p> <p>
Pokud se rozhodneme změnit naše podmínky ochrany soukromí, zašleme tyto změny na tuto stránku. Pokud se rozhodneme změnit naše podmínky ochrany soukromí, zašleme tyto změny na tuto stránku.
</p> </p>
<% end %>

View File

@ -4,6 +4,8 @@
<li><a class="active" href="<%=privacy_path%>">Privacy</a></li> <li><a class="active" href="<%=privacy_path%>">Privacy</a></li>
</ul> </ul>
<%= markdown_content(:privacy_policy) do %>
<div id="collect"></div> <div id="collect"></div>
<h2><a href="#collect">What information do we collect?</a></h2> <h2><a href="#collect">What information do we collect?</a></h2>
<p> <p>
@ -96,3 +98,5 @@ If we decide to change our privacy policy, we will post those changes on this pa
<p> <p>
This document is CC-BY-SA. It was last updated May 31, 2013. This document is CC-BY-SA. It was last updated May 31, 2013.
</p> </p>
<% end %>

View File

@ -4,6 +4,8 @@
<li><a class="active" href="<%=privacy_path%>">Конфиденциальность</a></li> <li><a class="active" href="<%=privacy_path%>">Конфиденциальность</a></li>
</ul> </ul>
<%= markdown_content(:privacy_policy) do %>
<div id="collect"></div> <div id="collect"></div>
<h2><a href="#collect">Какую информацию мы храним?</a></h2> <h2><a href="#collect">Какую информацию мы храним?</a></h2>
<p> <p>
@ -97,3 +99,5 @@
<p> <p>
Данный документ распространяется под лицензией CC-BY-SA. Дата последнего обновления - 31 мая 2013 года. Данный документ распространяется под лицензией CC-BY-SA. Дата последнего обновления - 31 мая 2013 года.
</p> </p>
<% end %>

View File

@ -4,6 +4,8 @@
<li><a class="active" href="/privacy">隐私条款</a></li> <li><a class="active" href="/privacy">隐私条款</a></li>
</ul> </ul>
<%= markdown_content(:privacy_policy) do %>
<div id="collect"></div> <div id="collect"></div>
<h2><a href="#collect">What information do we collect?</a></h2> <h2><a href="#collect">What information do we collect?</a></h2>
<p> <p>
@ -76,3 +78,5 @@ By using our site, you consent to our web site privacy policy.
<p> <p>
If we decide to change our privacy policy, we will post those changes on this page. If we decide to change our privacy policy, we will post those changes on this page.
</p> </p>
<% end %>

View File

@ -87,6 +87,7 @@ en:
show_more: "show more" show_more: "show more"
links: Links links: Links
faq: "FAQ" faq: "FAQ"
privacy_policy: "Privacy Policy"
you: "You" you: "You"
or: "or" or: "or"
now: "just now" now: "just now"

View File

@ -413,12 +413,13 @@ en:
welcome_invite: welcome_invite:
title: "Welcome: Invited User" title: "Welcome: Invited User"
description: "A private message automatically sent to all new invited users when they accept the invitation from another user to participate." description: "A private message automatically sent to all new invited users when they accept the invitation from another user to participate."
privacy_policy:
title: "Privacy Policy"
description: "Your site's privacy policy. Leave blank for default policy."
login_required_welcome_message: login_required_welcome_message:
title: "Login Required: Welcome Message" title: "Login Required: Welcome Message"
description: "Welcome message that is displayed to logged out users when description: "Welcome message that is displayed to logged out users when
the 'login required' setting is enabled." the 'login required' setting is enabled."
tos_user_content_license: tos_user_content_license:
title: "Terms of Service: Content License" title: "Terms of Service: Content License"
description: "The text for the Content License section of the Terms of Service." description: "The text for the Content License section of the Terms of Service."

View File

@ -20,7 +20,6 @@ module SiteContentClassMethods
replacements = {site_name: SiteSetting.title}.merge!(replacements) replacements = {site_name: SiteSetting.title}.merge!(replacements)
replacements = SiteSetting.settings_hash.merge!(replacements) replacements = SiteSetting.settings_hash.merge!(replacements)
site_content = SiteContent.select(:content).where(content_type: content_type).first site_content = SiteContent.select(:content).where(content_type: content_type).first
result = "" result = ""