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({
saveDisabled: function() {
if (this.get('saving')) return true;
if (this.blank('content.content')) return true;
if (this.get('saving')) { return true; }
if ((!this.get('content.allow_blank')) && this.blank('content.content')) { return true; }
return false;
}.property('saving', 'content.content'),

View file

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

View file

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

View file

@ -73,8 +73,12 @@ module ApplicationHelper
result
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)
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
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_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 :privacy_policy, allow_blank: true
def site_content_type
@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")
end
def allow_blank?
!!@opts[:allow_blank]
end
def default_content
if @opts[:default_18n_key].present?
return I18n.t(@opts[:default_18n_key])

View file

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

View file

@ -5,6 +5,7 @@ class SiteSerializer < ApplicationSerializer
:post_types,
:uncategorized_slug
has_many :categories, serializer: BasicCategorySerializer, embed: :objects
has_many :post_action_types, 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>
</ul>
<%= markdown_content(:privacy_policy) do %>
<div id="collect"></div>
<h2><a href="#collect">Jaké osobní informace sbíráme?</a></h2>
<p>
@ -76,3 +78,5 @@
<p>
Pokud se rozhodneme změnit naše podmínky ochrany soukromí, zašleme tyto změny na tuto stránku.
</p>
<% end %>

View file

@ -4,6 +4,8 @@
<li><a class="active" href="<%=privacy_path%>">Privacy</a></li>
</ul>
<%= markdown_content(:privacy_policy) do %>
<div id="collect"></div>
<h2><a href="#collect">What information do we collect?</a></h2>
<p>
@ -95,4 +97,6 @@ If we decide to change our privacy policy, we will post those changes on this pa
<p>
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>
</ul>
<%= markdown_content(:privacy_policy) do %>
<div id="collect"></div>
<h2><a href="#collect">Какую информацию мы храним?</a></h2>
<p>
@ -96,4 +98,6 @@
<p>
Данный документ распространяется под лицензией CC-BY-SA. Дата последнего обновления - 31 мая 2013 года.
</p>
</p>
<% end %>

View file

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

View file

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

View file

@ -413,12 +413,13 @@ en:
welcome_invite:
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."
privacy_policy:
title: "Privacy Policy"
description: "Your site's privacy policy. Leave blank for default policy."
login_required_welcome_message:
title: "Login Required: Welcome Message"
description: "Welcome message that is displayed to logged out users when
the 'login required' setting is enabled."
tos_user_content_license:
title: "Terms of Service: Content License"
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 = SiteSetting.settings_hash.merge!(replacements)
site_content = SiteContent.select(:content).where(content_type: content_type).first
result = ""