Skip to content

Commit 5480f20

Browse files
committed
Changed ResultBundleResult Djangoauthorization to models.Result, some clean ups
- for ResultBundle add, update, delete the Django access rights of the Result model is used - commented out some stuff that will be required maybe in future features Change-Id: If38a5230bf04137f823e8d7884fa29d41ea202ae
1 parent 5441385 commit 5480f20

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

codespeed/api.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ class Meta:
134134

135135
class ResultResource(ModelResource):
136136
"""Resource for Result()"""
137+
revision = fields.ToOneField(RevisionResource, 'revision')
138+
executable = fields.ToOneField(ExecutableResource, 'executable')
139+
benchmark = fields.ToOneField(BenchmarkResource, 'benchmark')
140+
environment = fields.ToOneField(EnvironmentResource, 'environment')
137141

138142
class Meta:
139143
queryset = Result.objects.all()
@@ -274,7 +278,7 @@ def _populate_by_obj(self):
274278
# TODO (a8): add user to models
275279
setattr(self.obj, 'user', User.objects.get(pk=1))
276280
#setattr(self.obj, 'user', None)
277-
setattr(self.obj, 'notify', None)
281+
#setattr(self.obj, 'notify', None)
278282

279283
def _check_data(self):
280284
"""See if all mandatory data is there"""
@@ -362,7 +366,7 @@ class ResultBundleResource(Resource):
362366
363367
not mandatory data
364368
'notify' - Send notification to registered user if result varies from
365-
previous results
369+
previous results, currently not implemented
366370
"""
367371

368372
revision = fields.ToOneField(RevisionResource, 'revision')
@@ -372,13 +376,15 @@ class ResultBundleResource(Resource):
372376
benchmark = fields.ToOneField(BenchmarkResource, 'benchmark')
373377
environment = fields.ToOneField(EnvironmentResource, 'environment')
374378
result = fields.ToOneField(ResultResource, 'result')
375-
user = fields.ToOneField(UserResource, 'user', null=True)
376-
notify = fields.CharField(attribute='notify', null=True)
379+
#user = fields.ToOneField(UserResource, 'user', null=True)
380+
#notify = fields.CharField(attribute='notify', null=True)
377381

378382
class Meta:
379383
resource_name = 'benchmark-result'
384+
object_class = Result
380385
authorization = DjangoAuthorization()
381-
authentication = MultiAuthentication(ApiKeyAuthentication(), Authentication())
386+
authentication = MultiAuthentication(ApiKeyAuthentication(),
387+
Authentication())
382388
allowed_methods = ['get', 'post', 'put', 'delete']
383389

384390
def get_resource_uri(self, bundle_or_obj):
@@ -415,12 +421,12 @@ def obj_get(self, request=None, **kwargs):
415421
setattr(result, 'result', result)
416422
# TODO (a8): add user to models
417423
#setattr(result, 'user', User.objects.get(pk=1))
418-
setattr(result, 'user', None)
424+
#setattr(result, 'user', None)
419425
#setattr(result, 'notify', None)
420426
return result
421427

422428
def obj_create(self, bundle, request=None, **kwargs):
423-
# FIXME (a8): Make full_hydrate work
429+
# not calling hydrate here since bundle.save() has that functionality
424430
#bundle = self.full_hydrate(bundle)
425431
bundle.save()
426432
return bundle
@@ -468,3 +474,6 @@ def obj_delete(self, request=None, **kwargs):
468474

469475
def rollback(self, bundles):
470476
pass
477+
478+
def detail_uri_kwargs(self):
479+
pass

0 commit comments

Comments
 (0)