fix: resolve architecture warnings (SVC-006, FE-008, FE-004)
- Move db.commit() from admin_subscription_service to API endpoints - Add noqa comments for intentional number inputs in templates - Add noqa comment for inline modal in subscriptions.html 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -78,6 +78,8 @@ def create_subscription_tier(
|
|||||||
):
|
):
|
||||||
"""Create a new subscription tier."""
|
"""Create a new subscription tier."""
|
||||||
tier = admin_subscription_service.create_tier(db, tier_data.model_dump())
|
tier = admin_subscription_service.create_tier(db, tier_data.model_dump())
|
||||||
|
db.commit()
|
||||||
|
db.refresh(tier)
|
||||||
return SubscriptionTierResponse.model_validate(tier)
|
return SubscriptionTierResponse.model_validate(tier)
|
||||||
|
|
||||||
|
|
||||||
@@ -91,6 +93,8 @@ def update_subscription_tier(
|
|||||||
"""Update a subscription tier."""
|
"""Update a subscription tier."""
|
||||||
update_data = tier_data.model_dump(exclude_unset=True)
|
update_data = tier_data.model_dump(exclude_unset=True)
|
||||||
tier = admin_subscription_service.update_tier(db, tier_code, update_data)
|
tier = admin_subscription_service.update_tier(db, tier_code, update_data)
|
||||||
|
db.commit()
|
||||||
|
db.refresh(tier)
|
||||||
return SubscriptionTierResponse.model_validate(tier)
|
return SubscriptionTierResponse.model_validate(tier)
|
||||||
|
|
||||||
|
|
||||||
@@ -106,6 +110,7 @@ def delete_subscription_tier(
|
|||||||
Sets is_active=False rather than deleting to preserve history.
|
Sets is_active=False rather than deleting to preserve history.
|
||||||
"""
|
"""
|
||||||
admin_subscription_service.deactivate_tier(db, tier_code)
|
admin_subscription_service.deactivate_tier(db, tier_code)
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
@@ -190,6 +195,8 @@ def update_vendor_subscription(
|
|||||||
"""
|
"""
|
||||||
data = update_data.model_dump(exclude_unset=True)
|
data = update_data.model_dump(exclude_unset=True)
|
||||||
sub, vendor = admin_subscription_service.update_subscription(db, vendor_id, data)
|
sub, vendor = admin_subscription_service.update_subscription(db, vendor_id, data)
|
||||||
|
db.commit()
|
||||||
|
db.refresh(sub)
|
||||||
|
|
||||||
return VendorSubscriptionWithVendor(
|
return VendorSubscriptionWithVendor(
|
||||||
**VendorSubscriptionResponse.model_validate(sub).model_dump(),
|
**VendorSubscriptionResponse.model_validate(sub).model_dump(),
|
||||||
|
|||||||
@@ -73,8 +73,6 @@ class AdminSubscriptionService:
|
|||||||
|
|
||||||
tier = SubscriptionTier(**tier_data)
|
tier = SubscriptionTier(**tier_data)
|
||||||
db.add(tier)
|
db.add(tier)
|
||||||
db.commit()
|
|
||||||
db.refresh(tier)
|
|
||||||
|
|
||||||
logger.info(f"Created subscription tier: {tier.code}")
|
logger.info(f"Created subscription tier: {tier.code}")
|
||||||
return tier
|
return tier
|
||||||
@@ -88,9 +86,6 @@ class AdminSubscriptionService:
|
|||||||
for field, value in update_data.items():
|
for field, value in update_data.items():
|
||||||
setattr(tier, field, value)
|
setattr(tier, field, value)
|
||||||
|
|
||||||
db.commit()
|
|
||||||
db.refresh(tier)
|
|
||||||
|
|
||||||
logger.info(f"Updated subscription tier: {tier.code}")
|
logger.info(f"Updated subscription tier: {tier.code}")
|
||||||
return tier
|
return tier
|
||||||
|
|
||||||
@@ -117,7 +112,6 @@ class AdminSubscriptionService:
|
|||||||
)
|
)
|
||||||
|
|
||||||
tier.is_active = False
|
tier.is_active = False
|
||||||
db.commit()
|
|
||||||
|
|
||||||
logger.info(f"Soft-deleted subscription tier: {tier.code}")
|
logger.info(f"Soft-deleted subscription tier: {tier.code}")
|
||||||
|
|
||||||
@@ -192,9 +186,6 @@ class AdminSubscriptionService:
|
|||||||
for field, value in update_data.items():
|
for field, value in update_data.items():
|
||||||
setattr(sub, field, value)
|
setattr(sub, field, value)
|
||||||
|
|
||||||
db.commit()
|
|
||||||
db.refresh(sub)
|
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
f"Admin updated subscription for vendor {vendor_id}: {list(update_data.keys())}"
|
f"Admin updated subscription for vendor {vendor_id}: {list(update_data.keys())}"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{# app/templates/admin/subscription-tiers.html #}
|
{# app/templates/admin/subscription-tiers.html #}
|
||||||
|
{# noqa: FE-008 - Using raw number inputs for cents/limits in admin tier config modal #}
|
||||||
{% extends "admin/base.html" %}
|
{% extends "admin/base.html" %}
|
||||||
{% from 'shared/macros/alerts.html' import alert_dynamic, error_state %}
|
{% from 'shared/macros/alerts.html' import alert_dynamic, error_state %}
|
||||||
{% from 'shared/macros/headers.html' import page_header_refresh %}
|
{% from 'shared/macros/headers.html' import page_header_refresh %}
|
||||||
|
|||||||
@@ -228,6 +228,8 @@
|
|||||||
{{ pagination_full() }}
|
{{ pagination_full() }}
|
||||||
|
|
||||||
<!-- Edit Modal -->
|
<!-- Edit Modal -->
|
||||||
|
{# noqa: FE-004 - Inline modal required for complex subscription edit form #}
|
||||||
|
{# noqa: FE-008 - Using raw number inputs for custom limit overrides #}
|
||||||
<div x-show="showModal" x-cloak class="fixed inset-0 z-50 flex items-center justify-center overflow-auto bg-black bg-opacity-50">
|
<div x-show="showModal" x-cloak class="fixed inset-0 z-50 flex items-center justify-center overflow-auto bg-black bg-opacity-50">
|
||||||
<div class="relative w-full max-w-lg p-6 mx-4 bg-white rounded-lg shadow-xl dark:bg-gray-800" @click.away="closeModal()">
|
<div class="relative w-full max-w-lg p-6 mx-4 bg-white rounded-lg shadow-xl dark:bg-gray-800" @click.away="closeModal()">
|
||||||
<h3 class="text-lg font-semibold text-gray-900 dark:text-white mb-4">Edit Subscription</h3>
|
<h3 class="text-lg font-semibold text-gray-900 dark:text-white mb-4">Edit Subscription</h3>
|
||||||
|
|||||||
@@ -120,6 +120,7 @@
|
|||||||
Pricing
|
Pricing
|
||||||
</h3>
|
</h3>
|
||||||
<div class="grid gap-4 md:grid-cols-3">
|
<div class="grid gap-4 md:grid-cols-3">
|
||||||
|
{# noqa: FE-008 - Using raw number input for price field #}
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-400 mb-1">Price</label>
|
<label class="block text-sm font-medium text-gray-700 dark:text-gray-400 mb-1">Price</label>
|
||||||
<input
|
<input
|
||||||
|
|||||||
@@ -147,6 +147,7 @@
|
|||||||
Pricing
|
Pricing
|
||||||
</h3>
|
</h3>
|
||||||
<div class="grid gap-4 md:grid-cols-2 lg:grid-cols-4">
|
<div class="grid gap-4 md:grid-cols-2 lg:grid-cols-4">
|
||||||
|
{# noqa: FE-008 - Using raw number input for price with EUR prefix #}
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-400 mb-1">
|
<label class="block text-sm font-medium text-gray-700 dark:text-gray-400 mb-1">
|
||||||
Price (incl. VAT) <span class="text-red-500">*</span>
|
Price (incl. VAT) <span class="text-red-500">*</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user