Skip to content

Commit

Permalink
Public user project roles are not create with new project
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverroick committed May 19, 2017
1 parent 1c93912 commit d2d4e19
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
22 changes: 22 additions & 0 deletions cadasta/organization/migrations/0004_remove_Pb_project_roles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2017-05-19 08:14
from __future__ import unicode_literals

from django.db import migrations


def remove_public_user_role(apps, schema_editor):
ProjectRole = apps.get_model("organization", "ProjectRole")
ProjectRole.objects.filter(role='Pb').delete()


class Migration(migrations.Migration):

dependencies = [
('organization', '0003_add_organizationrole_unique'),
]

operations = [
migrations.RunPython(
remove_public_user_role, migrations.RunPython.noop),
]
7 changes: 5 additions & 2 deletions cadasta/organization/tests/test_views_default_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,11 +487,12 @@ def setUp(self):
{'username': 'org_member_1'},
{'username': 'org_member_2'},
{'username': 'org_member_3'},
{'username': 'org_member_4'},
{'username': 'org_non_member_1'},
{'username': 'org_non_member_2'},
{'username': 'org_non_member_3'},
{'username': 'org_non_member_4'}])
for idx in range(5):
for idx in range(6):
OrganizationRole.objects.create(organization=self.org,
user=self.users[idx],
admin=(idx < 2))
Expand Down Expand Up @@ -594,13 +595,15 @@ def _get_xls_form(self, form_name):
'project_add_wizard-current_step': 'permissions',
'permissions-org_member_1': 'PM',
'permissions-org_member_2': 'DC',
'permissions-org_member_3': 'PU'
'permissions-org_member_3': 'PU',
'permissions-org_member_4': 'Pb'
}
PERMISSIONS_POST_DATA_BAD = {
'project_add_wizard-current_step': 'permissions',
'permissions-org_member_1': 'PM',
'permissions-org_member_2': 'DC',
'permissions-org_member_3': 'PU',
'permissions-org_member_4': 'Pb',
'permissions-bad_user': 'PU'
}
DETAILS_POST_DATA_MANIPULATED = {
Expand Down
2 changes: 1 addition & 1 deletion cadasta/organization/views/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ def done(self, form_list, form_dict, **kwargs):
user_roles = []
for user in org.users.all():
role = form_data[2].get(user.username, None)
if role:
if role and role != 'Pb':
user_roles.append((user, role))
try:
with transaction.atomic():
Expand Down

0 comments on commit d2d4e19

Please sign in to comment.