Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds API endpoints for Janeway core and Plugin versions. #4575

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from journal import models as journal_models
from submission import models as submission_models
from repository import models as repository_models
from utils import models as utils_models


class LicenceSerializer(serializers.HyperlinkedModelSerializer):
Expand Down Expand Up @@ -129,6 +130,7 @@ class Meta:
'salutation', 'orcid', 'is_active',
)


class PreprintAccountSerializer(serializers.HyperlinkedModelSerializer):

class Meta:
Expand All @@ -138,6 +140,7 @@ class Meta:
'salutation', 'orcid',
)


class AccountRoleSerializer(serializers.ModelSerializer):

class Meta:
Expand All @@ -160,11 +163,13 @@ def validate(self, data):

return data


class RepositoryFieldAnswerSerializer(serializers.ModelSerializer):
class Meta:
model = repository_models.RepositoryFieldAnswer
fields = ['pk', 'answer']


class PreprintSerializer(serializers.ModelSerializer):

class Meta:
Expand Down Expand Up @@ -197,3 +202,26 @@ class Meta:
many=True,
read_only=True,
)


class VersionSerializer(serializers.ModelSerializer):
class Meta:
model = utils_models.Version
fields = (
"number",
"date",
"rollback",
)


class PluginSerializer(serializers.ModelSerializer):
class Meta:
model = utils_models.Plugin
fields = (
"name",
"version",
"date_installed",
"display_name",
"press_wide",
"homepage_element",
)
2 changes: 2 additions & 0 deletions src/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
router.register(r'licences', views.LicenceViewSet, 'licence')
router.register(r'keywords', views.KeywordsViewSet, 'keywords')
router.register(r'accounts', views.AccountViewSet, 'accounts')
router.register(r'versions', views.VersionViewSet, 'versions')
router.register(r'plugins', views.PluginViewSet, 'plugins')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left these as single quote for consistency.


# Wire up our API using automatic URL routing.
# Additionally, we include login URLs for the browsable API.
Expand Down
29 changes: 29 additions & 0 deletions src/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from submission import models as submission_models
from journal import models as journal_models
from repository import models as repository_models
from utils import models as utils_models


@api_view(['GET'])
Expand Down Expand Up @@ -157,6 +158,34 @@ def get_queryset(self):
stage=repository_models.STAGE_PREPRINT_PUBLISHED)


@permission_classes((api_permissions.IsEditor, ))
class VersionViewSet(viewsets.ModelViewSet):
"""
API Endpoint for Janeway version data.
"""
serializer_class = serializers.VersionSerializer
http_method_names = ["get"]

def get_queryset(self):
return utils_models.Version.objects.all().order_by(
"-date",
)


@permission_classes((api_permissions.IsEditor, ))
class PluginViewSet(viewsets.ModelViewSet):
"""
API Endpoint for Janeway plugin version data.
"""
serializer_class = serializers.PluginSerializer
http_method_names = ["get"]

def get_queryset(self):
return utils_models.Plugin.objects.all().order_by(
"name",
)


def oai(request):
articles = submission_models.Article.objects.filter(stage=submission_models.STAGE_PUBLISHED)
if request.journal:
Expand Down