Open Buried-In-Code opened 7 months ago
This is something I've thought about adding since I would just need to add a AlternativeSources
model like:
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.db import models
class AlternativeSources(models.Model):
class Source(models.TextChoices):
COMICVINE = "C", "Comic Vine"
GCD = "G", "Grand Comics Database"
LOCG = "L", "League of Comic Geeks"
MARVEL = "M", "Marvel"
source = models.CharField(max_length=1, choices=Source.choices, default=Source.COMICVINE)
id_ = models.PositiveIntegerField("ID")
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
object_id = models.PositiveIntegerField()
content_object = GenericForeignKey("content_type", "object_id")
class Meta:
indexes = [models.Index(fields=["content_type", "object_id"], name="ct_obj_id_idx")]
ordering = ["content_type", "object_id"]
def __str__(self) -> str:
return f"{self.source}: {self.id_}"
I'd also need to write some data migrations for existing CV_ID's, but that won't be terribly hard.
The only thing stopping me from implementing this is finding a solution to add a Post
method for a model with a Generic Relation to the API, otherwise I couldn't automate adding this information.
Did a little searching on this and the only project I could find was this (which was archived yesterday) :
https://github.com/LilyFoote/rest-framework-generic-relations
Describe the solution you'd like Metron has support for Comicvine Ids, it would be nice if this could be expanded to include other services such as Marvel, GCD, League of Comics, etc...
Describe alternatives you've considered Currently I have to manually search in each service using title, year and number
Additional context