Commit d5045fd8 authored by Lukas Burgey's avatar Lukas Burgey
Browse files

Rework get_service

parent 878b84e3
......@@ -76,36 +76,25 @@ class Service(models.Model):
# default values or values to update are expected as kwargs
def get_service(cls, name, site, **kwargs):
description = kwargs.get('description', '')
contact_email = kwargs.get('contact_email', '')
contact_description = kwargs.get('contact_description', '')
vos = kwargs.get('vos', None)
# non essential args
defaults = {}
for key in ['description', 'contact_email', 'contact_description']:
if key in kwargs:
defaults[key] = kwargs[key]
service, created = cls.objects.get_or_create(
service, created = cls.objects.update_or_create(
'description': description,
'contact_email': contact_email,
'contact_description': contact_description,
if created:
if vos is not None:
for vo in vos:
service.vos.add(vo)'Service created: %s', service)
if service.description != description:
service.description = description
if service.contact_email != contact_email:
service.contact_email = contact_email
if service.contact_description != contact_description:
service.contact_description = contact_description
if 'vos' in kwargs:
for vo in kwargs['vos']:
if not service.vos.contains(vo):'VO %s now permits use of service %s', vo, service)
return service
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment