Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
serkanozer committed Oct 5, 2020
1 parent 45d89f6 commit c2a3d89
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/beds/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,16 @@ def mutate(self, info, name, length, width, garden_id, **kwargs):


class Query(graphene.ObjectType):
beds = graphene.List(BedType)
beds_for_user = graphene.List(BedType, gardenId=graphene.Int(required=False))
all_beds = graphene.List(BedType)
beds = graphene.List(BedType, gardenId=graphene.Int(required=False))

def resolve_beds(self, info):
def resolve_all_beds(self, info):
user = info.context.user
if not (user.is_superuser | user.is_staff):
raise Exception("You must be a superuser or staff to view all beds")
return Bed.objects.all()

def resolve_beds_for_user(self, info, gardenId=None):
def resolve_beds(self, info, gardenId=None):
user = info.context.user
try:
if user.is_anonymous:
Expand Down
6 changes: 3 additions & 3 deletions src/gardens/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ def mutate(self, info, name):
)

class Query(graphene.ObjectType):
all_gardens = graphene.List(GardenType)
gardens = graphene.List(GardenType)
user_gardens = graphene.List(GardenType)

def resolve_user_gardens(self, info):
def resolve_gardens(self, info):
user = info.context.user
if user.is_anonymous:
raise Exception("Not logged in!")
return Garden.objects.filter(owner=user)

def resolve_gardens(self, info):
def resolve_all_gardens(self, info):
user = info.context.user
if not (user.is_superuser or user.is_staff):
raise Exception("You must be a superuser to view all gardens")
Expand Down
4 changes: 2 additions & 2 deletions src/sections/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ def mutate(self, info, bed_id, xLocation, yLocation, **kwargs):


class Query(graphene.ObjectType):
sections = graphene.List(SectionType)
all_sections = graphene.List(SectionType)

def resolve_sections(self, info):
def resolve_all_sections(self, info):
return Section.objects.all()


Expand Down

0 comments on commit c2a3d89

Please sign in to comment.