Skip to content

Commit

Permalink
blog: link to older/newer posts
Browse files Browse the repository at this point in the history
Fix Issue 70 of the amFOSS website
  • Loading branch information
SnehashishReddy authored and harshithpabbati committed Apr 2, 2021
1 parent e55f903 commit 763be6a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions activity/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def resolve_name(self, info):
def resolve_author(self, info):
return User.objects.values().get(id=self['author_id'])


class CollectionTagObj(graphene.ObjectType):
name = graphene.String()
author = graphene.Field(UserBasicObj)
Expand All @@ -30,6 +31,7 @@ def resolve_author(self, info):
def resolve_date(self, info):
return self['date']


class TagObj(graphene.ObjectType):
name = graphene.String()

Expand Down Expand Up @@ -76,6 +78,17 @@ def resolve_cover(self, info):
return self['cover']


class PaginationObj(graphene.ObjectType):
previous = graphene.String()
next = graphene.String()

def resolve_previous(self, info):
return Blog.objects.values().filter(featured=True, date__lt=self['date']).last()['slug']

def resolve_next(self, info):
return Blog.objects.values().filter(featured=True, date__gt=self['date']).first()['slug']


class BlogObj(graphene.ObjectType):
title = graphene.String(required=True)
slug = graphene.String(required=True)
Expand All @@ -88,6 +101,7 @@ class BlogObj(graphene.ObjectType):
cover = graphene.String(required=True)
category = graphene.Field(CategoryObj)
collection = graphene.Field(CollectionTagObj)
pagination = graphene.Field(PaginationObj)

def resolve_title(self, info):
return self['title']
Expand Down Expand Up @@ -125,6 +139,9 @@ def resolve_category(self, info):
def resolve_collection(self, info):
return Collection.objects.values().get(id=self['collection_id'])

def resolve_pagination(self, info):
return self


class AchievementObj(graphene.ObjectType):
title = graphene.String(required=True)
Expand Down

0 comments on commit 763be6a

Please sign in to comment.