diff --git a/compose/django/Dockerfile b/compose/django/Dockerfile index d84436c4..c1e14c52 100644 --- a/compose/django/Dockerfile +++ b/compose/django/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.10-slim +FROM python:3.10-slim AS neurovault ENV PYTHONUNBUFFERED 1 ENV PYTHONDONTWRITEBYTECODE 1 @@ -10,6 +10,54 @@ RUN apt-get update && apt-get install --no-install-recommends -y \ libpq-dev \ git +RUN apt-get -y update \ + && apt-get install -y wget subversion && \ + wget -qO- ftp://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/6.0.0/freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.0.tar.gz | tar zxv -C /opt \ + --exclude='freesurfer/trctrain' \ + --exclude='freesurfer/subjects/fsaverage_sym' \ + --exclude='freesurfer/subjects/fsaverage3' \ + --exclude='freesurfer/subjects/fsaverage4' \ + --exclude='freesurfer/subjects/fsaverage5' \ + --exclude='freesurfer/subjects/fsaverage6' \ + --exclude='freesurfer/subjects/cvs_avg35' \ + --exclude='freesurfer/subjects/cvs_avg35_inMNI152' \ + --exclude='freesurfer/subjects/bert' \ + --exclude='freesurfer/subjects/V1_average' \ + --exclude='freesurfer/average/mult-comp-cor' \ + --exclude='freesurfer/lib/cuda' \ + --exclude='freesurfer/lib/qt' && \ + apt-get install -y tcsh bc tar libgomp1 perl-modules curl && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +# Set up the environment +ENV OS Linux +ENV FS_OVERRIDE 0 +ENV FIX_VERTEX_AREA= +ENV SUBJECTS_DIR /opt/freesurfer/subjects +ENV FSF_OUTPUT_FORMAT nii.gz +ENV MNI_DIR /opt/freesurfer/mni +ENV LOCAL_DIR /opt/freesurfer/local +ENV FREESURFER_HOME /opt/freesurfer +ENV FSFAST_HOME /opt/freesurfer/fsfast +ENV MINC_BIN_DIR /opt/freesurfer/mni/bin +ENV MINC_LIB_DIR /opt/freesurfer/mni/lib +ENV MNI_DATAPATH /opt/freesurfer/mni/data +ENV FMRI_ANALYSIS_DIR /opt/freesurfer/fsfast +ENV PERL5LIB /opt/freesurfer/mni/lib/perl5/5.8.5 +ENV MNI_PERL5LIB /opt/freesurfer/mni/lib/perl5/5.8.5 +ENV PATH /opt/freesurfer/bin:/opt/freesurfer/fsfast/bin:/opt/freesurfer/tktools:/opt/freesurfer/mni/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH +RUN echo "cHJpbnRmICJrcnp5c3p0b2YuZ29yZ29sZXdza2lAZ21haWwuY29tXG41MTcyXG4gKkN2dW12RVYzelRmZ1xuRlM1Si8yYzFhZ2c0RVxuIiA+IC9vcHQvZnJlZXN1cmZlci9saWNlbnNlLnR4dAo=" | base64 -d | sh + +RUN svn export --force https://github.com/NeuroVault/neurovault_data/trunk/pycortex_datastore /usr/local/share/pycortex/ +RUN apt-get update && apt-get -y install tcsh libglu1-mesa libxmu6 +RUN /opt/freesurfer/bin/mri_convert /opt/freesurfer/subjects/fsaverage/mri/brain.mgz /opt/freesurfer/subjects/fsaverage/mri/brain.nii.gz +RUN mkdir /usr/local/share/pycortex/db/fsaverage/transforms/ +RUN pip install tornado + +RUN apt-get update && apt-get -y install zip +RUN wget https://ndownloader.figshare.com/files/6891069 -O icbm.zip && unzip icbm.zip -d /opt/freesurfer/subjects/ && rm icbm.zip + COPY ./compose/django/requirements.txt requirements.txt RUN pip install -r requirements.txt diff --git a/compose/django/Dockerfile_fs b/compose/django/Dockerfile_fs deleted file mode 100644 index aa724fda..00000000 --- a/compose/django/Dockerfile_fs +++ /dev/null @@ -1,49 +0,0 @@ -FROM neurovault/neurovault - -RUN apt-get -y update \ - && apt-get install -y wget subversion && \ - wget -qO- ftp://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/6.0.0/freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.0.tar.gz | tar zxv -C /opt \ - --exclude='freesurfer/trctrain' \ - --exclude='freesurfer/subjects/fsaverage_sym' \ - --exclude='freesurfer/subjects/fsaverage3' \ - --exclude='freesurfer/subjects/fsaverage4' \ - --exclude='freesurfer/subjects/fsaverage5' \ - --exclude='freesurfer/subjects/fsaverage6' \ - --exclude='freesurfer/subjects/cvs_avg35' \ - --exclude='freesurfer/subjects/cvs_avg35_inMNI152' \ - --exclude='freesurfer/subjects/bert' \ - --exclude='freesurfer/subjects/V1_average' \ - --exclude='freesurfer/average/mult-comp-cor' \ - --exclude='freesurfer/lib/cuda' \ - --exclude='freesurfer/lib/qt' && \ - apt-get install -y tcsh bc tar libgomp1 perl-modules curl && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* - -# Set up the environment -ENV OS Linux -ENV FS_OVERRIDE 0 -ENV FIX_VERTEX_AREA= -ENV SUBJECTS_DIR /opt/freesurfer/subjects -ENV FSF_OUTPUT_FORMAT nii.gz -ENV MNI_DIR /opt/freesurfer/mni -ENV LOCAL_DIR /opt/freesurfer/local -ENV FREESURFER_HOME /opt/freesurfer -ENV FSFAST_HOME /opt/freesurfer/fsfast -ENV MINC_BIN_DIR /opt/freesurfer/mni/bin -ENV MINC_LIB_DIR /opt/freesurfer/mni/lib -ENV MNI_DATAPATH /opt/freesurfer/mni/data -ENV FMRI_ANALYSIS_DIR /opt/freesurfer/fsfast -ENV PERL5LIB /opt/freesurfer/mni/lib/perl5/5.8.5 -ENV MNI_PERL5LIB /opt/freesurfer/mni/lib/perl5/5.8.5 -ENV PATH /opt/freesurfer/bin:/opt/freesurfer/fsfast/bin:/opt/freesurfer/tktools:/opt/freesurfer/mni/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH -RUN echo "cHJpbnRmICJrcnp5c3p0b2YuZ29yZ29sZXdza2lAZ21haWwuY29tXG41MTcyXG4gKkN2dW12RVYzelRmZ1xuRlM1Si8yYzFhZ2c0RVxuIiA+IC9vcHQvZnJlZXN1cmZlci9saWNlbnNlLnR4dAo=" | base64 -d | sh - -RUN svn export --force https://github.com/NeuroVault/neurovault_data/trunk/pycortex_datastore /usr/local/share/pycortex/ -RUN apt-get update && apt-get -y install tcsh libglu1-mesa libxmu6 -RUN /opt/freesurfer/bin/mri_convert /opt/freesurfer/subjects/fsaverage/mri/brain.mgz /opt/freesurfer/subjects/fsaverage/mri/brain.nii.gz -RUN mkdir /usr/local/share/pycortex/db/fsaverage/transforms/ -RUN pip install tornado - -RUN apt-get update && apt-get -y install zip -RUN wget https://ndownloader.figshare.com/files/6891069 -O icbm.zip && unzip icbm.zip -d /opt/freesurfer/subjects/ && rm icbm.zip diff --git a/compose/django/Dockerfile_multi b/compose/django/Dockerfile_multi deleted file mode 100644 index 631d55f6..00000000 --- a/compose/django/Dockerfile_multi +++ /dev/null @@ -1,68 +0,0 @@ -FROM python:3.10-slim AS neurovault - -ENV PYTHONUNBUFFERED 1 -ENV PYTHONDONTWRITEBYTECODE 1 - -RUN apt-get update && apt-get install --no-install-recommends -y \ - # dependencies for building Python packages - build-essential \ - # psycopg2 dependencies - libpq-dev \ - git - -COPY ./compose/django/requirements.txt requirements.txt -RUN pip install -r requirements.txt - -WORKDIR /code - -EXPOSE 8000 - -FROM neurovault AS neurovault_fs - -RUN apt-get -y update \ - && apt-get install -y wget subversion && \ - wget -qO- ftp://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/6.0.0/freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.0.tar.gz | tar zxv -C /opt \ - --exclude='freesurfer/trctrain' \ - --exclude='freesurfer/subjects/fsaverage_sym' \ - --exclude='freesurfer/subjects/fsaverage3' \ - --exclude='freesurfer/subjects/fsaverage4' \ - --exclude='freesurfer/subjects/fsaverage5' \ - --exclude='freesurfer/subjects/fsaverage6' \ - --exclude='freesurfer/subjects/cvs_avg35' \ - --exclude='freesurfer/subjects/cvs_avg35_inMNI152' \ - --exclude='freesurfer/subjects/bert' \ - --exclude='freesurfer/subjects/V1_average' \ - --exclude='freesurfer/average/mult-comp-cor' \ - --exclude='freesurfer/lib/cuda' \ - --exclude='freesurfer/lib/qt' && \ - apt-get install -y tcsh bc tar libgomp1 perl-modules curl && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* - -# Set up the environment -ENV OS Linux -ENV FS_OVERRIDE 0 -ENV FIX_VERTEX_AREA= -ENV SUBJECTS_DIR /opt/freesurfer/subjects -ENV FSF_OUTPUT_FORMAT nii.gz -ENV MNI_DIR /opt/freesurfer/mni -ENV LOCAL_DIR /opt/freesurfer/local -ENV FREESURFER_HOME /opt/freesurfer -ENV FSFAST_HOME /opt/freesurfer/fsfast -ENV MINC_BIN_DIR /opt/freesurfer/mni/bin -ENV MINC_LIB_DIR /opt/freesurfer/mni/lib -ENV MNI_DATAPATH /opt/freesurfer/mni/data -ENV FMRI_ANALYSIS_DIR /opt/freesurfer/fsfast -ENV PERL5LIB /opt/freesurfer/mni/lib/perl5/5.8.5 -ENV MNI_PERL5LIB /opt/freesurfer/mni/lib/perl5/5.8.5 -ENV PATH /opt/freesurfer/bin:/opt/freesurfer/fsfast/bin:/opt/freesurfer/tktools:/opt/freesurfer/mni/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH -RUN echo "cHJpbnRmICJrcnp5c3p0b2YuZ29yZ29sZXdza2lAZ21haWwuY29tXG41MTcyXG4gKkN2dW12RVYzelRmZ1xuRlM1Si8yYzFhZ2c0RVxuIiA+IC9vcHQvZnJlZXN1cmZlci9saWNlbnNlLnR4dAo=" | base64 -d | sh - -RUN svn export --force https://github.com/NeuroVault/neurovault_data/trunk/pycortex_datastore /usr/local/share/pycortex/ -RUN apt-get update && apt-get -y install tcsh libglu1-mesa libxmu6 -RUN /opt/freesurfer/bin/mri_convert /opt/freesurfer/subjects/fsaverage/mri/brain.mgz /opt/freesurfer/subjects/fsaverage/mri/brain.nii.gz -RUN mkdir /usr/local/share/pycortex/db/fsaverage/transforms/ -RUN pip install tornado - -RUN apt-get update && apt-get -y install zip -RUN wget https://ndownloader.figshare.com/files/6891069 -O icbm.zip && unzip icbm.zip -d /opt/freesurfer/subjects/ && rm icbm.zip diff --git a/docker-compose.yml b/docker-compose.yml index 593cfd22..59a95de0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,9 +4,9 @@ services: restart: always build: context: . - dockerfile: ./compose/django/Dockerfile_multi - target: neurovault_fs - image: neurovault/neurovault_fs + dockerfile: ./compose/django/Dockerfile + target: neurovault + image: neurovault/neurovault command: python manage.py runserver 0.0.0.0:8000 ports: - "8000:8000" @@ -35,7 +35,7 @@ services: worker: build: context: . - dockerfile: ./compose/django/Dockerfile_multi + dockerfile: ./compose/django/Dockerfile target: neurovault image: neurovault/neurovault command: celery -A neurovault.celery worker -Q default -n default@%h diff --git a/neurovault/apps/statmaps/tests/test_data/statmaps/saccade.I_C.MNI__SetA_Tstat.nii.gz b/neurovault/apps/statmaps/tests/test_data/statmaps/saccade.I_C.MNI__SetA_Tstat.nii.gz deleted file mode 100644 index 369cd493..00000000 Binary files a/neurovault/apps/statmaps/tests/test_data/statmaps/saccade.I_C.MNI__SetA_Tstat.nii.gz and /dev/null differ diff --git a/neurovault/apps/statmaps/tests/test_data/statmaps/saccade.I_C.MNI__SetA_mean.nii.gz b/neurovault/apps/statmaps/tests/test_data/statmaps/saccade.I_C.MNI__SetA_mean.nii.gz deleted file mode 100644 index 7e4c4134..00000000 Binary files a/neurovault/apps/statmaps/tests/test_data/statmaps/saccade.I_C.MNI__SetA_mean.nii.gz and /dev/null differ diff --git a/neurovault/apps/users/forms.py b/neurovault/apps/users/forms.py index 98ea77de..25ab2ffc 100644 --- a/neurovault/apps/users/forms.py +++ b/neurovault/apps/users/forms.py @@ -2,7 +2,6 @@ from django.contrib.auth.models import User from django.contrib.auth.forms import UserCreationForm from django.utils.translation import gettext_lazy as _ -from oauth2_provider.models import Application class UserCreateForm(UserCreationForm): @@ -57,18 +56,3 @@ def save(self, commit=True): def clean_password(self): return "" - - -class ApplicationEditForm(forms.ModelForm): - name = forms.CharField(required=True) - - class Meta: - model = Application - fields = ( - "name", - "client_id", - "client_secret", - "client_type", - "authorization_grant_type", - "redirect_uris", - ) diff --git a/neurovault/apps/users/migrations/0001_initial.py b/neurovault/apps/users/migrations/0001_initial.py index 56eb50ea..97d049fd 100644 --- a/neurovault/apps/users/migrations/0001_initial.py +++ b/neurovault/apps/users/migrations/0001_initial.py @@ -5,12 +5,15 @@ def create_default_app(apps, schema_editor): + ''' Application = apps.get_registered_model("oauth2_provider", "Application") Application.objects.get_or_create( name=settings.DEFAULT_OAUTH_APP_NAME, redirect_uris=["http://localhost"], pk=settings.DEFAULT_OAUTH_APPLICATION_ID, ) + ''' + pass class Migration(migrations.Migration): diff --git a/neurovault/apps/users/templates/base_settings.html b/neurovault/apps/users/templates/base_settings.html index 4982cc0a..c44c17c9 100644 --- a/neurovault/apps/users/templates/base_settings.html +++ b/neurovault/apps/users/templates/base_settings.html @@ -15,12 +15,6 @@
{{ application.name }}
- -Name | -Client ID | -
---|---|
{{ application.name }} - | -- {{ application.client_id }} - | -
Developer applications are used for enhanced access to the NeuroVault API.
-Register an application to get started.
-{{ error.description }}
- {% endif %} -{{ object.name }} will no longer be able to access your account on your behalf.
- -Name | -Owner | -- |
---|---|---|
{{ rt.application.name }} | -- {{ rt.application.user.username }} - | -Revoke access - | -
You have no applications authorized to access your account on your behalf via NeuroVault API.
-Any applications or scripts using this token will no longer be able to access the NeuroVault API.
- -Token | -- |
---|---|
{{ token.token }} | -Delete - | -
Personal access tokens are used to access your account via the NeuroVault API.
-{{ token }}+
+ Regenerate Token
+{% endblock %}
diff --git a/neurovault/apps/users/tests/test_application_views.py b/neurovault/apps/users/tests/test_application_views.py
deleted file mode 100644
index 31ae1459..00000000
--- a/neurovault/apps/users/tests/test_application_views.py
+++ /dev/null
@@ -1,93 +0,0 @@
-from django.test import TestCase
-from django.contrib.auth import get_user_model
-from django.urls import reverse
-
-from oauth2_provider.models import Application
-
-UserModel = get_user_model()
-
-
-class BaseTest(TestCase):
- def setUp(self):
- self.user_password = "random"
- self.user = UserModel.objects.create_user(
- "neurouser", "neurouser@example.com", self.user_password
- )
-
- def tearDown(self):
- self.user.delete()
-
-
-class TestApplicationRegistrationView(BaseTest):
- def test_application_registration_user(self):
- self.client.login(username=self.user.username, password=self.user_password)
-
- form_data = {
- "name": "Random App",
- "client_id": "client_id",
- "client_secret": "client_secret",
- "client_type": Application.CLIENT_CONFIDENTIAL,
- "redirect_uris": "http://example.com",
- "authorization_grant_type": Application.GRANT_AUTHORIZATION_CODE,
- }
-
- response = self.client.post(reverse("users:developerapps_register"), form_data)
- self.assertEqual(response.status_code, 302)
-
- app = Application.objects.get(name="Random App")
- self.assertEqual(app.user.username, self.user.username)
-
-
-class TestApplicationViews(BaseTest):
- def _create_application(self, name, user):
- app = Application.objects.create(
- name=name,
- redirect_uris="http://example.com",
- client_type=Application.CLIENT_CONFIDENTIAL,
- authorization_grant_type=Application.GRANT_AUTHORIZATION_CODE,
- user=user,
- )
- return app
-
- def setUp(self):
- super(TestApplicationViews, self).setUp()
- self.app = self._create_application("app 1", self.user)
-
- def tearDown(self):
- super(TestApplicationViews, self).tearDown()
- self.app.delete()
-
- def test_application_list(self):
- self.client.login(username=self.user.username, password=self.user_password)
-
- response = self.client.get(reverse("users:developerapps_list"))
- self.assertEqual(response.status_code, 200)
- self.assertEqual(len(response.context["object_list"]), 1)
-
- def test_application_detail(self):
- self.client.login(username=self.user.username, password=self.user_password)
-
- response = self.client.get(
- reverse("users:developerapps_update", args=(self.app.pk,))
- )
- self.assertEqual(response.status_code, 200)
-
- def test_application_update(self):
- self.client.login(username=self.user.username, password=self.user_password)
-
- form_data = {
- "name": "Changed App",
- "client_id": "client_id",
- "client_secret": "client_secret",
- "client_type": Application.CLIENT_CONFIDENTIAL,
- "redirect_uris": "http://example.com",
- "authorization_grant_type": Application.GRANT_AUTHORIZATION_CODE,
- }
-
- response = self.client.post(
- reverse("users:developerapps_update", args=(self.app.pk,)), form_data
- )
- self.assertEqual(response.status_code, 302)
-
- app = Application.objects.get(name="Changed App")
- self.assertEqual(app.user.username, self.user.username)
diff --git a/neurovault/apps/users/tests/test_oauth.py b/neurovault/apps/users/tests/test_oauth.py
deleted file mode 100644
index 63741fa0..00000000
--- a/neurovault/apps/users/tests/test_oauth.py
+++ /dev/null
@@ -1,67 +0,0 @@
-from django.test import TestCase, Client
-from django.test.utils import override_settings
-from django.http import HttpResponse
-from django.urls import reverse, re_path, include
-
-from django.contrib.auth import get_user_model
-
-from rest_framework import permissions
-from rest_framework.views import APIView
-from oauth2_provider.contrib.rest_framework import OAuth2Authentication
-from oauth2_provider.models import AccessToken
-
-UserModel = get_user_model()
-
-
-class MockView(APIView):
- permission_classes = (permissions.IsAuthenticated,)
-
- def get(self, request):
- return HttpResponse({"a": 1, "b": 2, "c": 3})
-
-
-class OAuth2View(MockView):
- authentication_classes = [OAuth2Authentication]
-
-
-urlpatterns = [
- re_path(r"^oauth2/", include("oauth2_provider.urls")),
- re_path(r"^oauth2-test/$", OAuth2View.as_view()),
- re_path(r"^accounts/", include("neurovault.apps.users.urls")),
-]
-
-
-@override_settings(ROOT_URLCONF=__name__)
-class TestPersonalAccessTokens(TestCase):
- def setUp(self):
- self.user_password = "l0n6 l1v3 7h3 k1n6!"
- self.user = UserModel.objects.create_user(
- "bernardo", "bernardo@example.com", self.user_password
- )
- self.client = Client()
-
- def tearDown(self):
- self.user.delete()
-
- def _create_authorization_header(self, token):
- return "Bearer {0}".format(token)
-
- def test_authentication_empty(self):
- response = self.client.get("/oauth2-test/")
- self.assertEqual(response.status_code, 401)
-
- def test_authentication_denied(self):
- auth = self._create_authorization_header("fake-token")
- response = self.client.get("/oauth2-test/", HTTP_AUTHORIZATION=auth)
- self.assertEqual(response.status_code, 401)
-
- def test_authentication_allow(self):
- self.client.login(username=self.user, password=self.user_password)
- response = self.client.post(reverse("users:token_create"))
- self.assertEqual(response.status_code, 302)
-
- access_token = AccessToken.objects.get(user_id=self.user)
-
- auth = self._create_authorization_header(access_token)
- response = self.client.get("/oauth2-test/", HTTP_AUTHORIZATION=auth)
- self.assertEqual(response.status_code, 200)
diff --git a/neurovault/apps/users/tests/test_tokens.py b/neurovault/apps/users/tests/test_tokens.py
new file mode 100644
index 00000000..494d94ba
--- /dev/null
+++ b/neurovault/apps/users/tests/test_tokens.py
@@ -0,0 +1,64 @@
+from django.contrib.auth import get_user_model
+from django.test import TestCase
+from django.urls import reverse
+
+from rest_framework.authtoken.models import Token
+from rest_framework.test import APIClient, APITestCase
+from rest_framework import status
+
+UserModel = get_user_model()
+
+class BaseTest(TestCase):
+ def setUp(self):
+ self.user_password = "random"
+ self.user = UserModel.objects.create_user(
+ "neurouser", "neurouser@example.com", self.user_password
+ )
+
+ def tearDown(self):
+ self.user.delete()
+
+class TokenGenerationTest(BaseTest):
+ def test_token_list(self):
+ self.client.login(username=self.user.username, password=self.user_password)
+ response = self.client.get(reverse('users:token_list'))
+ self.assertEqual(response.status_code, 200)
+
+ def test_token_list_unauthorized(self):
+ response = self.client.get(reverse('users:token_list'))
+ self.assertEqual(response.status_code, 302)
+ self.assertEqual(response.url, "/accounts/login/?next=/accounts/token/")
+
+ def test_token_create(self):
+ self.client.login(username=self.user.username, password=self.user_password)
+ token = Token.objects.filter(user=self.user).first()
+ self.assertIsNone(token)
+
+ response = self.client.get(reverse('users:token_list'))
+ token = Token.objects.filter(user=self.user).first()
+ self.assertIsNotNone(Token)
+ self.assertEqual(response.status_code, 200)
+
+ response = self.client.get(reverse('users:token_create'))
+ new_token = Token.objects.filter(user=self.user).first()
+ self.assertNotEqual(token, new_token)
+
+ def test_token_create_unauthorized(self):
+ response = self.client.post(reverse('users:token_create'))
+ self.assertEqual(response.status_code, 302)
+ self.assertEqual(response.url, "/accounts/login/?next=/accounts/token/new")
+
+
+ def test_token_auth(self):
+ self.client.login(username=self.user.username, password=self.user_password)
+ self.client.get(reverse('users:token_list'))
+ token = Token.objects.filter(user=self.user).first()
+
+ client = APIClient()
+ client.credentials(HTTP_AUTHORIZATION='Token ' + token.key)
+ post_dict = {
+ "name": "Test Create Collection",
+ }
+ response = client.post("/api/collections/", post_dict)
+ self.assertEqual(response.status_code, status.HTTP_201_CREATED)
+ self.assertEqual(response.data["name"], post_dict["name"])
diff --git a/neurovault/apps/users/urls.py b/neurovault/apps/users/urls.py
index 29f34cb6..87e165c8 100644
--- a/neurovault/apps/users/urls.py
+++ b/neurovault/apps/users/urls.py
@@ -7,20 +7,10 @@
create_user,
password_change_done,
delete_profile,
+ view_token
)
from django.contrib.auth.views import LoginView, LogoutView
from django.contrib.auth import views as auth_views
-from oauth2_provider.views.application import ApplicationList
-from .views import (
- ApplicationRegistration,
- ApplicationUpdate,
- ApplicationDelete,
- ConnectionList,
- ConnectionDelete,
- PersonalTokenList,
- PersonalTokenCreate,
- PersonalTokenDelete,
-)
admin.autodiscover()
@@ -69,35 +59,8 @@
re_path(r"^profile/edit$", edit_user, name="edit_user"),
re_path(r"^profile/delete$", delete_profile, name="delete_profile"),
re_path(r"^profile/.*$", view_profile, name="my_profile"),
- re_path(r"^tokens/$", PersonalTokenList.as_view(), name="token_list"),
- re_path(r"^tokens/new$", PersonalTokenCreate.as_view(), name="token_create"),
- re_path(
- r"^tokens/(?P