Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
e3e2d0f
add minimal model for instruments
jdbocarsly Jan 4, 2024
22090d0
add backend routes for equipment
jdbocarsly Jan 7, 2024
cab0ed4
frontend for equipment table page, "new equipment" modal functionali…
jdbocarsly Jan 7, 2024
be6d3ec
turn on emojis in tinymce fields :grin:
jdbocarsly Jan 16, 2024
90f5540
fix bug in DataBlockBase where the block type wasn't displayed properly
jdbocarsly Jan 16, 2024
64483d4
Clean up and fix typos in equipment routes based on code review
jdbocarsly Feb 12, 2024
80097d3
allow all logged-in users to see all equipment
jdbocarsly Feb 12, 2024
8c26944
adjust EquipmentTable columns and add delete buttons
jdbocarsly Mar 22, 2024
b59c7b9
specify which types are included in the equipment table using EQUIPME…
jdbocarsly Mar 25, 2024
d4ddf84
add contact information field to the Equipment model and frontend
jdbocarsly Mar 25, 2024
43241d2
remove creators from new equipment entries so they are visible for al…
jdbocarsly Mar 27, 2024
47f0ab3
add python tests for equipment
jdbocarsly Mar 28, 2024
56fbc5b
fix typos in starting material python tests
jdbocarsly Mar 28, 2024
804e8c5
cleanup and improve scoping of ids for inputs across app
jdbocarsly Mar 28, 2024
b53f2da
clean up e2e tests, and update them to better scope actions to within…
jdbocarsly Mar 28, 2024
8769345
Cleanup and update batchSampleFeature.js e2e test, remove unnecessary…
jdbocarsly Mar 30, 2024
b04b86a
remove location field from CreateEquipmentModal.vue
jdbocarsly Mar 29, 2024
3c567c4
add e2e tests for equipment
jdbocarsly Mar 29, 2024
dc831b3
remove unnecessary within() calls from cypress tests
jdbocarsly Mar 30, 2024
259f0ae
turn on batchSampleFeature.cy.js e2e tests, and enable equipment test…
jdbocarsly Mar 30, 2024
770741b
remove cypress spec list from ci.yml so that all specs run
jdbocarsly Apr 1, 2024
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
6 changes: 0 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,6 @@ jobs:
config: baseUrl=http://localhost:8081
working-directory: ./webapp
record: true
spec: |
./cypress/e2e/sampleTablePage.cy.js
./cypress/e2e/editPage.cy.js
browser: "electron"
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
Expand All @@ -166,9 +163,6 @@ jobs:
config: baseUrl=http://localhost:8081
working-directory: ./webapp
record: true
spec: |
./cypress/e2e/sampleTablePage.cy.js
./cypress/e2e/editPage.cy.js
browser: "chrome"
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
Expand Down
13 changes: 12 additions & 1 deletion pydatalab/pydatalab/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from pydatalab.models.cells import Cell
from pydatalab.models.collections import Collection
from pydatalab.models.equipment import Equipment
from pydatalab.models.files import File
from pydatalab.models.people import Person
from pydatalab.models.samples import Sample
Expand All @@ -13,6 +14,16 @@
"samples": Sample,
"starting_materials": StartingMaterial,
"cells": Cell,
"equipment": Equipment,
}

__all__ = ("File", "Sample", "StartingMaterial", "Person", "Cell", "Collection", "ITEM_MODELS")
__all__ = (
"File",
"Sample",
"StartingMaterial",
"Person",
"Cell",
"Collection",
"Equipment",
"ITEM_MODELS",
)
23 changes: 23 additions & 0 deletions pydatalab/pydatalab/models/equipment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from typing import Optional

from pydantic import Field

from pydatalab.models.items import Item


class Equipment(Item):
"""A model for representing an experimental sample."""

type: str = Field("equipment", const="equipment", pattern="^equipment$")

serial_numbers: Optional[str]
"""A string describing one or more serial numbers for the instrument."""

manufacturer: Optional[str]
"""The manufacturer of this piece of equipment"""

location: Optional[str]
"""Place where the equipment is located"""

contact: Optional[str]
"""Contact information for equipment (e.g., email address or phone number)."""
90 changes: 69 additions & 21 deletions pydatalab/pydatalab/routes/v0_1/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,45 @@ def dereference_files(file_ids: List[Union[str, ObjectId]]) -> Dict[str, Dict]:
return results


def get_equipment_summary():
if not current_user.is_authenticated and not CONFIG.TESTING:
return (
jsonify(
status="error",
message="Authorization required to access equipment list.",
),
401,
)

_project = {
"_id": 0,
"item_id": 1,
"name": 1,
"type": 1,
"date": 1,
"refcode": 1,
"location": 1,
}

items = [
doc
for doc in flask_mongo.db.items.aggregate(
[
{
"$match": {
"type": "equipment",
}
},
{"$project": _project},
]
)
]
return jsonify({"status": "success", "items": items})


get_equipment_summary.methods = ("GET",) # type: ignore


def get_starting_materials():
if not current_user.is_authenticated and not CONFIG.TESTING:
return (
Expand Down Expand Up @@ -424,8 +463,9 @@ def _create_sample(
# new_sample = {k: sample_dict[k] for k in schema["properties"] if k in sample_dict}
new_sample = sample_dict

if type == "starting_materials":
# starting_materials are open to all in the deploment at this point, so no creators are assigned
if type in ("starting_materials", "equipment"):
# starting_materials and equipment are open to all in the deploment at this point,
# so no creators are assigned
new_sample["creator_ids"] = []
new_sample["creators"] = []
elif CONFIG.TESTING:
Expand Down Expand Up @@ -497,29 +537,36 @@ def _create_sample(
400,
)

sample_list_entry = {
"refcode": data_model.refcode,
"item_id": data_model.item_id,
"nblocks": 0,
"date": data_model.date,
"name": data_model.name,
"creator_ids": data_model.creator_ids,
# TODO: This workaround for creators & collections is still gross, need to figure this out properly
"creators": [json.loads(c.json(exclude_unset=True)) for c in data_model.creators]
if data_model.creators
else [],
"collections": [
json.loads(c.json(exclude_unset=True, exclude_none=True))
for c in data_model.collections
]
if data_model.collections
else [],
"type": data_model.type,
}

# hack to let us use _create_sample() for equipment too. We probably want to make
# a more general create_item() to more elegantly handle different returns.
if data_model.type == "equipment":
sample_list_entry["location"] = data_model.location

data = (
{
"status": "success",
"item_id": data_model.item_id,
"sample_list_entry": {
"refcode": data_model.refcode,
"item_id": data_model.item_id,
"nblocks": 0,
"date": data_model.date,
"name": data_model.name,
"creator_ids": data_model.creator_ids,
# TODO: This workaround for creators & collections is still gross, need to figure this out properly
"creators": [json.loads(c.json(exclude_unset=True)) for c in data_model.creators]
if data_model.creators
else [],
"collections": [
json.loads(c.json(exclude_unset=True, exclude_none=True))
for c in data_model.collections
]
if data_model.collections
else [],
"type": data_model.type,
},
"sample_list_entry": sample_list_entry,
},
201, # 201: Created
)
Expand Down Expand Up @@ -885,6 +932,7 @@ def search_users():
ENDPOINTS: Dict[str, Callable] = {
"/samples/": get_samples,
"/starting-materials/": get_starting_materials,
"/equipment/": get_equipment_summary,
"/search-items/": search_items,
"/search-users/": search_users,
"/new-sample/": create_sample,
Expand Down
Loading