Skip to content

Commit

Permalink
Make disclaimers visible from profile
Browse files Browse the repository at this point in the history
  • Loading branch information
rebkwok committed Jul 8, 2024
1 parent 4f44d32 commit 6f0db77
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
3 changes: 2 additions & 1 deletion accounts/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.urls import path
from accounts.views import ProfileUpdateView, profile, \
SignedDataPrivacyCreateView
SignedDataPrivacyCreateView, user_disclaimer


app_name = 'profile'
Expand All @@ -12,5 +12,6 @@
'data-privacy-review/', SignedDataPrivacyCreateView.as_view(),
name='data_privacy_review'
),
path("disclaimer", user_disclaimer, name='view_latest_disclaimer'),
path('', profile, name='profile'),
]
10 changes: 10 additions & 0 deletions accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from activitylog.models import ActivityLog
from booking.email_helpers import send_mail
from common.mailchimp_utils import update_mailchimp
from studioadmin.views.disclaimers import user_disclaimer_view_context


@login_required
Expand Down Expand Up @@ -357,3 +358,12 @@ def get_success_url(self, form=None):
if form and form.next_url:
return form.next_url
return reverse('booking:lessons')


@login_required
def user_disclaimer(request):
ctx = user_disclaimer_view_context(user_id=request.user.id)
ctx["editable"] = False
return TemplateResponse(
request, "studioadmin/user_disclaimer.html", ctx
)
20 changes: 12 additions & 8 deletions studioadmin/views/disclaimers.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,21 +141,25 @@ def disclaimer_content_view(request, version):
request, "studioadmin/disclaimer_content_view.html", ctx
)

@login_required
@is_instructor_or_staff
def user_disclaimer(request, encoded_user_id):
# get last disclaimer for this user
user_id = dechaffify(str_int(encoded_user_id))

def user_disclaimer_view_context(user_id=None, encoded_user_id=None):

# get last disclaimer for this user
user_id = user_id or dechaffify(str_int(encoded_user_id))
disclaimer = OnlineDisclaimer.objects.filter(user__id=user_id).last()
disclaimer_content = DisclaimerContent.objects.get(version=disclaimer.version)

ctx = {
return {
'disclaimer': disclaimer,
'disclaimer_content': disclaimer_content,
'encoded_user_id': encoded_user_id
}
'encoded_user_id': encoded_user_id,
}

@login_required
@is_instructor_or_staff
def user_disclaimer(request, encoded_user_id):
ctx = user_disclaimer_view_context(encoded_user_id=encoded_user_id)
ctx["editable"] = True
return TemplateResponse(
request, "studioadmin/user_disclaimer.html", ctx
)
Expand Down
2 changes: 1 addition & 1 deletion templates/account/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ <h4 class="card-title">Account Info</h4>
<span class="col-3"><strong>Disclaimer:</strong></span>
<span class="col-9">
{% if disclaimer %}
Completed
Completed <a class="btn btn-sm btn-wm btn-wm-xs ml-2" href="{% url 'profile:view_latest_disclaimer' %}" target="_blank">View</a>
{% elif expired_disclaimer %}
Expired
{% else %}
Expand Down
2 changes: 2 additions & 0 deletions templates/studioadmin/user_disclaimer.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{% block studioadmincontent %}

<div class="container-fluid row">
{% if editable %}
<div>
<a href="javascript:window.print()" id="print-button" alt="print this page"><span class="fa fa-print fa-3x"></span></a>
{% if request.user.is_staff or request.user.is_instructor %}
Expand All @@ -25,6 +26,7 @@
{% endif %}
{% endif %}
</div>
{% endif %}


<div class="disclaimer">
Expand Down

0 comments on commit 6f0db77

Please sign in to comment.