Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for other external services #227

Open
Buried-In-Code opened this issue Mar 22, 2024 · 2 comments
Open

Add support for other external services #227

Buried-In-Code opened this issue Mar 22, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@Buried-In-Code
Copy link
Member

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

@bpepple bpepple self-assigned this Mar 22, 2024
@bpepple bpepple added the enhancement New feature or request label Mar 22, 2024
@bpepple
Copy link
Member

bpepple commented Mar 22, 2024

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.

@bpepple
Copy link
Member

bpepple commented Mar 23, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants