-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Landscape membership list #946
Closed
Closed
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
b961c36
refactor: Added membership_list to landscape
josebui 613e4d4
refactor: Create manager when landscape created
josebui 4033bc7
fix: Fixed manager test
josebui 1e81edb
refactor: User landscape manager
josebui 412ec33
refactor: Removed default landscape group from tests and GQL
josebui 70e4743
refactor: (WIP) landscape add membership tests
josebui 824216c
fix: Update landsacpe membership test
josebui d45fb2c
refactor: Delete landscape membership
josebui 17274d7
fix: delete and duplicated tests
josebui 0bf3e15
test: Added non members landscape membership test
josebui 6879646
fix: Anonymous user membership data
josebui 582557d
fix: Optional membership_list for landscapes
josebui 2e71137
refactor: Migration to copy landscape membership data to new model
josebui 03f0931
fix: Removed landscape default group from GQL
josebui 3e63f96
fix: Added enroll method to membership list node
josebui a98f13b
feat: Shared data files issue
josebui 118a339
fix: Renamed migration
josebui f9a9609
fix: Return landscape on membership delete
josebui 41de1b9
fix: Shared data landscape membership fixes
josebui ccf22ea
fix: Added landscape managers count
josebui e9a80b0
fix: User can join landscape
josebui a178128
fix: Added membership email filter to landscapes query
josebui 1fe84e2
fix: Added membership list to landscape admin
josebui 8deeda3
fix: Prefetch Landscape membership list data
josebui b9d550d
fix: Landscape membership count visible for anonymous users
josebui 35b862b
fix: Removed more default group references
josebui dfbf5e4
fix: Added distinct for landscapes query
josebui ae54343
Update terraso_backend/apps/graphql/schema/landscapes.py
josebui 63405d3
Update terraso_backend/apps/graphql/schema/landscapes.py
josebui f6fe2bd
Update terraso_backend/apps/graphql/schema/landscapes.py
josebui e4aecc0
Update terraso_backend/tests/graphql/mutations/test_landscape_members…
josebui 64de363
Update terraso_backend/apps/collaboration/graphql/memberships.py
josebui 52a15aa
fix: Fixed imports
josebui e939b42
fix: Linter fix
josebui File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
20 changes: 20 additions & 0 deletions
20
terraso_backend/apps/core/landscape_collaboration_roles.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,20 @@ | ||
# Copyright © 2023 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/. | ||
|
||
|
||
ROLE_MANAGER = "manager" | ||
ROLE_MEMBER = "member" | ||
|
||
ALL_ROLES = [ROLE_MANAGER, ROLE_MEMBER] |
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
71 changes: 71 additions & 0 deletions
71
terraso_backend/apps/core/migrations/0047_landscape_membership_list.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,71 @@ | ||
# Copyright © 2023 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 4.2.6 on 2023-10-10 20:45 | ||
|
||
import django.db.models.deletion | ||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
import apps.core.models.commons | ||
|
||
|
||
def copy_memberships(apps, schema_editor): | ||
Landscape = apps.get_model("core", "Landscape") | ||
MembershipList = apps.get_model("collaboration", "MembershipList") | ||
Membership = apps.get_model("collaboration", "Membership") | ||
landscapes = Landscape.objects.all() | ||
for landscape in landscapes: | ||
if not landscape.membership_list: | ||
landscape.membership_list = MembershipList.objects.create( | ||
enroll_method="both", | ||
membership_type="open", | ||
) | ||
landscape.save() | ||
default_group = landscape.associated_groups.filter(is_default_landscape_group=True).first() | ||
if not default_group: | ||
print(f"no default group for landscape {landscape.name}") | ||
continue | ||
current_memberships = default_group.group.memberships.filter( | ||
deleted_at__isnull=True | ||
).distinct("user") | ||
for membership in current_memberships: | ||
Membership.objects.create( | ||
membership_list=landscape.membership_list, | ||
user=membership.user, | ||
user_role=membership.user_role, | ||
membership_status=membership.membership_status, | ||
) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("collaboration", "0005_change_collaborator_to_editor"), | ||
("core", "0046_shared_resource"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="landscape", | ||
name="membership_list", | ||
field=models.ForeignKey( | ||
null=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="landscape", | ||
to="collaboration.membershiplist", | ||
), | ||
), | ||
migrations.RunPython(copy_memberships), | ||
] |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: what is this for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@paulschreiber The function using this default is the fucntion to save memberships, since the collaboration app doesn't have all the context to enforce the validation a function can be passed from the app using it to add the needed validation, if no function is passed this will be used by default