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

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

Open
rhodges opened this issue Mar 8, 2019 · 0 comments
Open

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

rhodges opened this issue Mar 8, 2019 · 0 comments
Assignees

Comments

@rhodges
Copy link
Contributor

rhodges commented Mar 8, 2019

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()
@rhodges rhodges self-assigned this Mar 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant