2020-09-07 08:02:40 +00:00
|
|
|
# Generated by Django 3.1 on 2020-09-07 07:54
|
|
|
|
|
|
|
|
from django.db import migrations
|
|
|
|
|
2022-05-08 14:32:29 +00:00
|
|
|
from etebase_server.django.models import AccessLevels
|
2020-09-07 08:02:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
def change_access_level_to_int(apps, schema_editor):
|
2020-11-14 15:04:41 +00:00
|
|
|
CollectionMember = apps.get_model("django_etebase", "CollectionMember")
|
|
|
|
CollectionInvitation = apps.get_model("django_etebase", "CollectionInvitation")
|
2020-09-07 08:02:40 +00:00
|
|
|
|
|
|
|
for member in CollectionMember.objects.all():
|
2020-11-14 15:04:41 +00:00
|
|
|
if member.accessLevelOld == "adm":
|
2020-09-07 08:02:40 +00:00
|
|
|
member.accessLevel = AccessLevels.ADMIN
|
2020-11-14 15:04:41 +00:00
|
|
|
elif member.accessLevelOld == "rw":
|
2020-09-07 08:02:40 +00:00
|
|
|
member.accessLevel = AccessLevels.READ_WRITE
|
2020-11-14 15:04:41 +00:00
|
|
|
elif member.accessLevelOld == "ro":
|
2020-09-07 08:02:40 +00:00
|
|
|
member.accessLevel = AccessLevels.READ_ONLY
|
|
|
|
member.save()
|
|
|
|
|
|
|
|
for invitation in CollectionInvitation.objects.all():
|
2020-11-14 15:04:41 +00:00
|
|
|
if invitation.accessLevelOld == "adm":
|
2020-09-07 08:02:40 +00:00
|
|
|
invitation.accessLevel = AccessLevels.ADMIN
|
2020-11-14 15:04:41 +00:00
|
|
|
elif invitation.accessLevelOld == "rw":
|
2020-09-07 08:02:40 +00:00
|
|
|
invitation.accessLevel = AccessLevels.READ_WRITE
|
2020-11-14 15:04:41 +00:00
|
|
|
elif invitation.accessLevelOld == "ro":
|
2020-09-07 08:02:40 +00:00
|
|
|
invitation.accessLevel = AccessLevels.READ_ONLY
|
|
|
|
invitation.save()
|
|
|
|
|
|
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
|
|
|
|
dependencies = [
|
2020-11-14 15:04:41 +00:00
|
|
|
("django_etebase", "0027_auto_20200907_0752"),
|
2020-09-07 08:02:40 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
operations = [
|
|
|
|
migrations.RunPython(change_access_level_to_int),
|
|
|
|
]
|