Files
AdventureLog/backend/server/integrations/models.py
Sean Morley 36631886a2 Add Wanderer author fields and enhance integration with API key authentication
- Introduced `wanderer_author_username` and `wanderer_author_domain` fields to the Trail model for better integration with the Wanderer API.
- Updated TrailSerializer to include new fields and ensure proper backfilling of author information from the Wanderer API.
- Enhanced import/export functionality to handle new author fields for backward compatibility.
- Migrated Wanderer integration to use API key authentication, removing username and token fields for improved security.
- Updated documentation to reflect changes in the Wanderer integration setup and usage.
- Added utility functions for handling GeoJSON data from GPX files and improved error handling in related services.
- Refactored views and serializers to accommodate the new integration structure and ensure seamless user experience.
2026-06-01 20:08:20 -04:00

40 lines
1.6 KiB
Python

from django.db import models
from django.contrib.auth import get_user_model
import uuid
User = get_user_model()
class ImmichIntegration(models.Model):
server_url = models.CharField(max_length=255)
api_key = models.CharField(max_length=255)
user = models.ForeignKey(
User, on_delete=models.CASCADE)
copy_locally = models.BooleanField(default=True, help_text="Copy image to local storage, instead of just linking to the remote URL.")
id = models.UUIDField(default=uuid.uuid4, editable=False, unique=True, primary_key=True)
def __str__(self):
return self.user.username + ' - ' + self.server_url
class StravaToken(models.Model):
user = models.ForeignKey(
User, on_delete=models.CASCADE, related_name='strava_tokens')
access_token = models.CharField(max_length=255)
refresh_token = models.CharField(max_length=255)
expires_at = models.BigIntegerField() # Unix timestamp
athlete_id = models.BigIntegerField(null=True, blank=True)
scope = models.CharField(max_length=255, null=True, blank=True)
updated_at = models.DateTimeField(auto_now=True)
class WandererIntegration(models.Model):
server_url = models.CharField(max_length=255)
api_key = models.CharField(max_length=512)
user = models.ForeignKey(
User, on_delete=models.CASCADE, related_name='wanderer_integrations')
id = models.UUIDField(default=uuid.uuid4, editable=False, unique=True, primary_key=True)
def __str__(self):
return self.user.username + ' - ' + self.server_url
class Meta:
verbose_name = "Wanderer Integration"
verbose_name_plural = "Wanderer Integrations"