diff --git a/docs/ethical-advertising.rst b/docs/ethical-advertising.rst index 1de603cdcff..f4c6dd7a095 100644 --- a/docs/ethical-advertising.rst +++ b/docs/ethical-advertising.rst @@ -135,6 +135,9 @@ Opting Out We have added multiple ways to opt out of the advertising on Read the Docs. +Users can go ad-free for as long as they are logged-in +by becoming a `Gold Member of Read the Docs `_. + Users can opt out of seeing paid advertisements on documentation pages: * Go to the drop down user menu in the top right of the Read the Docs dashboard and clicking **Settings** (https://readthedocs.org/accounts/edit/). diff --git a/docs/support.rst b/docs/support.rst index f32fa8e29e6..43c3c442a74 100644 --- a/docs/support.rst +++ b/docs/support.rst @@ -17,10 +17,9 @@ Good questions for Stack Overflow would be: Community Support ----------------- -Read the Docs is a community supported site, -nobody is paid to handle readthedocs.org support. -We are hoping to bring in enough money with our `Gold`_ program to change that, -so please sign up if you are able. +Read the Docs is supported by community contributions and advertising. +We hope to bring in enough money +with our `Gold`_ and `Ethical Ads`_ programs to keep Read the Docs sustainable. **All people answering your questions are doing it with their own time, so please be kind and provide as much information as possible.** @@ -58,5 +57,5 @@ or read more at https://readthedocs.com/services/#open-source-support. .. _Stack Overflow: http://stackoverflow.com/questions/tagged/read-the-docs .. _Github Issue Tracker: https://github.com/rtfd/readthedocs.org/issues -.. _sign up: https://readthedocs.org/accounts/gold/ .. _Gold: https://readthedocs.org/accounts/gold/ +.. _Ethical Ads: https://docs.readthedocs.io/en/latest/ethical-advertising.html diff --git a/readthedocs/core/context_processors.py b/readthedocs/core/context_processors.py index 53e945f7693..bfeb8a27f4f 100644 --- a/readthedocs/core/context_processors.py +++ b/readthedocs/core/context_processors.py @@ -14,5 +14,6 @@ def readthedocs_processor(request): 'DASHBOARD_ANALYTICS_CODE': getattr(settings, 'DASHBOARD_ANALYTICS_CODE'), 'SITE_ROOT': getattr(settings, 'SITE_ROOT', '') + '/', 'TEMPLATE_ROOT': getattr(settings, 'TEMPLATE_ROOT', '') + '/', + 'USE_PROMOS': getattr(settings, 'USE_PROMOS', False), } return exports diff --git a/readthedocs/core/forms.py b/readthedocs/core/forms.py index a5d9e920cfa..6899afa1295 100644 --- a/readthedocs/core/forms.py +++ b/readthedocs/core/forms.py @@ -8,7 +8,6 @@ from builtins import object from django import forms -from django.conf import settings from django.contrib.auth.models import User from django.forms.fields import CharField from django.utils.translation import ugettext_lazy as _ @@ -26,8 +25,6 @@ class Meta(object): model = UserProfile # Don't allow users edit someone else's user page fields = ['first_name', 'last_name', 'homepage'] - if settings.USE_PROMOS: - fields.append('allow_ads') def __init__(self, *args, **kwargs): super(UserProfileForm, self).__init__(*args, **kwargs) @@ -68,6 +65,12 @@ def clean_username(self): return data +class UserAdvertisingForm(forms.ModelForm): + class Meta(object): + model = UserProfile + fields = ['allow_ads'] + + class FacetField(forms.MultipleChoiceField): """ diff --git a/readthedocs/gold/templates/gold/subscription_form.html b/readthedocs/gold/templates/gold/subscription_form.html index 566317e9166..188ac56e01a 100644 --- a/readthedocs/gold/templates/gold/subscription_form.html +++ b/readthedocs/gold/templates/gold/subscription_form.html @@ -59,6 +59,9 @@

Read the Docs Gold

we suggest giving at least $20/month to help cover our support and operations costs. {% endblocktrans %}

+ +

{% trans 'Becoming a Gold Member also makes Read the Docs ad-free for as long as you are logged-in.' %}

+

{% blocktrans %} You can also make one-time donations on our sustainability page. diff --git a/readthedocs/profiles/urls/private.py b/readthedocs/profiles/urls/private.py index cdebde0a75c..a545789aa6e 100644 --- a/readthedocs/profiles/urls/private.py +++ b/readthedocs/profiles/urls/private.py @@ -18,5 +18,6 @@ 'template_name': 'profiles/private/edit_profile.html', }, name='profiles_profile_edit'), - url(r'^delete/', views.delete_account, name='delete_account') + url(r'^delete/', views.delete_account, name='delete_account'), + url(r'^advertising/$', views.account_advertising, name='account_advertising'), ] diff --git a/readthedocs/profiles/views.py b/readthedocs/profiles/views.py index 09abd1579fb..99dd99bb033 100644 --- a/readthedocs/profiles/views.py +++ b/readthedocs/profiles/views.py @@ -13,8 +13,9 @@ from django.http import Http404, HttpResponseRedirect from django.shortcuts import get_object_or_404, redirect, render from django.template.context import RequestContext +from django.utils.translation import ugettext_lazy as _ -from readthedocs.core.forms import UserDeleteForm +from readthedocs.core.forms import UserDeleteForm, UserAdvertisingForm def create_profile( @@ -279,3 +280,35 @@ def profile_detail( context.update({'profile': profile_obj}) return render(request, template_name, context=context) + + +@login_required +def account_advertising(request): + success_url = reverse(account_advertising) + + try: + profile_obj = request.user.profile + except ObjectDoesNotExist: + return HttpResponseRedirect(reverse('profiles_profile_create')) + + if request.method == 'POST': + form = UserAdvertisingForm( + data=request.POST, + instance=profile_obj, + ) + if form.is_valid(): + form.save() + messages.info(request, _('Updated your advertising preferences')) + return HttpResponseRedirect(success_url) + else: + form = UserAdvertisingForm(instance=profile_obj) + + return render( + request, + 'profiles/private/advertising_profile.html', + context={ + 'form': form, + 'profile': profile_obj, + 'user': profile_obj.user, + }, + ) diff --git a/readthedocs/templates/profiles/base_profile_edit.html b/readthedocs/templates/profiles/base_profile_edit.html index ef9a916e8b2..9611f62fcbe 100644 --- a/readthedocs/templates/profiles/base_profile_edit.html +++ b/readthedocs/templates/profiles/base_profile_edit.html @@ -51,6 +51,9 @@

  • {% trans "Change Email" %}
  • {% trans "Gold" %}
  • + {% if USE_PROMOS %} +
  • {% trans "Advertising" %}
  • + {% endif %} {% endblock %}
    diff --git a/readthedocs/templates/profiles/private/advertising_profile.html b/readthedocs/templates/profiles/private/advertising_profile.html new file mode 100644 index 00000000000..1529a6a0f85 --- /dev/null +++ b/readthedocs/templates/profiles/private/advertising_profile.html @@ -0,0 +1,51 @@ +{% extends "profiles/base_profile_edit.html" %} + +{% load i18n %} + +{% block title %}{% trans "Set advertising preferences" %}{% endblock %} + +{% block profile-admin-advertising %}active{% endblock %} + +{% block edit_content_header %} {% trans "Set advertising preferences" %} {% endblock %} + +{% block edit_content %} +

    + {% blocktrans %} + Read the Docs is an open source project. + In order to maintain service, we rely on both the + support of our users, and from sponsor support. + {% endblocktrans %} +

    + +

    + {% blocktrans %} + For more details on advertising on Read the Docs + including the privacy protections we have in place for users + and community advertising we run on behalf of the open source community, + see our documentation. + {% endblocktrans %} +

    + + {% if request.user.gold.exists or request.user.goldonce.exists %} +

    + {% blocktrans %} + Note: + Since you are a Gold Member or donor, you will not see advertising as long as you are logged-in. + Thank you for supporting Read the Docs. + {% endblocktrans%} +

    + {% else %} +

    + {% url "gold_detail" as gold_detail %} + {% blocktrans %} + You may remove ads completely by becoming a Gold member to Read the Docs. + {% endblocktrans %} +

    + {% endif %} + +
    + {% csrf_token %} + {{ form.as_p }} + +
    +{% endblock %} diff --git a/readthedocs/templates/projects/project_advertising.html b/readthedocs/templates/projects/project_advertising.html index c18ce73d0b8..51b24653f6d 100644 --- a/readthedocs/templates/projects/project_advertising.html +++ b/readthedocs/templates/projects/project_advertising.html @@ -14,8 +14,8 @@ {% block project_edit_content %}

    {% blocktrans %} - Read the Docs is an open source project, maintained and operated by - full-time volunteers. In order to maintain service, we rely on both the + Read the Docs is an open source project. + In order to maintain service, we rely on both the support of our users, and from sponsor support. {% endblocktrans %}

    @@ -48,9 +48,10 @@

    {% blocktrans %} - For more information on our stance on sponsor advertisements, we wrote - more about our stance - on our blog. + For more details on advertising on Read the Docs + including the privacy protections we have in place for users + and community advertising we run on behalf of the open source community, + see our documentation. {% endblocktrans %}

    diff --git a/readthedocs/templates/projects/project_edit_base.html b/readthedocs/templates/projects/project_edit_base.html index bb94c50f44b..cc85e88834a 100644 --- a/readthedocs/templates/projects/project_edit_base.html +++ b/readthedocs/templates/projects/project_edit_base.html @@ -24,7 +24,9 @@
  • {% trans "Subprojects" %}
  • {% trans "Integrations" %}
  • {% trans "Notifications" %}
  • -
  • {% trans "Advertising" %}
  • + {% if USE_PROMOS %} +
  • {% trans "Advertising" %}
  • + {% endif %}

    {% block project_edit_content_header %}{% endblock %}

    diff --git a/readthedocs/templates/support.html b/readthedocs/templates/support.html index 4a7682b734a..720e6f7d159 100644 --- a/readthedocs/templates/support.html +++ b/readthedocs/templates/support.html @@ -26,10 +26,9 @@ Community Support ----------------- -Read the Docs is a community supported site, -nobody is paid to handle readthedocs.org support. -We are hoping to bring in enough money with our `Gold`_ program to change that, -so please sign up if you are able. +Read the Docs is supported by community contributions and advertising. +We hope to bring in enough money +with our `Gold`_ and `Ethical Ads`_ programs to keep Read the Docs sustainable. **All people answering your questions are doing it with their own time, so please be kind and provide as much information as possible.** @@ -67,8 +66,8 @@ .. _Stack Overflow: http://stackoverflow.com/questions/tagged/read-the-docs .. _Github Issue Tracker: https://github.com/rtfd/readthedocs.org/issues -.. _sign up: https://readthedocs.org/accounts/gold/ .. _Gold: https://readthedocs.org/accounts/gold/ +.. _Ethical Ads: https://docs.readthedocs.io/en/latest/ethical-advertising.html {% endfilter %}