Skip to content

Need easy way to control Slider children 'Site' settings. #15

@rhodges

Description

@rhodges

We need children to belong to the sites that the Slider parents belong to.

A quick script I used for updating the children (but not the parents) for the Monthly AIS sliders (2016 and 2017):

from django.contrib.sites.models import Site
from data_manager.models import Layer

production_site_id = 1

prod = Site.objects.get(pk=production_site_id)
AIS7 = Layer.all_objects.get(id=1385)
AIS6 = Layer.all_objects.get(id=1363)

for parent in [AIS6, AIS7]:
  children_dict = parent.associatedMultilayers
  for month in children_dict.keys():
    for vessel_type in children_dict[month].keys():
      child_layer_id = children_dict[month][vessel_type]
      child_layer = Layer.all_objects.get(pk=child_layer_id)
      child_layer.site.add(prod)
      child_layer.save()

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions