fix(subscriptions): address code review feedback
- Use shared _require_admin from admin_users in subscriptions API endpoint
- Remove unnecessary Alpine.js hidden-div workaround in pricing.html
- Replace fragile string replace for OCR page count with proper Jinja {:,} format
- Improve comment wording in upload quota cleanup code
- Extract _scalar_count() helper in subscription.py to reduce repetition
- Add aria-valuemin='0' to all progressbar elements in subscription/index templates
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
@@ -113,7 +113,7 @@
|
||||
</div>
|
||||
{% if user_tier.lifetime_file_limit > 0 %}
|
||||
{% set pct = ([((user_usage.lifetime / user_tier.lifetime_file_limit) * 100) | int, 100] | min) %}
|
||||
<div class="w-full bg-gray-100 rounded-full h-2" role="progressbar"
|
||||
<div class="w-full bg-gray-100 rounded-full h-2" role="progressbar" aria-valuemin="0"
|
||||
aria-valuenow="{{ user_usage.lifetime }}" aria-valuemax="{{ user_tier.lifetime_file_limit }}">
|
||||
<div class="h-2 rounded-full {% if pct >= 90 %}bg-red-500{% elif pct >= 70 %}bg-yellow-500{% else %}bg-green-500{% endif %}"
|
||||
style="width: {{ pct }}%"></div>
|
||||
@@ -132,7 +132,7 @@
|
||||
</div>
|
||||
{% if user_tier.daily_upload_limit > 0 %}
|
||||
{% set pct = ([((user_usage.today / user_tier.daily_upload_limit) * 100) | int, 100] | min) %}
|
||||
<div class="w-full bg-gray-100 rounded-full h-2" role="progressbar"
|
||||
<div class="w-full bg-gray-100 rounded-full h-2" role="progressbar" aria-valuemin="0"
|
||||
aria-valuenow="{{ user_usage.today }}" aria-valuemax="{{ user_tier.daily_upload_limit }}">
|
||||
<div class="h-2 rounded-full {% if pct >= 90 %}bg-red-500{% elif pct >= 70 %}bg-yellow-500{% else %}bg-blue-500{% endif %}"
|
||||
style="width: {{ pct }}%"></div>
|
||||
@@ -151,7 +151,7 @@
|
||||
</div>
|
||||
{% if user_tier.monthly_upload_limit > 0 %}
|
||||
{% set pct = ([((user_usage.month / user_tier.monthly_upload_limit) * 100) | int, 100] | min) %}
|
||||
<div class="w-full bg-gray-100 rounded-full h-2" role="progressbar"
|
||||
<div class="w-full bg-gray-100 rounded-full h-2" role="progressbar" aria-valuemin="0"
|
||||
aria-valuenow="{{ user_usage.month }}" aria-valuemax="{{ user_tier.monthly_upload_limit }}">
|
||||
<div class="h-2 rounded-full {% if pct >= 90 %}bg-red-500{% elif pct >= 70 %}bg-yellow-500{% else %}bg-indigo-500{% endif %}"
|
||||
style="width: {{ pct }}%"></div>
|
||||
|
||||
@@ -31,9 +31,6 @@
|
||||
>
|
||||
Annual <span class="ml-1 text-xs bg-green-400 text-green-900 rounded-full px-2 py-0.5 font-bold">Save ~17%</span>
|
||||
</button>
|
||||
|
||||
<!-- Tier cards — responsive 4-column grid -->
|
||||
<div class="hidden" x-effect="$el.classList.remove('hidden')"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -221,7 +218,7 @@
|
||||
{% if tier.max_ocr_pages_monthly == 0 %}
|
||||
<span class="font-semibold text-green-600">Unlimited</span>
|
||||
{% else %}
|
||||
<span class="font-medium text-gray-800">{{ tier.max_ocr_pages_monthly | int | string | replace("2500", "2 500") }}</span>
|
||||
<span class="font-medium text-gray-800">{{ "{:,}".format(tier.max_ocr_pages_monthly) }}</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
{% endfor %}
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
{% if tier.lifetime_file_limit > 0 %}
|
||||
<div class="mt-2">
|
||||
{% set lifetime_pct = ((usage.lifetime / tier.lifetime_file_limit) * 100) | int %}
|
||||
<div class="w-full bg-gray-200 rounded-full h-1.5" role="progressbar"
|
||||
<div class="w-full bg-gray-200 rounded-full h-1.5" role="progressbar" aria-valuemin="0"
|
||||
aria-valuenow="{{ usage.lifetime }}" aria-valuemax="{{ tier.lifetime_file_limit }}">
|
||||
<div class="h-1.5 rounded-full
|
||||
{% if lifetime_pct >= 90 %}bg-red-500{% elif lifetime_pct >= 70 %}bg-yellow-500{% else %}bg-green-500{% endif %}"
|
||||
@@ -88,7 +88,7 @@
|
||||
{% if tier.daily_upload_limit > 0 %}
|
||||
<div class="mt-2">
|
||||
{% set today_pct = ((usage.today / tier.daily_upload_limit) * 100) | int %}
|
||||
<div class="w-full bg-gray-200 rounded-full h-1.5" role="progressbar"
|
||||
<div class="w-full bg-gray-200 rounded-full h-1.5" role="progressbar" aria-valuemin="0"
|
||||
aria-valuenow="{{ usage.today }}" aria-valuemax="{{ tier.daily_upload_limit }}">
|
||||
<div class="h-1.5 rounded-full
|
||||
{% if today_pct >= 90 %}bg-red-500{% elif today_pct >= 70 %}bg-yellow-500{% else %}bg-blue-500{% endif %}"
|
||||
@@ -108,7 +108,7 @@
|
||||
{% if tier.monthly_upload_limit > 0 %}
|
||||
<div class="mt-2">
|
||||
{% set month_pct = ((usage.month / tier.monthly_upload_limit) * 100) | int %}
|
||||
<div class="w-full bg-gray-200 rounded-full h-1.5" role="progressbar"
|
||||
<div class="w-full bg-gray-200 rounded-full h-1.5" role="progressbar" aria-valuemin="0"
|
||||
aria-valuenow="{{ usage.month }}" aria-valuemax="{{ tier.monthly_upload_limit }}">
|
||||
<div class="h-1.5 rounded-full
|
||||
{% if month_pct >= 90 %}bg-red-500{% elif month_pct >= 70 %}bg-yellow-500{% else %}bg-indigo-500{% endif %}"
|
||||
|
||||
Reference in New Issue
Block a user