Skip to content

Commit

Permalink
Merge pull request #963 from WesternFriend/superuser-edit-subscriptio…
Browse files Browse the repository at this point in the history
…n-page

Always allow superuser to edit subscribe page
  • Loading branch information
brylie authored Nov 28, 2023
2 parents ee0acbb + 4b8ce98 commit 31d6f28
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions subscription/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,12 @@ def serve(
) -> HttpResponse:
# Redirect to the Manage Subscription page
# if the user is logged in and has a subscription.
# Superusers should not be redirected.
if (
hasattr(request, "user")
and request.user.is_authenticated
and request.user.is_subscriber
and not request.user.is_superuser
):
# redirect to manage subscription page
manage_subscription_page = ManageSubscriptionPage.objects.first()
Expand Down
14 changes: 14 additions & 0 deletions subscription/templates/subscription/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ <h1>{{ page.title }}</h1>
<script
src="https://www.paypal.com/sdk/js?client-id={{ paypal_client_id }}&vault=true&intent=subscription"></script>

{% if request.user.is_superuser %}
<!-- warn superuser not to subscribe since it may cause unexpected difficulties -->
<div class="alert alert-warning" role="alert">
<h2 class="alert-heading fs-4">
<i class="bi bi-exclamation-triangle-fill"></i>
Warning
</h2>
<p>As a superuser, <b>you should not subscribe to a plan</b>. Doing so may cause unexpected difficulties or errors.</p>
<p class="mb-0">
If you want to test the subscription process, <b>please create a new user and subscribe as that user</b>.
</p>
</div>
{% endif %}

{% include_block page.body %}
{% endif %}
{% endblock %}

0 comments on commit 31d6f28

Please sign in to comment.