Skip to content

Commit

Permalink
Merge pull request #109 from acdh-oeaw/bugfix/91-change-rkts-to-http
Browse files Browse the repository at this point in the history
change rkts links from https to http
  • Loading branch information
gythaogg authored Jul 15, 2024
2 parents fd7f8f8 + 7e78669 commit 60c3f5f
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions apis_ontology/management/commands/change_rkts_links_to_http.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from django.core.management.base import BaseCommand

from apis_ontology.models import Person, Place, Work, Instance


class Command(BaseCommand):
help = "Change https links in rkts links to http"

def handle(self, *args, **options):
def convert_to_https(qs, entity_type=""):
for obj in qs:
obj.external_links = obj.external_links.replace("https://", "http://")
obj.save()

self.stdout.write(
self.style.SUCCESS(
f"{len(qs)} {entity_type if entity_type else 'entities'} updated"
)
)

http_persons = Person.objects.filter(external_links__contains="rkts")
convert_to_https(http_persons, "persons")
http_places = Place.objects.filter(external_links__contains="rkts")
convert_to_https(http_places, "places")
http_works = Work.objects.filter(external_links__contains="rkts")
convert_to_https(http_works, "works")
http_instances = Instance.objects.filter(external_links__contains="rkts")
convert_to_https(http_instances, "instances")

0 comments on commit 60c3f5f

Please sign in to comment.