-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
704 additions
and
23 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
66 changes: 66 additions & 0 deletions
66
terraso_backend/apps/core/migrations/0049_sharedresource_share_fields.py
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,66 @@ | ||
# Copyright © 2024 Technology Matters | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published | ||
# by the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see https://www.gnu.org/licenses/. | ||
|
||
# Generated by Django 5.0 on 2024-01-08 15:59 | ||
|
||
import uuid | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
|
||
def fill_shared_uuid(apps, schema_editor): | ||
SharedResource = apps.get_model("core", "SharedResource") | ||
shared_resources = SharedResource.objects.all() | ||
for shared_resource in shared_resources: | ||
shared_resource.share_uuid = uuid.uuid4() | ||
SharedResource.objects.bulk_update(shared_resources, ["share_uuid"]) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("core", "0048_group_membership_list"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="sharedresource", | ||
name="share_access", | ||
field=models.CharField( | ||
choices=[ | ||
("no", "No share access"), | ||
("all", "Anyone with the link"), | ||
("target_members", "Only tagert members"), | ||
], | ||
default="no", | ||
max_length=32, | ||
), | ||
), | ||
migrations.AddField( | ||
model_name="sharedresource", | ||
name="share_uuid", | ||
field=models.UUIDField(default=uuid.uuid4), | ||
preserve_default=False, | ||
), | ||
migrations.RunPython(fill_shared_uuid), | ||
migrations.AddConstraint( | ||
model_name="sharedresource", | ||
constraint=models.UniqueConstraint( | ||
condition=models.Q(("deleted_at__isnull", True)), | ||
fields=("share_uuid",), | ||
name="unique_share_uuid", | ||
), | ||
), | ||
] |
40 changes: 40 additions & 0 deletions
40
terraso_backend/apps/core/migrations/0050_sharedresource_remove_none.py
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,40 @@ | ||
# Copyright © 2024 Technology Matters | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published | ||
# by the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see https://www.gnu.org/licenses/. | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("core", "0049_sharedresource_share_fields"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunSQL( | ||
sql="UPDATE core_sharedresource SET share_access ='target_members' WHERE share_access='no';" | ||
), | ||
migrations.AlterField( | ||
model_name="sharedresource", | ||
name="share_access", | ||
field=models.CharField( | ||
choices=[ | ||
("all", "Anyone with the link"), | ||
("target_members", "Only target members"), | ||
], | ||
default="target_members", | ||
max_length=32, | ||
), | ||
), | ||
] |
29 changes: 29 additions & 0 deletions
29
terraso_backend/apps/core/migrations/0051_sharedresource_renamed_target_members.py
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,29 @@ | ||
# Copyright © 2024 Technology Matters | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published | ||
# by the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see https://www.gnu.org/licenses/. | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("core", "0050_sharedresource_remove_none"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunSQL( | ||
sql="UPDATE core_sharedresource SET share_access ='members' WHERE share_access='target_members';" | ||
), | ||
] |
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
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
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
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
Oops, something went wrong.