I have 4 different types of subscription packages and I need to set template in a way that if one subscription is active than other enrol buttons should be disabled. I have two variables to work with.
is_active=True
subs_type = 'yearly' or 'monthly' or 'quarterly' or 'weekly'
On my packages.html page I have 4 packages like:
<div>
<h1>Package 1</h1>
<a href="/someurl"><input class"btn" type="submit" value="enroll"></a>
</div>
<div>
<h1>Package 2</h1>
<a href="/someurl"><input class"btn" type="submit" value="enroll"></a>
</div>
<div>
<h1>Package 3</h1>
<a href="/someurl"><input class"btn" type="submit" value="enroll"></a>
</div>
<div>
<h1>Package 4</h1>
<a href="/someurl"><input class"btn" type="submit" value="enroll"></a>
</div>
I have few conditions to apply which I couldn't make work together. 1. If user subscribed one of the package then all other enrol button should pop message that he/she already subscribed. 2. The one that is subscribed should sow cancel button but rest should show enrol button but should work.
Can someone help me to make it work please?
Considering what you said in that comments. That is_active
defines if the client is already subscribed, and package_type
describes which package the client is subscribed to.
So let's say that package 1 is the yearly package, then:
<h1>Package 1</h1>
{% if is_active %}
{% if package_type == "yearly" %}
<a href="/someurl"><input class"btn" type="submit" value="cancel"></a>
{% else %}
already enrolled to another package
{% endif %}
{% else %}
<a href="/someurl"><input class"btn" type="submit" value="enroll"></a>
{% endif %}
Assuming you're using jinja and not another templating language.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.