Last active
November 23, 2016 23:22
-
-
Save capooti/3c57072e747e1efa525cf9c8b52c15f5 to your computer and use it in GitHub Desktop.
Fix old WorldMap maps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from geonode.maps.models import Map | |
broken_maps = [2517, | |
2519, | |
2520, | |
2521, | |
2522, | |
2525, | |
2527, | |
2528, | |
2529, | |
2530, | |
2531, | |
2532, | |
2533, | |
2534, | |
2535, | |
2536, | |
2537, | |
2538, | |
2539, | |
2540, | |
2542, | |
2543, | |
2546, | |
2547, | |
2549, | |
2550, | |
2551, | |
2554, | |
2555, | |
2556, | |
2557, | |
2558, | |
2561, | |
2562, | |
2563, | |
2564, | |
2565, | |
2566, | |
2569, | |
2570, | |
2571, | |
2572, | |
2573, | |
2574, | |
2577, | |
2578, | |
2581, | |
2582, | |
2583, | |
2584, | |
2585, | |
2586, | |
2587, | |
2588, | |
2589, | |
2590, | |
2591, | |
2592, | |
2593, | |
2596, | |
2616, | |
2617, | |
2619, | |
2620, | |
2621, | |
2623, | |
2628, | |
2630, | |
2632, | |
2633, | |
2634, | |
2635, | |
2638, | |
2640, | |
2641, | |
2643, | |
2644, | |
2646, | |
2648, | |
2649, | |
2650, | |
2651, | |
2652, | |
2655, | |
2656, | |
2657, | |
2658, | |
2659, | |
2660, | |
2661, | |
2662, | |
2663, | |
2665, | |
2669, | |
2670, | |
2671, | |
2672, | |
2673, | |
2674, | |
2675, | |
2676, | |
2677, | |
2678, | |
2681, | |
2682, | |
2683, | |
2684, | |
2685, | |
2687, | |
2692, | |
2693, | |
2695, | |
2696, | |
2697, | |
2699, | |
2700, | |
2701, | |
2702, | |
2703, | |
2704, | |
2705, | |
2707, | |
2709, | |
2711, | |
2713, | |
2714, | |
2715, | |
2716, | |
2717, | |
2719, | |
2720, | |
2724, | |
2730, | |
2731, | |
2732] | |
for map in Map.objects.all().order_by('id'): | |
if map.id not in broken_maps: | |
print 'Migrating map with id: %s titled %s' % (map.id, map.title) | |
for layer in map.layer_set.filter(ows_url__icontains='worldmap.harvard.edu/geoserver/wms'): | |
print 'Layer order %s' % layer.stack_order | |
if not '"local":true' in layer.layer_params: | |
config = json.loads(layer.layer_params) | |
config['local'] = True | |
new_config = json.dumps(config) | |
layer.layer_params = new_config | |
layer.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment