Skip to content

Commit

Permalink
fix requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
jdkent committed Oct 24, 2023
1 parent f15211c commit 7e8fb93
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 19 deletions.
8 changes: 4 additions & 4 deletions store/neurostore/models/auth.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from flask_security import UserMixin, RoleMixin, SQLAlchemyUserDatastore
# from flask_security import UserMixin, RoleMixin, SQLAlchemyUserDatastore


from ..database import db
Expand All @@ -13,14 +13,14 @@
)


class Role(BaseMixin, db.Model, RoleMixin):
class Role(BaseMixin, db.Model):
__tablename__ = "roles"

name = db.Column(db.Text, unique=True)
description = db.Column(db.Text)


class User(BaseMixin, db.Model, UserMixin):
class User(BaseMixin, db.Model):
__tablename__ = "users"
active = db.Column(db.Boolean())
name = db.Column(db.Text, index=True)
Expand All @@ -30,4 +30,4 @@ class User(BaseMixin, db.Model, UserMixin):
)


user_datastore = SQLAlchemyUserDatastore(db, User, Role)
# user_datastore = SQLAlchemyUserDatastore(db, User, Role)
1 change: 0 additions & 1 deletion store/neurostore/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ flask-cors~=3.0
flask-dance~=3.2
flask-shell-ipython~=0.4
flask-migrate~=2.5
flask-security~=3.0
flask-sqlalchemy==3.0.2 # fix multiple instance error: https://flask-sqlalchemy.palletsprojects.com/en/3.0.x/changes/#version-3-0-3
gunicorn~=20.0
ipython~=7.19
Expand Down
16 changes: 8 additions & 8 deletions store/neurostore/resources/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,11 @@ def get(self, id):
record = q.filter_by(id=id).first_or_404()
if self._model is Studyset and args["nested"]:
snapshot = StudysetSnapshot()
return snapshot.dump(record)
return snapshot.dump(record), 200, {"Content-Type": "application/json"}
else:
return self._schema(
context=dict(args),
).dump(record)
).dump(record), 200, {"Content-Type": "application/json"}

def put(self, id):
request_data = self.insert_data(id, request.json)
Expand Down Expand Up @@ -343,12 +343,12 @@ def post_delete(self, record):


LIST_USER_ARGS = {
"search": fields.String(missing=None),
"sort": fields.String(missing="created_at"),
"page": fields.Int(missing=1),
"desc": fields.Boolean(missing=True),
"page_size": fields.Int(missing=20, validate=lambda val: val < 30000),
"user_id": fields.String(missing=None),
"search": fields.String(load_default=None),
"sort": fields.String(load_default="created_at"),
"page": fields.Int(load_default=1),
"desc": fields.Boolean(load_default=True),
"page_size": fields.Int(load_default=20, validate=lambda val: val < 30000),
"user_id": fields.String(load_default=None),
}


Expand Down
4 changes: 2 additions & 2 deletions store/neurostore/resources/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class BaseStudiesView(ObjectView, ListView):
_nested = {"versions": "StudiesView"}

_view_fields = {
"level": fields.String(default="group", load_default="group"),
"level": fields.String(dump_default="group", load_default="group"),
"flat": fields.Boolean(load_default=False),
"info": fields.Boolean(load_default=False),
"data_type": fields.String(load_default=None),
Expand Down Expand Up @@ -274,7 +274,7 @@ class StudiesView(ObjectView, ListView):
**{
"data_type": fields.String(load_default=None),
"studyset_owner": fields.String(load_default=None),
"level": fields.String(default="group", load_default="group"),
"level": fields.String(dump_default="group", load_default="group"),
"flat": fields.Boolean(load_default=False),
"info": fields.Boolean(load_default=False),
},
Expand Down
4 changes: 2 additions & 2 deletions store/neurostore/schemas/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@


class UserSchema(BaseSchema):
name = fields.Str(description="User full name")
external_id = fields.Str(description="External authentication service user ID")
name = fields.Str(metadata={"description": "User full name"})
external_id = fields.Str(metadata={"description": "External authentication service user ID"})

class Meta:
unknown = EXCLUDE
7 changes: 5 additions & 2 deletions store/neurostore/tests/api/test_studysets.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,19 @@ def test_add_study_to_studyset(auth_client, ingest_neurosynth, session):
assert post_resp.status_code == 200

dset_id = post_resp.json()["id"]
auth_client.get(f"/api/studysets/{dset_id}?nested=true")
auth_client.get(f"/api/studysets/{dset_id}?nested=false")
pre_nested = auth_client.get(f"/api/studysets/{dset_id}?nested=true")
pre_non_nested = auth_client.get(f"/api/studysets/{dset_id}?nested=false")

assert pre_nested.status_code == pre_non_nested.status_code == 200
put_resp = auth_client.put(f"/api/studysets/{dset_id}", data={"studies": study_ids})

assert put_resp.status_code == 200
# test that the study shows up for both nested and not nested
nested_resp = auth_client.get(f"/api/studysets/{dset_id}?nested=true")
non_nested_resp = auth_client.get(f"/api/studysets/{dset_id}?nested=false")

assert nested_resp.status_code == non_nested_resp.status_code == 200

assert len(nested_resp.json()["studies"]) == len(non_nested_resp.json()["studies"])


Expand Down

0 comments on commit 7e8fb93

Please sign in to comment.