diff --git a/cadasta/organization/tests/test_urls_api.py b/cadasta/organization/tests/test_urls_api.py index c7fe24839..b41fb098a 100644 --- a/cadasta/organization/tests/test_urls_api.py +++ b/cadasta/organization/tests/test_urls_api.py @@ -36,6 +36,11 @@ def test_organization_users_detail(self): kwargs={'slug': 'org-slug', 'username': 'n_smith'}) == version_url('/organizations/org-slug/users/n_smith/')) + assert (reverse(version_ns('organization:users_detail'), + kwargs={'slug': 'org-slug', + 'username': 'n_smith-@+.'}) == + version_url('/organizations/org-slug/users/n_smith-@+./')) + resolved = resolve( version_url('/organizations/org-slug/users/n_smith/')) @@ -43,6 +48,13 @@ def test_organization_users_detail(self): assert resolved.kwargs['slug'] == 'org-slug' assert resolved.kwargs['username'] == 'n_smith' + resolved = resolve( + version_url('/organizations/org-slug/users/n_smith-@+./')) + + assert resolved.func.__name__ == api.OrganizationUsersDetail.__name__ + assert resolved.kwargs['slug'] == 'org-slug' + assert resolved.kwargs['username'] == 'n_smith-@+.' + class ProjectUrlTest(TestCase): @@ -96,9 +108,26 @@ def test_project_users_detail(self): '/organizations/habitat/projects/123abc/users/barbara/') assert actual == expected + actual = reverse( + version_ns('organization:project_users_detail'), + kwargs={'organization': 'habitat', + 'project': '123abc', + 'username': 'barbara-@+.'} + ) + expected = version_url( + '/organizations/habitat/projects/123abc/users/barbara-@+./') + assert actual == expected + resolved = resolve(version_url( '/organizations/habitat/projects/123abc/users/barbara/')) assert resolved.func.__name__ == api.ProjectUsersDetail.__name__ assert resolved.kwargs['organization'] == 'habitat' assert resolved.kwargs['project'] == '123abc' assert resolved.kwargs['username'] == 'barbara' + + resolved = resolve(version_url( + '/organizations/habitat/projects/123abc/users/barbara-@+./')) + assert resolved.func.__name__ == api.ProjectUsersDetail.__name__ + assert resolved.kwargs['organization'] == 'habitat' + assert resolved.kwargs['project'] == '123abc' + assert resolved.kwargs['username'] == 'barbara-@+.' diff --git a/cadasta/organization/tests/test_urls_default.py b/cadasta/organization/tests/test_urls_default.py index 29a5aac0c..19a68fb6c 100644 --- a/cadasta/organization/tests/test_urls_default.py +++ b/cadasta/organization/tests/test_urls_default.py @@ -70,11 +70,19 @@ def test_user_activate(self): url = reverse('user:activate', kwargs={'user': 'user-name'}) assert (url == '/users/user-name/activate/') + url = reverse('user:activate', kwargs={'user': 'user-name-with-+@.'}) + assert (url == '/users/user-name-with-+@./activate/') + resolved = resolve('/users/user-name/activate/') assert resolved.func.__name__ == default.UserActivation.__name__ assert resolved.kwargs['user'] == 'user-name' assert resolved.func.view_initkwargs['new_state'] is True + resolved = resolve('/users/user-name-with-+@./activate/') + assert resolved.func.__name__ == default.UserActivation.__name__ + assert resolved.kwargs['user'] == 'user-name-with-+@.' + assert resolved.func.view_initkwargs['new_state'] is True + def test_user_deactivate(self): url = reverse('user:deactivate', kwargs={'user': 'user-name'}) assert (url == '/users/user-name/deactivate/') @@ -205,12 +213,26 @@ def test_member_edit(self): ) assert url == '/organizations/org-slug/members/some-user/' + url = reverse( + 'organization:members_edit', + kwargs={'slug': 'org-slug', 'username': 'some-user-with-+@.'} + ) + assert url == '/organizations/org-slug/members/some-user-with-+@./' + resolved = resolve('/organizations/org-slug/members/some-user/') assert (resolved.func.__name__ == default.OrganizationMembersEdit.__name__) assert resolved.kwargs['slug'] == 'org-slug' assert resolved.kwargs['username'] == 'some-user' + resolved = resolve( + '/organizations/org-slug/members/some-user-with-+@./' + ) + assert (resolved.func.__name__ == + default.OrganizationMembersEdit.__name__) + assert resolved.kwargs['slug'] == 'org-slug' + assert resolved.kwargs['username'] == 'some-user-with-+@.' + def test_member_remove(self): url = reverse( 'organization:members_remove', @@ -218,8 +240,23 @@ def test_member_remove(self): ) assert url == '/organizations/org-slug/members/some-user/remove/' + url = reverse( + 'organization:members_remove', + kwargs={'slug': 'org-slug', 'username': 'some-user-with-+@.'} + ) + assert (url == + '/organizations/org-slug/members/some-user-with-+@./remove/') + resolved = resolve('/organizations/org-slug/members/some-user/remove/') assert (resolved.func.__name__ == default.OrganizationMembersRemove.__name__) assert resolved.kwargs['slug'] == 'org-slug' assert resolved.kwargs['username'] == 'some-user' + + resolved = resolve( + '/organizations/org-slug/members/some-user-with-+@./remove/' + ) + assert (resolved.func.__name__ == + default.OrganizationMembersRemove.__name__) + assert resolved.kwargs['slug'] == 'org-slug' + assert resolved.kwargs['username'] == 'some-user-with-+@.' diff --git a/cadasta/organization/urls/api/organizations.py b/cadasta/organization/urls/api/organizations.py index 7538544c6..ed56a2310 100644 --- a/cadasta/organization/urls/api/organizations.py +++ b/cadasta/organization/urls/api/organizations.py @@ -16,7 +16,7 @@ api.OrganizationUsers.as_view(), name='users'), url( - r'^(?P[-\w]+)/users/(?P[-\w]+)/$', + r'^(?P[-\w]+)/users/(?P[-@+.\w]+)/$', api.OrganizationUsersDetail.as_view(), name='users_detail'), url( @@ -33,7 +33,7 @@ name='project_users'), url( r'^(?P[-\w]+)/projects/' - '(?P[-\w]+)/users/(?P[-\w]+)/$', + '(?P[-\w]+)/users/(?P[-@+.\w]+)/$', api.ProjectUsersDetail.as_view(), name='project_users_detail'), ] diff --git a/cadasta/organization/urls/default/organizations.py b/cadasta/organization/urls/default/organizations.py index f70bf8db9..1fce091af 100644 --- a/cadasta/organization/urls/default/organizations.py +++ b/cadasta/organization/urls/default/organizations.py @@ -79,11 +79,11 @@ default.OrganizationMembersAdd.as_view(), name='members_add'), url( - r'^(?P[-\w]+)/members/(?P[-\w]+)/$', + r'^(?P[-\w]+)/members/(?P[-@+.\w]+)/$', default.OrganizationMembersEdit.as_view(), name='members_edit'), url( - r'^(?P[-\w]+)/members/(?P[-\w]+)/remove/$', + r'^(?P[-\w]+)/members/(?P[-@+.\w]+)/remove/$', default.OrganizationMembersRemove.as_view(), name='members_remove'), ] diff --git a/cadasta/organization/urls/default/users.py b/cadasta/organization/urls/default/users.py index d378a79e5..d8c0c3c48 100644 --- a/cadasta/organization/urls/default/users.py +++ b/cadasta/organization/urls/default/users.py @@ -4,10 +4,10 @@ urlpatterns = [ url(r'^$', default.UserList.as_view(), name='list'), - url(r'^(?P[-\w]+)/activate/$', + url(r'^(?P[-@+.\w]+)/activate/$', default.UserActivation.as_view(new_state=True), name='activate'), - url(r'^(?P[-\w]+)/deactivate/$', + url(r'^(?P[-@+.\w]+)/deactivate/$', default.UserActivation.as_view(new_state=False), name='deactivate') ]