Skip to content

Commit b0569e6

Browse files
authored
BLUEBUTTON-522 application list (#707)
* Separate openid related view * Add paged ApplicationListView * Add django setting for APP_LIST_EXCLUDE for list
1 parent f24a3d0 commit b0569e6

File tree

6 files changed

+64
-3
lines changed

6 files changed

+64
-3
lines changed

apps/wellknown/serializers.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from rest_framework.serializers import (ModelSerializer, SerializerMethodField)
2+
from ..dot_ext.models import Application, ApplicationLabel
3+
4+
5+
class ApplicationLabelSerializer(ModelSerializer):
6+
class Meta:
7+
model = ApplicationLabel
8+
fields = (
9+
'name',
10+
'slug',
11+
'description',
12+
)
13+
14+
15+
class ApplicationListSerializer(ModelSerializer):
16+
labels = SerializerMethodField()
17+
18+
class Meta:
19+
model = Application
20+
fields = ('name', 'website_uri', 'logo_uri', 'tos_uri', 'policy_uri',
21+
'support_email', 'support_phone_number', 'description', 'labels')
22+
23+
def get_labels(self, obj):
24+
labels = ApplicationLabel.objects.filter(applications=obj.id).values('name', 'slug', 'description')
25+
return(labels)

apps/wellknown/urls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from django.conf.urls import url
2-
from .views import openid_configuration
2+
from .views import openid_configuration, ApplicationListView
33

44

55
urlpatterns = [
6-
# openid-configuration -----------------------------------
76
url(r'^openid-configuration$',
87
openid_configuration,
98
name='openid-configuration'),
9+
url(r'^applications$', ApplicationListView.as_view(), name='applications-list'),
1010
]

apps/wellknown/views/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from .openid import openid_configuration, base_issuer, build_endpoint_info # NOQA
2+
from .application import ApplicationListView # NOQA
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from ...dot_ext.models import Application
2+
from ..serializers import ApplicationListSerializer
3+
from django.conf import settings
4+
from rest_framework.generics import ListAPIView
5+
from rest_framework.pagination import PageNumberPagination
6+
from rest_framework.permissions import AllowAny
7+
from rest_framework.renderers import JSONRenderer
8+
9+
10+
class ApplicationListPagination(PageNumberPagination):
11+
page_size = 10
12+
page_size_query_param = 'page_size'
13+
max_page_size = 10000
14+
15+
16+
class ApplicationListView(ListAPIView):
17+
"""
18+
View to provide an applications list.
19+
20+
An application that has active=False or with a label slug in the APP_LIST_EXCLUDE
21+
list will be excluded from this view.
22+
"""
23+
permission_classes = (AllowAny,)
24+
renderer_classes = (JSONRenderer,)
25+
serializer_class = ApplicationListSerializer
26+
pagination_class = ApplicationListPagination
27+
28+
def get_queryset(self):
29+
queryset = Application.objects.exclude(active=False).exclude(
30+
applicationlabel__slug__in=settings.APP_LIST_EXCLUDE).order_by('name')
31+
return queryset
File renamed without changes.

hhs_oauth_server/settings/base.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,10 @@
348348
APP_LOGO_WIDTH_MAX = env('DJANGO_APP_LOGO_WIDTH_MAX', '128')
349349
APP_LOGO_HEIGHT_MAX = env('DJANGO_APP_LOGO_HEIGHT_MAX', '128')
350350

351+
# Application label slugs to exclude from externally
352+
# published lists, like those used for internal use testing.
353+
APP_LIST_EXCLUDE = env('DJANGO_APP_LIST_EXCLUDE', ['internal-use'])
354+
351355
# LINKS TO DOCS
352356
DEVELOPER_DOCS_URI = "https://bluebutton.cms.gov/developers"
353357
DEVELOPER_DOCS_TITLE = "Documentation"
@@ -383,7 +387,6 @@
383387
'STATIC_ROOT',
384388
'MEDIA_URL',
385389
'MEDIA_ROOT',
386-
'IS_MEDIA_URL_LOCAL',
387390
'MFA',
388391
'DEVELOPER_DOCS_URI',
389392
'DEVELOPER_DOCS_TITLE',

0 commit comments

Comments
 (0)