-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set is_root=True for old folders set as root_node for existing NodeSe…
…ttings [#PLAT-578]
- Loading branch information
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11.13 on 2018-07-11 18:05 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations | ||
|
||
|
||
def set_is_root(state, *args, **kwargs): | ||
OsfStorageFolder = state.get_model('addons_osfstorage', 'osfstoragefolder') | ||
OsfStorageFolder.objects.filter(nodesettings__isnull=False, is_root__isnull=True).update(is_root=True) | ||
|
||
|
||
def unset_is_root(state, *args, **kwargs): | ||
state.get_model('osf', 'osfstoragefolder').objects.filter(is_root=True).update(is_root=None) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('osf', '0116_merge_20180706_0901'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(set_is_root, unset_is_root) | ||
] |