Skip to content

Commit

Permalink
added sandbox btn block to create account btn and connect to sp buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
arojas1 committed Oct 9, 2024
1 parent 40cdcf9 commit d56cbb7
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 39 deletions.
3 changes: 2 additions & 1 deletion accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ def landing(request):

@login_required(login_url="login")
def select_account(request):
return render(request, "accounts/select-account.html")
envi = dev_prod_or_local(request.get_host())
return render(request, "accounts/select-account.html", {"envi": envi})


class CustomSocialSignupView(SignupView):
Expand Down
2 changes: 2 additions & 0 deletions institutions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,7 @@ def connections(request, pk):
@member_required(roles=["admin", "editor"])
def connect_service_provider(request, pk):
try:
envi = dev_prod_or_local(request.get_host())
institution = get_institution(pk)
member_role = check_member_role(request.user, institution)
if request.method == "GET":
Expand Down Expand Up @@ -1505,6 +1506,7 @@ def connect_service_provider(request, pk):
'institution': institution,
'other_service_providers': other_service_providers,
'connected_service_providers': connected_service_providers,
'envi': envi
}
return render(request, 'account_settings_pages/_connect-service-provider.html', context)

Expand Down
81 changes: 45 additions & 36 deletions templates/account_settings_pages/_connect-service-provider.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,46 +89,55 @@ <h3 class="mr-8 pointer" onclick="toggleSectionInfo(this, 'addServiceProvidersDi
</div>

<div class="w-15">
{% if institution.is_subscribed or researcher.is_subscribed or community.is_approved %}
{% if not service_provider.certification_type == 'manual'%}
<button
name="connectServiceProviderbtn"
class="primary-btn action-btn w-100"
data-name="{{ service_provider.name }}"
data-id="{{ service_provider.id }}"
>
Connect <i class="fa-solid fa-link-simple"></i>
</button>
{% elif service_provider.certification_type == 'manual' %}
<a
class="primary-btn action-btn w-100"
href="{{ service_provider.documentation }}"
target="_blank"
>
More Info <i class="fa-solid fa-arrow-up-right-from-square fa-xs"></i>
</a>
{% endif %}
{% else %}
{% if not service_provider.certification_type == 'manual'%}
<div class="btn-with-helptext">
<a
class="primary-btn disabled-btn w-100"
{% if envi != 'SANDBOX' %}
{% if institution.is_subscribed or researcher.is_subscribed or community.is_approved %}
{% if not service_provider.certification_type == 'manual'%}
<button
name="connectServiceProviderbtn"
class="primary-btn action-btn w-100"
data-name="{{ service_provider.name }}"
data-id="{{ service_provider.id }}"
>
Connect <i class="fa-solid fa-link-simple"></i>
</button>
{% elif service_provider.certification_type == 'manual' %}
<a
class="primary-btn action-btn w-100"
href="{{ service_provider.documentation }}"
target="_blank"
>
More Info <i class="fa-solid fa-arrow-up-right-from-square fa-xs"></i>
</a>
<span class="btn-help-text">
Your account needs to be {% if community %}confirmed{% else %}subscribed{% endif %} to connect to Service Providers.
</span>
</div>
{% elif service_provider.certification_type == 'manual' %}
<a
class="primary-btn action-btn w-100"
href="{{ service_provider.documentation }}"
target="_blank"
>
More Info <i class="fa-solid fa-arrow-up-right-from-square fa-xs"></i>
</a>
{% endif %}
{% else %}
{% if not service_provider.certification_type == 'manual'%}
<div class="btn-with-helptext">
<a class="primary-btn disabled-btn w-100">
Connect <i class="fa-solid fa-link-simple"></i>
</a>
<span class="btn-help-text">
Your account needs to be {% if community %}confirmed{% else %}subscribed{% endif %} to connect to Service Providers.
</span>
</div>
{% elif service_provider.certification_type == 'manual' %}
<a
class="primary-btn action-btn w-100"
href="{{ service_provider.documentation }}"
target="_blank"
>
More Info <i class="fa-solid fa-arrow-up-right-from-square fa-xs"></i>
</a>
{% endif %}
{% endif %}
{% else %}
<div class="btn-with-helptext">
<a class="primary-btn disabled-btn w-100">
Connect <i class="fa-solid fa-link-simple"></i>
</a>
<span class="btn-help-text">
Connecting to Service Providers is not available in the Sandbox.
</span>
</div>
{% endif %}
</div>
</div>
Expand Down
23 changes: 21 additions & 2 deletions templates/accounts/select-account.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,16 @@ <h2 class="mt-0">Choose an account</h2>

<p>Create a new account or Join an existing account. Not sure which account type to create? <a class="default-a" href="mailto:[email protected]">Contact us</a>.</p>
<div class="flex-this gap-1">
<a id="create-account" class="primary-btn disabled-btn">Create</a>
{% if envi == 'SANDBOX' %}
<div class="btn-with-helptext">
<a id="create-account" class="primary-btn disabled-btn">Create</a>
<span id="helptext" class="btn-help-text hide" style="left: 0%;">
Creating this account is unavailable in the Sandbox
</span>
</div>
{% else %}
<a id="create-account" class="primary-btn disabled-btn">Create</a>
{% endif %}
<a id="join-account" class="primary-btn disabled-btn">Join</a>
</div>

Expand All @@ -143,11 +152,16 @@ <h2 class="mt-0">Choose an account</h2>
var joinBtn = document.getElementById('join-account');
var accountCards = document.getElementsByClassName('account-card');
var i;
var envi = "{{ envi }}"
var helptext = document.getElementById('helptext');

function showButtons(e) {
for (i = 0; i < accountCards.length; i++) {
accountCards[i].classList.remove('card-selected');
}
if (helptext) {
helptext.classList.add('hide');
}

selectedCard = e.closest('.account-card');
selectedCard.classList.add('card-selected');
Expand Down Expand Up @@ -181,14 +195,19 @@ <h2 class="mt-0">Choose an account</h2>
joinBtn.classList.remove('action-btn');
joinBtn.classList.add('disabled-btn');
}
else if (e.value == 'service-provider') {
else if (e.value == 'service-provider' && !(envi == 'SANDBOX')) {
createBtn.classList.remove('disabled-btn');
createBtn.classList.add('action-btn');
createBtn.setAttribute('href', '{% url "prep-service-provider" %}');

joinBtn.classList.remove('action-btn');
joinBtn.classList.add('disabled-btn');
}
else if (e.value == 'service-provider' && envi == 'SANDBOX') {
createBtn.classList.remove('action-btn');
createBtn.classList.add('disabled-btn');
helptext.classList.remove('hide');
}
}
</script>
{% endblock %}

0 comments on commit d56cbb7

Please sign in to comment.