Skip to content

Commit

Permalink
added plan filter for Action and Job
Browse files Browse the repository at this point in the history
  • Loading branch information
pnhowe committed Jan 10, 2018
1 parent 6b8a776 commit 9c01320
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions architect/Builder/models.py
Expand Up @@ -205,6 +205,11 @@ def jobComplete( self, job ):
def filter_instance( instance ):
return Action.objects.filter( instance=instance )

@cinp.list_filter( name='plan', paramater_type_list=[ { 'type': 'Model', 'model': 'architect.Plan.models.Plan' } ] )
@staticmethod
def filter_plan( plan ):
return Action.objects.filter( instance__plan=plan )

@cinp.check_auth()
@staticmethod
def checkAuth( user, verb, id_list, action=None ):
Expand Down Expand Up @@ -282,6 +287,16 @@ def jobNotify( self, token, target, script, at, foundation=None, structure=None
def filter_action( action ):
return Job.objects.filter( action=action )

@cinp.list_filter( name='instance', paramater_type_list=[ { 'type': 'Model', 'model': 'architect.Builder.models.Instance' } ] )
@staticmethod
def filter_instance( instance ):
return Job.objects.filter( action__instance=instance )

@cinp.list_filter( name='plan', paramater_type_list=[ { 'type': 'Model', 'model': 'architect.Plan.models.Plan' } ] )
@staticmethod
def filter_plan( plan ):
return Job.objects.filter( action__instance__plan=plan )

@cinp.check_auth()
@staticmethod
def checkAuth( user, verb, id_list, action=None ):
Expand Down
2 changes: 1 addition & 1 deletion architect/Plan/models.py
Expand Up @@ -108,7 +108,7 @@ class PlanComplex( models.Model ):
updated = models.DateTimeField( auto_now=True )
created = models.DateTimeField( auto_now_add=True )

@cinp.action( return_type={ 'type': 'Map' }, paramater_type_list=[ { 'type': 'Integer' } ] )
@cinp.action( return_type={ 'type': 'Map' }, paramater_type_list=[ { 'type': 'Integer', 'doc': 'number of seconds of data to retreieve' } ] )
def graph_data( self, duration=3600 ):
result = { 'graph': {}, 'value': {} }
result[ 'graph' ][ 'cost' ] = self.cost.graph_data( duration )
Expand Down

0 comments on commit 9c01320

Please sign in to comment.