Skip to content

Commit

Permalink
Add Privex footer to API browser, created api index
Browse files Browse the repository at this point in the history
  • Loading branch information
Someguy123 committed Mar 24, 2019
1 parent a94b757 commit 6ebc258
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 4 deletions.
32 changes: 32 additions & 0 deletions payments/templates/rest_framework/api.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{% extends "rest_framework/base.html" %}

{% block branding %}
<a class="navbar-brand" rel="nofollow" href="{% url 'index' %}">
CryptoToken Converter REST API
</a>
{% endblock %}

{% block content %}
{{ block.super }}
<div class="text-center" style="margin-top: 10%">
<hr/>
<p style="color: #a5a5a5; font-size: 14px;">
This Web API is running <a href="https://github.com/Privex/cryptotoken-converter" target="_blank">CryptoToken
Converter</a>, an open source application created by
<a href="https://www.privex.io/" target="_blank">Privex Inc.</a>
<br/>

<strong>Privex Inc. DOES NOT operate this service, and is not liable for any damages caused
by using it.</strong>
<br/>

If you have any problems with this service, please contact the owner of this domain:
<strong>{{ request.get_host }}</strong>
</p>
<a href="https://www.privex.io/" target="_blank">
<img src="https://www.privex.io/static/assets/svg/privex_ctc_api.svg"
alt="Developed by Privex" width="50%"/>
</a>
<br/><br/>
</div>
{% endblock %}
13 changes: 13 additions & 0 deletions payments/views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import logging
from rest_framework import viewsets
from rest_framework.decorators import api_view
from rest_framework.request import Request
from rest_framework.response import Response
from rest_framework.reverse import reverse
from rest_framework.views import APIView

from payments.coin_handlers import get_manager
Expand Down Expand Up @@ -33,6 +35,17 @@ class IndexView(TemplateView):
template_name = 'base.html'


@api_view(['GET'])
def api_root(request, format=None):
return Response({
'coins': reverse('coin-list', request=request, format=format),
'pairs': reverse('coinpair-list', request=request, format=format),
'deposits': reverse('deposit-list', request=request, format=format),
'conversions': reverse('conversion-list', request=request, format=format),
'start_conversion': reverse('start_convert', request=request, format=format)
})


class CoinAPI(viewsets.ReadOnlyModelViewSet):
queryset = Coin.objects.filter(enabled=True)
serializer_class = CoinSerializer
Expand Down
9 changes: 5 additions & 4 deletions steemengine/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
"""
# from adminplus.sites import AdminSitePlus
from django.contrib import admin
from django.urls import path, include
from django.urls import path, include, re_path
from rest_framework import routers

from payments.views import IndexView, DepositAPI, CoinAPI, ConvertAPI, CoinPairAPI, ConversionAPI
from payments.views import IndexView, DepositAPI, CoinAPI, ConvertAPI, CoinPairAPI, ConversionAPI, api_root
from payments.admin import ctadmin


Expand All @@ -42,9 +42,10 @@

urlpatterns = [
path('admin/', admin.site.urls),
path('api/convert/', ConvertAPI.as_view()),
path('api/convert/', ConvertAPI.as_view(), name='start_convert'),
re_path(r'^api/$', api_root),
path('api/', include(router.urls)),
path('', IndexView.as_view())
path('', IndexView.as_view(), name='index')
]


Expand Down

0 comments on commit 6ebc258

Please sign in to comment.