Skip to content

Commit

Permalink
portia_server: fix: use singular type names
Browse files Browse the repository at this point in the history
  • Loading branch information
milahu committed Apr 16, 2022
1 parent 35befd5 commit 3b1f10b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 3 additions & 1 deletion portia_server/portia_api/jsonapi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ def dasherize(value):


def type_from_model_name(value):
return '{}s'.format(camel_case_to_dashes(value))
type_ = camel_case_to_dashes(value) # singular
#type_ = type_ + "s" # plural
return type_


def deep_getattr(obj, key):
Expand Down
14 changes: 7 additions & 7 deletions portia_server/portia_api/resources/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ class ProjectSchema(SlydSchema):
)
project = fields.Relationship(
self_url='/api/projects/{project_id}',
self_url_kwargs={'project_id': '<id>'}, type_='projects'
self_url_kwargs={'project_id': '<id>'}, type_='project'
)

class Meta:
type_ = 'projects'
type_ = 'project'


class SchemaSchema(SlydSchema):
Expand All @@ -95,7 +95,7 @@ class SchemaSchema(SlydSchema):
project = fields.Relationship(
related_url='/api/projects/{project_id}',
related_url_kwargs={'project_id': '<project_id>'},
type_='projects',
type_='project',
include_resource_linkage=True
)
fields = fields.Relationship(
Expand All @@ -119,7 +119,7 @@ class FieldSchema(SlydSchema):
project = fields.Relationship(
related_url='/api/projects/{project_id}',
related_url_kwargs={'project_id': '<project_id>'},
type_='projects',
type_='project',
include_resource_linkage=True
)
schema = fields.Relationship(
Expand Down Expand Up @@ -159,7 +159,7 @@ class SpiderSchema(SlydSchema):
project = fields.Relationship(
related_url='/api/projects/{project_id}',
related_url_kwargs={'project_id': '<project_id>'},
type_='projects',
type_='project',
include_resource_linkage=True
)

Expand Down Expand Up @@ -202,7 +202,7 @@ class SampleSchema(SlydSchema):
project = fields.Relationship(
related_url='/api/projects/{project_id}',
related_url_kwargs={'project_id': '<project_id>'},
type_='projects', include_resource_linkage=True
type_='project', include_resource_linkage=True
)
spider = fields.Relationship(
related_url='/api/projects/{project_id}/spiders/{spider_id}',
Expand Down Expand Up @@ -351,7 +351,7 @@ class ExtractorSchema(SlydSchema):
project = fields.Relationship(
related_url='/api/projects/{project_id}',
related_url_kwargs={'project_id': '<project_id>'},
type_='projects',
type_='project',
include_resource_linkage=True
)

Expand Down

0 comments on commit 3b1f10b

Please sign in to comment.