misc: do not update Issuer uselessly (#86976)
gitea/django-mellon/pipeline/head This commit looks good
Details
gitea/django-mellon/pipeline/head This commit looks good
Details
This commit is contained in:
parent
b372884c2d
commit
7f58bf9c66
|
@ -19,12 +19,18 @@ from . import models, utils
|
||||||
def get_issuer(entity_id):
|
def get_issuer(entity_id):
|
||||||
idp = utils.get_idp(entity_id)
|
idp = utils.get_idp(entity_id)
|
||||||
slug = idp.get('SLUG')
|
slug = idp.get('SLUG')
|
||||||
|
issuer = None
|
||||||
if slug:
|
if slug:
|
||||||
issuer = models.Issuer.objects.filter(slug=slug).first()
|
issuer = models.Issuer.objects.filter(slug=slug).first()
|
||||||
# migrate issuer entity_id based on the slug
|
# migrate issuer entity_id based on the slug
|
||||||
if issuer and issuer.entity_id != entity_id:
|
if issuer and issuer.entity_id != entity_id:
|
||||||
issuer.entity_id = entity_id
|
issuer.entity_id = entity_id
|
||||||
issuer.save()
|
issuer.save()
|
||||||
if not slug or not issuer:
|
|
||||||
issuer, _ = models.Issuer.objects.update_or_create(entity_id=entity_id, defaults={'slug': slug})
|
if issuer is None:
|
||||||
|
issuer, _ = models.Issuer.objects.get_or_create(entity_id=entity_id)
|
||||||
|
# migrate issuer slug based on the entity_id
|
||||||
|
if issuer.slug != slug:
|
||||||
|
issuer.slug = slug
|
||||||
|
issuer.save()
|
||||||
return issuer
|
return issuer
|
||||||
|
|
Loading…
Reference in New Issue