mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2026-07-31 15:59:34 -04:00
- Introduced the Endurain integration, allowing users to connect their self-hosted Endurain instance for activity browsing and GPX import. - Added `EndurainIntegration` model, serializer, and viewset to manage user connections and activities. - Implemented MFA support for Endurain login, including token handling and validation. - Enhanced activity handling in `ActivityViewSet` to prioritize user-provided elevation data over GPX-derived values. - Updated environment configuration and documentation to include Endurain integration details. - Added tests for Endurain services and integration functionality to ensure reliability and correctness. - Improved throttling for Endurain authentication to enhance security and performance.
102 lines
2.9 KiB
Python
102 lines
2.9 KiB
Python
from django.contrib import admin
|
|
from allauth.account.decorators import secure_admin_login
|
|
|
|
from integrations.models import EndurainIntegration, ImmichIntegration, StravaToken, WandererIntegration
|
|
|
|
admin.site.login = secure_admin_login(admin.site.login)
|
|
|
|
@admin.register(WandererIntegration)
|
|
class WandererIntegrationAdmin(admin.ModelAdmin):
|
|
list_display = ('user', 'server_url', 'id')
|
|
search_fields = ('user__username', 'server_url')
|
|
autocomplete_fields = ('user',)
|
|
readonly_fields = ('id',)
|
|
|
|
fieldsets = (
|
|
(None, {'fields': ('user', 'server_url', 'id')}),
|
|
(
|
|
'Credentials',
|
|
{
|
|
'classes': ('collapse',),
|
|
'fields': ('api_key',),
|
|
'description': 'API key is not shown in list views. Expand to view or rotate.',
|
|
},
|
|
),
|
|
)
|
|
|
|
|
|
@admin.register(ImmichIntegration)
|
|
class ImmichIntegrationAdmin(admin.ModelAdmin):
|
|
list_display = ('user', 'server_url', 'copy_locally', 'id')
|
|
list_filter = ('copy_locally',)
|
|
search_fields = ('user__username', 'server_url')
|
|
autocomplete_fields = ('user',)
|
|
readonly_fields = ('id',)
|
|
|
|
fieldsets = (
|
|
(None, {'fields': ('user', 'server_url', 'copy_locally', 'id')}),
|
|
(
|
|
'Credentials',
|
|
{'classes': ('collapse',), 'fields': ('api_key',)},
|
|
),
|
|
)
|
|
|
|
|
|
@admin.register(StravaToken)
|
|
class StravaTokenAdmin(admin.ModelAdmin):
|
|
list_display = (
|
|
'user',
|
|
'athlete_id',
|
|
'expires_at',
|
|
'scope',
|
|
'updated_at',
|
|
)
|
|
list_filter = ('scope',)
|
|
search_fields = ('user__username', 'athlete_id')
|
|
autocomplete_fields = ('user',)
|
|
readonly_fields = ('updated_at',)
|
|
|
|
fieldsets = (
|
|
(None, {'fields': ('user', 'athlete_id', 'scope', 'expires_at', 'updated_at')}),
|
|
(
|
|
'OAuth tokens',
|
|
{
|
|
'classes': ('collapse',),
|
|
'fields': ('access_token', 'refresh_token'),
|
|
'description': 'OAuth tokens are stored for Strava sync.',
|
|
},
|
|
),
|
|
)
|
|
|
|
|
|
@admin.register(EndurainIntegration)
|
|
class EndurainIntegrationAdmin(admin.ModelAdmin):
|
|
list_display = ('user', 'server_url', 'username', 'auth_method', 'endurain_user_id', 'updated_at')
|
|
list_filter = ('auth_method',)
|
|
search_fields = ('user__username', 'server_url', 'username')
|
|
autocomplete_fields = ('user',)
|
|
readonly_fields = ('id', 'updated_at')
|
|
|
|
fieldsets = (
|
|
(None, {
|
|
'fields': (
|
|
'user',
|
|
'server_url',
|
|
'username',
|
|
'auth_method',
|
|
'endurain_user_id',
|
|
'access_token_expires_at',
|
|
'refresh_token_expires_at',
|
|
'id',
|
|
'updated_at',
|
|
),
|
|
}),
|
|
(
|
|
'JWT tokens',
|
|
{
|
|
'classes': ('collapse',),
|
|
'fields': ('access_token', 'refresh_token'),
|
|
},
|
|
),
|
|
)
|