Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow staying logged in for longer #4236

Merged
merged 5 commits into from
Jun 22, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion readthedocs/profiles/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,12 @@ def account_advertising(request):
except ObjectDoesNotExist:
return HttpResponseRedirect(reverse('profiles_profile_create'))

if request.method == 'POST':
if request.method == 'POST' and request.POST.get('stay-logged-in') == 'yes':
# Set the expiry for 3 months (3 * 31 days)
request.session.set_expiry(60 * 60 * 24 * 31 * 3)
messages.info(request, _('Successfully extended your login session'))
form = UserAdvertisingForm(instance=profile_obj)
elif request.method == 'POST':
form = UserAdvertisingForm(
data=request.POST,
instance=profile_obj,
Expand All @@ -310,5 +315,6 @@ def account_advertising(request):
'form': form,
'profile': profile_obj,
'user': profile_obj.user,
'session_expiry': request.session.get_expiry_date(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this isn't used with the recent changes

},
)
54 changes: 31 additions & 23 deletions readthedocs/templates/profiles/private/advertising_profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,51 @@
{% block edit_content_header %} {% trans "Set advertising preferences" %} {% endblock %}

{% block edit_content %}
<p>
{% 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 %}
</p>

<p>
{% 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 <a href="https://docs.readthedocs.io/en/latest/ethical-advertising.html">our documentation</a>.
{% endblocktrans %}
</p>

{% if request.user.gold.exists or request.user.goldonce.exists %}
<p>
{% blocktrans %}
<strong>Note:</strong>
Since you are a Gold Member or donor, you <strong>will not</strong> see advertising as long as you are logged-in.
Thank you for supporting Read the Docs.
{% endblocktrans%}
</p>

<p>{% blocktrans with expiry=session_expiry|timeuntil %}Your login session will expire in {{ expiry }}.{% endblocktrans %}</p>

<form method="POST" action=".">
{% csrf_token %}
<input type="hidden" name="stay-logged-in" value="yes">
<input type="submit" name="submit" value="{% trans "Stay logged in for 3 months" %}" id="submit"/>
</form>
{% else %}
<p>
{% 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 %}
</p>

<p>
{% 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 <a href="https://docs.readthedocs.io/en/latest/ethical-advertising.html">our documentation</a>.
{% endblocktrans %}
</p>

<p>
{% url "gold_detail" as gold_detail %}
{% blocktrans %}
You may remove ads completely by becoming a <a href="{{ gold_detail }}">Gold member to Read the Docs</a>.
{% endblocktrans %}
</p>
{% endif %}

<form method="POST" action=".">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" name="submit" value="{% trans "Update advertisement preference" %}" id="submit"/>
</form>
<form method="POST" action=".">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" name="submit" value="{% trans "Update advertisement preference" %}" id="submit"/>
</form>
{% endif %}
{% endblock %}