Skip to content
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

Complete and improve records API #270

Merged
merged 1 commit into from
Jun 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions cadasta/config/permissions/org-admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,37 @@
"action": ["org.*", "org.*.*", "project.*", "project.*.*"],
"object": ["organization/$organization"]
},

{
"effect": "allow",
"action": ["project.*", "project.*.*", "questionaire.*", "spatial.*", "resource.*"],
"action": ["project.*", "project.*.*", "questionaire.*", "resource.*",
"spatial.*", "spatial_rel.*", "party.*", "party_rel.*", "tenure_rel.*"],
"object": ["project/$organization/*"]
},

{
"effect": "allow",
"action": ["spatial.*"],
"object": ["spatial/$organization/*/*"]
},
{
"effect": "allow",
"action": ["spatial_rel.*"],
"object": ["spatial_rel/$organization/*/*"]
},
{
"effect": "allow",
"action": ["party.*"],
"object": ["party/$organization/*/*"]
},
{
"effect": "allow",
"action": ["party_rel.*"],
"object": ["party_rel/$organization/*/*"]
},
{
"effect": "allow",
"action": ["tenure_rel.*"],
"object": ["tenure_rel/$organization/*/*"]
},
{
"effect": "allow",
"action": ["resource.*"],
Expand Down
15 changes: 13 additions & 2 deletions cadasta/config/permissions/org-member.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,19 @@
// within an organization.
{
"effect": "allow",
"action": ["project.view_private", "spatial.view", "spatial.list"],
"object": ["project/$organization/*", "project/$organization/*/*"]
"action": ["project.view_private",
"spatial.list", "spatial.view",
"spatial_rel.list", "spatial_rel.view",
"party.list", "party.view",
"party_rel.list", "party_rel.view",
"tenure_rel.list", "tenure_rel.view"],
"object": ["project/$organization/*",
"project/$organization/*/*",
"spatial/$organization/*/*",
"spatial_rel/$organization/*/*",
"party/$organization/*/*",
"party_rel/$organization/*/*",
"tenure_rel/$organization/*/*"]
}
]
}
27 changes: 26 additions & 1 deletion cadasta/config/permissions/project-manager.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,34 @@
// organization.
{
"effect": "allow",
"action": ["project.*", "project.*.*", "questionaire.*", "spatial.*", "resource.*"],
"action": ["project.*", "project.*.*", "questionaire.*", "resource.*"],
"object": ["project/$organization/$project"]
},
{
"effect": "allow",
"action": ["spatial.*"],
"object": ["spatial/$organization/$project/*"]
},
{
"effect": "allow",
"action": ["spatial_rel.*"],
"object": ["spatial_rel/$organization/$project/*"]
},
{
"effect": "allow",
"action": ["party.*"],
"object": ["party/$organization/$project/*"]
},
{
"effect": "allow",
"action": ["party_rel.*"],
"object": ["party_rel/$organization/$project/*"]
},
{
"effect": "allow",
"action": ["tenure_rel.*"],
"object": ["tenure_rel/$organization/$project/*"]
},
{
"effect": "allow",
"action": ["resource.*"],
Expand Down
8 changes: 5 additions & 3 deletions cadasta/config/permissions/superuser.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@
"action": ["org.*", "org.*.*"],
"object": ["organization/*"]
},

{
"effect": "allow",
"action": ["project.*", "project.*.*"],
"object": ["organization/*"]
},
{
"effect": "allow",
"action": ["project.*", "project.*.*", "spatial.*", "resource.*"],
"object": ["project/*/*"]
"action": ["project.*", "project.*.*", "resource.*",
"spatial.*", "spatial_rel.*",
"party.*", "party_rel.*", "tenure_rel.*"],
"object": ["project/*/*", "spatial/*/*/*", "spatial_rel/*/*/*",
"party/*/*/*", "party_rel/*/*/*", "tenure_rel/*/*/*"]
},
{
"effect": "allow",
Expand Down
3 changes: 1 addition & 2 deletions cadasta/config/settings/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,7 @@

JSONATTRS_SCHEMA_SELECTORS = {
'spatial.spatialunit': ('project.organization.pk', 'project.pk',),
'spatial.spatialunitrelationship': (
'project.organization.pk', 'project.pk',),
'spatial.spatialrelationship': ('project.organization.pk', 'project.pk',),
'party.party': ('project.organization.pk', 'project.pk',),
'party.partyrelationship': ('project.organization.pk', 'project.pk',),
'party.tenurerelationship': ('project.organization.pk', 'project.pk',)
Expand Down
4 changes: 4 additions & 0 deletions cadasta/config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
'(?P<project_id>[-\w]+)/parties/',
include('party.urls.api.parties',
namespace='party')),
url(r'^organizations/(?P<organization>[-\w]+)/projects/'
'(?P<project_id>[-\w]+)/relationships/',
include('party.urls.api.relationships',
namespace='relationship')),
]

api = [
Expand Down
6 changes: 3 additions & 3 deletions cadasta/core/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from organization.models import Organization, OrganizationRole, Project
from organization.tests.factories import OrganizationFactory, ProjectFactory
from spatial.tests.factories import (SpatialUnitFactory,
SpatialUnitRelationshipFactory)
SpatialRelationshipFactory)
from tutelary.models import Policy, PolicyInstance, Role, RolePolicyAssign


Expand Down Expand Up @@ -334,7 +334,7 @@ def add_test_spatial_units(self):
type='AP',
attributes={"testing": "attributes"})

SpatialUnitRelationshipFactory(
SpatialRelationshipFactory(
su1=su1, su2=su2, type='C', project=project)

su3 = SpatialUnitFactory(
Expand All @@ -361,7 +361,7 @@ def add_test_spatial_units(self):
type='PA',
attributes={"testing": "attributes"})

SpatialUnitRelationshipFactory(
SpatialRelationshipFactory(
su1=su3, su2=su4, type='C', project=project)

SpatialUnitFactory(
Expand Down
6 changes: 3 additions & 3 deletions cadasta/core/tests/test_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from tutelary.models import Policy
from accounts.models import User
from organization.models import Organization, Project
from spatial.models import SpatialUnit, SpatialUnitRelationship
from spatial.models import SpatialUnit, SpatialRelationship


class FixturesTest(TestCase):
Expand All @@ -25,7 +25,7 @@ def test_fixture_setup(self):
assert Organization.objects.count() == 2
assert Project.objects.count() == 9
assert SpatialUnit.objects.count() == 7
assert SpatialUnitRelationship.objects.count() == 2
assert SpatialRelationship.objects.count() == 2

data.delete_test_users()
data.delete_test_organizations()
Expand All @@ -35,4 +35,4 @@ def test_fixture_setup(self):
assert Organization.objects.count() == 0
assert Project.objects.count() == 0
assert SpatialUnit.objects.count() == 0
assert SpatialUnitRelationship.objects.count() == 0
assert SpatialRelationship.objects.count() == 0
37 changes: 33 additions & 4 deletions cadasta/party/messages.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
from django.utils.translation import ugettext as _

PARTY_VIEW = _("You don't have permission to access this party")
PARTY_EDIT = _("You don't have permission to update this party")
PARTY_ARCHIVE = _("You don't have permission to archive this party")
PARTY_UNARCHIVE = _("You don't have permission to unarchive this party")

PARTY_LIST = _(
"You don't have permission to view parties of this project.")
PARTY_CREATE = _(
"You don't have permission to add parties to this project.")
PARTY_VIEW = _(
"You don't have permission to view this party.")
PARTY_UPDATE = _(
"You don't have permission to update this party.")
PARTY_DELETE = _(
"You don't have permission to remove this party.")

PARTY_REL_LIST = _(
"You don't have permission to view party relationships of this project.")
PARTY_REL_CREATE = _(
"You don't have permission to add party relationships to this project.")
PARTY_REL_VIEW = _(
"You don't have permission to view this party relationship.")
PARTY_REL_UPDATE = _(
"You don't have permission to update this party relationship.")
PARTY_REL_DELETE = _(
"You don't have permission to remove this party relationship.")

TENURE_REL_LIST = _(
"You don't have permission to view tenure relationships of this project.")
TENURE_REL_CREATE = _(
"You don't have permission to add tenure relationships to this project.")
TENURE_REL_VIEW = _(
"You don't have permission to view this tenure relationship.")
TENURE_REL_UPDATE = _(
"You don't have permission to update this tenure relationship.")
TENURE_REL_DELETE = _(
"You don't have permission to remove this tenure relationship.")
Loading