Refactor WordPress integration service to use API key for connection testing
- Updated the `IntegrationService` to perform connection tests using only the API key, removing reliance on username and app password. - Simplified health check logic and improved error messaging for better clarity. - Added functionality to revoke API keys in the `WordPressIntegrationForm` component. - Enhanced site settings page with a site selector and improved integration status display. - Cleaned up unused code and improved overall structure for better maintainability.
This commit is contained in:
@@ -27,6 +27,27 @@ class IntegrationViewSet(SiteSectorModelViewSet):
|
||||
throttle_scope = 'integration'
|
||||
throttle_classes = [DebugScopedRateThrottle]
|
||||
|
||||
def get_queryset(self):
|
||||
"""
|
||||
Override to filter integrations by site.
|
||||
SiteIntegration only has 'site' field (no 'sector'), so SiteSectorModelViewSet's
|
||||
filtering doesn't apply. We manually filter by site here.
|
||||
"""
|
||||
queryset = super().get_queryset()
|
||||
|
||||
# Get site parameter from query params
|
||||
site_id = self.request.query_params.get('site_id') or self.request.query_params.get('site')
|
||||
|
||||
if site_id:
|
||||
try:
|
||||
site_id_int = int(site_id)
|
||||
queryset = queryset.filter(site_id=site_id_int)
|
||||
except (ValueError, TypeError):
|
||||
# Invalid site_id, return empty queryset
|
||||
queryset = queryset.none()
|
||||
|
||||
return queryset
|
||||
|
||||
def get_serializer_class(self):
|
||||
from rest_framework import serializers
|
||||
|
||||
|
||||
Reference in New Issue
Block a user