Skip to content

Commit

Permalink
feat: introduce steward endpoint (#9377)
Browse files Browse the repository at this point in the history
  • Loading branch information
thelostone-mc authored Aug 20, 2021
1 parent 2cb9769 commit 5860a58
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
'retail',
'ptokens',
'rest_framework',
'django_filters',
'marketing',
'economy',
'dashboard',
Expand Down
39 changes: 39 additions & 0 deletions app/quadraticlands/router.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
"""Define dashboard specific DRF API routes.
Copyright (C) 2021 Gitcoin Core
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from quadraticlands.serializer import GTCStewardSerializer
from rest_framework import routers, viewsets
from rest_framework.pagination import PageNumberPagination

from .models import GTCSteward


class GTCStewardPagination(PageNumberPagination):
page_size = 30
page_size_query_param = 'page_size'


class GTCStewardViewSet(viewsets.ModelViewSet):
queryset = GTCSteward.objects.all()
serializer_class = GTCStewardSerializer
pagination_class = GTCStewardPagination


router = routers.DefaultRouter()
router.register(r'stewards', GTCStewardViewSet)
15 changes: 15 additions & 0 deletions app/quadraticlands/serializer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from dashboard.models import ProfileSerializer
from rest_flex_fields import FlexFieldsModelSerializer

from .models import GTCSteward


class GTCStewardSerializer(FlexFieldsModelSerializer):
"""Handle serializing of GTCSteward"""
class Meta:
"""Define the GrantCLR serializer metadata."""
model = GTCSteward
fields = ('profile', 'real_name', 'bio', 'gtc_address', 'profile_link', 'custom_steward_img')
expandable_fields = {
'profile': ProfileSerializer
}
3 changes: 3 additions & 0 deletions app/quadraticlands/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
"""
from django.conf import settings
from django.conf.urls import include, url
from django.urls import path, re_path

from quadraticlands.helpers import vote
from quadraticlands.router import router
from quadraticlands.views import (
base, base_auth, dashboard_index, handler400, handler403, handler404, handler500, index, mission_diplomacy,
mission_diplomacy_room, mission_index, mission_lore, mission_postcard, mission_postcard_svg, mission_schwag,
Expand Down Expand Up @@ -52,6 +54,7 @@
path('mission/diplomacy/<str:uuid>/<str:name>', mission_diplomacy_room, name='mission_diplomacy_room'),
re_path(r'^mission/diplomacy/?', mission_diplomacy, name='mission_diplomacy'),

url(r'^api/v1/', include(router.urls)),
]


Expand Down
1 change: 1 addition & 0 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,4 @@ libsass==0.20.1
graphqlclient==0.2.4
docutils==0.17.1
unidecode==1.2.0
drf-flex-fields==0.9.1

0 comments on commit 5860a58

Please sign in to comment.