| {% extends 'users/settings/page.html' %}
| {% block head %}
| {{ super() }}
style(type='text/css').
	button#recheck_subscription {
		margin-top: 1em;
	}
| {% endblock %}

| {% block settings_page_title %}Subscription{% endblock %}
| {% block settings_page_content %}

//--------------------------------------------------------------------------------------------------
| {% if user_cls == 'demo' %}
h4.text-info.py-3
	i.pi-heart-filled
	| You have a free account
hr
p.
	You have full access to the Blender Cloud, provided by the Blender Institute. This account is
	meant for free evaluation of the service. Get in touch with
	#[a(href="mailto:cloudsupport@blender.org") cloudsupport@blender.org] if you have any questions.

//--------------------------------------------------------------------------------------------------
| {% elif user_cls == 'outsider' %}
h4.text-info.py-3
	i.pi-info
	| You do not have an active subscription.
hr
h3
	a(href="https://store.blender.org/product/membership/") Get full access to Blender Cloud now!

//--------------------------------------------------------------------------------------------------
| {% elif user_cls == 'subscriber-expired' %}
| {% set renew_url = url_for('cloud.renew_subscription') %}
h4.text-info.py-3
	i.pi-info
	a(href="{{renew_url}}") Your subscription can be renewed
hr
p.text-danger Subscription expired on: <strong>{{ expiration_date }}</strong>
p
	a.btn.btn-success.px-5(href="{{renew_url}}") Renew now

//--------------------------------------------------------------------------------------------------
| {% elif current_user.has_cap('subscriber') %}
h4.text-success.py-3
	i.pi-heart-filled.text-danger.pr-2
	| Your subscription is active

//---------------------------------
| {% if user_cls == 'subscriber' %}
h5 Thank you for supporting Blender!
hr
p Subscription expires on: <strong>{{ expiration_date }}</strong>
p
	a(href="{{ config['EXTERNAL_SUBSCRIPTIONS_MANAGEMENT_SERVER'] | urljoin('/my-account/subscriptions/') }}") Manage your subscription on Blender Store

//---------------------------------
| {% elif user_cls == 'subscriber-org' %}
p Your organisation provides you with your subscription.
| {% endif %}

//--------------------------------------------------------------------------------------------------
| {% endif %}

hr

button#recheck_subscription.btn.btn-sm.btn-outline-secondary.px-5(onclick="javascript:recheck_subscription(this)")
	| Re-check my Subscription

script.
	function recheck_subscription(button) {
		$(button).text('Checking');

		$.get('/api/bcloud/update-subscription')
		.done(function() {
			window.location.reload();
		})
		.fail(function(err) {
			if (err.status == 403) {
				/* This happens when we are no longer logged in properly, so just refresh the
				 * page to get a proper status. */
				window.location.reload();
				return;
			}
			alert('Unable to update subscription, please check your internet connection.');
		})
		;
	}

| {% endblock %}
