Skip to content

Commit

Permalink
Merge pull request #2212 from SEED-platform/2176_apiv3_users
Browse files Browse the repository at this point in the history
2176 apiv3 users
  • Loading branch information
aviveiros11 committed May 21, 2020
2 parents f15fa05 + c0be058 commit 6dc9a66
Show file tree
Hide file tree
Showing 5 changed files with 896 additions and 5 deletions.
4 changes: 3 additions & 1 deletion seed/api/v3/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
from seed.views.v3.data_quality import DataQualityViews


from seed.views.v3.users import UserViewSet

api_v3_router = routers.DefaultRouter()
api_v3_router.register(r'cycles', CycleViewSet, base_name='cycles')
api_v3_router.register(r'datasets', DatasetViewSet, base_name='datasets')
api_v3_router.register(r'data_quality_checks', DataQualityViews, base_name='data_quality_checks')

api_v3_router.register(r'users', UserViewSet, base_name='user')

urlpatterns = [
url(r'^', include(api_v3_router.urls)),
Expand Down
4 changes: 4 additions & 0 deletions seed/landing/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ def process_header_request(cls, request):
def get_absolute_url(self):
return "/users/%s/" % urlquote(self.username)

def deactivate_user(self):
self.is_active = False
self.save()

def get_full_name(self):
"""
Returns the first_name plus the last_name, with a space in between.
Expand Down
8 changes: 6 additions & 2 deletions seed/utils/api_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ class AutoSchemaHelper(SwaggerAutoSchema):

# Used to easily build out example values displayed on Swagger page.
body_parameter_formats = {
'interger_list': openapi.Schema(
'interger_array': openapi.Schema(
type=openapi.TYPE_ARRAY,
items=openapi.Schema(type=openapi.TYPE_INTEGER)
),
'string': openapi.Schema(type=openapi.TYPE_STRING)
'string': openapi.Schema(type=openapi.TYPE_STRING),
'string_array': openapi.Schema(
type=openapi.TYPE_ARRAY,
items=openapi.Schema(type=openapi.TYPE_STRING)
)
}

def base_field(self, name, location_attr, description, required, type):
Expand Down
4 changes: 2 additions & 2 deletions seed/views/v3/data_quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ def __init__(self, *args):
required=True,
description="An object containing IDs of the records to perform data quality checks on. Should contain two keys- property_state_ids and taxlot_state_ids, each of which is an array of appropriate IDs.",
params_to_formats={
'property_state_ids': 'interger_list',
'taxlot_state_ids': 'interger_list'
'property_state_ids': 'interger_array',
'taxlot_state_ids': 'interger_array'
}
),
],
Expand Down
Loading

0 comments on commit 6dc9a66

Please sign in to comment.