Unverified Commit cd15ce8f authored by Lynn Foster's avatar Lynn Foster Committed by GitHub
Browse files

Merge pull request #4 from valueflows/for-daniel

Updates to support DisCO new UI
parents 578571d0 f78a20a6
......@@ -47,7 +47,7 @@ class Query(graphene.AbstractType):
return formatAgentList(EconomicAgent.objects.all())
def resolve_user_is_authorized_to_create(self, args, context, info):
context_agent_id = args.get('contest_agent_id')
context_agent_id = args.get('context_agent_id')
user_agent = AgentUser.objects.filter(user=self.user).first().agent
return user_agent.is_authorized(context_agent_id=context_agent_id)
......
......@@ -98,6 +98,7 @@ class UpdateProcess(AuthedMutation):
scope_id = graphene.Int(required=False)
note = graphene.String(required=False)
is_finished = graphene.Boolean(required=False)
is_started = graphene.Boolean(required=False)
plan_id = graphene.Int(required=False)
process = graphene.Field(lambda: Process)
......@@ -111,8 +112,8 @@ class UpdateProcess(AuthedMutation):
note = args.get('note')
scope_id = args.get('scope_id')
is_finished = args.get('is_finished')
is_started = args.get('is_started')
plan_id = args.get('plan_id')
process = ProcessProxy.objects.get(pk=id)
if process:
if name:
......@@ -133,6 +134,9 @@ class UpdateProcess(AuthedMutation):
process.plan=plan
if is_finished != None:
process.finished=is_finished
if is_started != None:
if is_started == True:
process.started=datetime.date.today()
process.changed_by=context.user
user_agent = AgentUser.objects.get(user=context.user).agent
......
......@@ -1851,6 +1851,19 @@ query ($token: String) {
}
}
query ($token: String) {
viewer(token: $token) {
resourceClassification (id: 62) {
name
id
generatePlanFromWorkflowRecipe {
id
name
}
}
}
}
query ($token: String) {
viewer(token: $token) {
agent(id: 146) {
......
......@@ -4,6 +4,12 @@
import graphene
from graphene_django.types import DjangoObjectType
from django.conf import settings
from django.contrib.auth import authenticate
from django.contrib.auth.models import User
from django.core.exceptions import PermissionDenied
from valuenetwork.api.schemas.Auth import _authUser
import datetime
import valuenetwork.api.types as types
from valuenetwork.valueaccounting.models import EconomicResource as EconomicResourceProxy, EconomicResourceType, Facet as FacetProxy, FacetValue as FacetValueProxy
......@@ -54,15 +60,33 @@ class ResourceClassification(DjangoObjectType):
class Meta:
model = EconomicResourceType
only_fields = ('id', 'name', 'unit')
only_fields = ('id', 'name', 'unit', 'context_agent')
classification_resources = graphene.List(lambda: EconomicResource)
classification_facets = graphene.List(lambda: Facet)
generate_plan_from_workflow_recipe = graphene.Field(lambda: types.Plan)
#classification_facet_values = graphene.List(lambda: FacetValue)
def resolve_classification_resources(self, args, context, info):
return self.resources.all()
def resolve_classification_facets(self, args, context, info):
rtfvs = self.facets.all()
facets = []
for rtfv in rtfvs:
if rtfv.facet_value.facet not in facets:
facets.append(rtfv.facet_value.facet)
return facets
# This is a shameless hack!!!
def resolve_generate_plan_from_workflow_recipe(self, args, context, *rargs):
token = rargs[0].variable_values['token']
context.user = _authUser(token)
return self.generate_staged_work_order("Plan name", datetime.date.today(), context.user)
#def resolve_classification_facet_values(self, args, context, info):
# return self.facets.all() #TODO in process, not working yet
......
......@@ -7321,7 +7321,10 @@ class Process(models.Model):
 
@property #ValueFlows
def is_started(self):
return self.started
if self.started is not None:
return True
else:
return False
 
@property #ValueFlows
def note(self):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment