You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
4 years ago
|
# Generated by Django 3.1 on 2020-09-07 07:54
|
||
|
|
||
|
from django.db import migrations
|
||
|
|
||
3 years ago
|
from etebase_server.django.models import AccessLevels
|
||
4 years ago
|
|
||
|
|
||
|
def change_access_level_to_int(apps, schema_editor):
|
||
4 years ago
|
CollectionMember = apps.get_model("django_etebase", "CollectionMember")
|
||
|
CollectionInvitation = apps.get_model("django_etebase", "CollectionInvitation")
|
||
4 years ago
|
|
||
|
for member in CollectionMember.objects.all():
|
||
4 years ago
|
if member.accessLevelOld == "adm":
|
||
4 years ago
|
member.accessLevel = AccessLevels.ADMIN
|
||
4 years ago
|
elif member.accessLevelOld == "rw":
|
||
4 years ago
|
member.accessLevel = AccessLevels.READ_WRITE
|
||
4 years ago
|
elif member.accessLevelOld == "ro":
|
||
4 years ago
|
member.accessLevel = AccessLevels.READ_ONLY
|
||
|
member.save()
|
||
|
|
||
|
for invitation in CollectionInvitation.objects.all():
|
||
4 years ago
|
if invitation.accessLevelOld == "adm":
|
||
4 years ago
|
invitation.accessLevel = AccessLevels.ADMIN
|
||
4 years ago
|
elif invitation.accessLevelOld == "rw":
|
||
4 years ago
|
invitation.accessLevel = AccessLevels.READ_WRITE
|
||
4 years ago
|
elif invitation.accessLevelOld == "ro":
|
||
4 years ago
|
invitation.accessLevel = AccessLevels.READ_ONLY
|
||
|
invitation.save()
|
||
|
|
||
|
|
||
|
class Migration(migrations.Migration):
|
||
|
|
||
|
dependencies = [
|
||
4 years ago
|
("django_etebase", "0027_auto_20200907_0752"),
|
||
4 years ago
|
]
|
||
|
|
||
|
operations = [
|
||
|
migrations.RunPython(change_access_level_to_int),
|
||
|
]
|