mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2026-07-30 23:38:02 -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.
46 lines
1.5 KiB
Python
46 lines
1.5 KiB
Python
from .models import EndurainIntegration, ImmichIntegration, WandererIntegration
|
|
from rest_framework import serializers
|
|
|
|
|
|
class WandererIntegrationSerializer(serializers.ModelSerializer):
|
|
api_key = serializers.CharField(write_only=True, required=False)
|
|
|
|
class Meta:
|
|
model = WandererIntegration
|
|
fields = ['id', 'server_url', 'api_key']
|
|
read_only_fields = ['id']
|
|
|
|
def to_representation(self, instance):
|
|
return {
|
|
'id': str(instance.id),
|
|
'server_url': instance.server_url,
|
|
}
|
|
|
|
|
|
class EndurainIntegrationSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = EndurainIntegration
|
|
fields = ['id', 'server_url', 'username', 'auth_method', 'endurain_user_id']
|
|
read_only_fields = ['id', 'username', 'auth_method', 'endurain_user_id']
|
|
|
|
def to_representation(self, instance):
|
|
return {
|
|
'id': str(instance.id),
|
|
'server_url': instance.server_url,
|
|
'username': instance.username,
|
|
'auth_method': instance.auth_method,
|
|
'endurain_user_id': instance.endurain_user_id,
|
|
}
|
|
|
|
|
|
class ImmichIntegrationSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = ImmichIntegration
|
|
fields = '__all__'
|
|
read_only_fields = ['id', 'user']
|
|
|
|
def to_representation(self, instance):
|
|
representation = super().to_representation(instance)
|
|
representation.pop('user', None)
|
|
return representation
|