mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 06:03:20 +00:00
First steps with the api
This commit is contained in:
parent
ad36c1c6f6
commit
feb7b4689b
0
api/__init__.py
Normal file
0
api/__init__.py
Normal file
3
api/admin.py
Normal file
3
api/admin.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
0
api/migrations/__init__.py
Normal file
0
api/migrations/__init__.py
Normal file
3
api/models.py
Normal file
3
api/models.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from django.db import models
|
||||||
|
|
||||||
|
# Create your models here.
|
3
api/tests.py
Normal file
3
api/tests.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
16
api/urls.py
Normal file
16
api/urls.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
from django.conf.urls import url, include
|
||||||
|
|
||||||
|
from api.views import *
|
||||||
|
from rest_framework import routers
|
||||||
|
|
||||||
|
# Router config
|
||||||
|
router = routers.DefaultRouter()
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
|
||||||
|
# API
|
||||||
|
url(r'^', include(router.urls)),
|
||||||
|
url(r'^login/', include('rest_framework.urls', namespace='rest_framework')),
|
||||||
|
url(r'^markdown$', RenderMarkdown, name='api_markdown'),
|
||||||
|
|
||||||
|
]
|
2
api/views/__init__.py
Normal file
2
api/views/__init__.py
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
from .api import *
|
||||||
|
from .serializers import *
|
13
api/views/api.py
Normal file
13
api/views/api.py
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
from rest_framework.response import Response
|
||||||
|
from rest_framework.decorators import api_view
|
||||||
|
|
||||||
|
from core.templatetags.renderer import markdown
|
||||||
|
|
||||||
|
|
||||||
|
@api_view(['GET'])
|
||||||
|
def RenderMarkdown(request):
|
||||||
|
"""
|
||||||
|
Render Markdown
|
||||||
|
"""
|
||||||
|
if request.method == 'GET':
|
||||||
|
return Response(markdown(request.GET['text']))
|
1
api/views/serializers.py
Normal file
1
api/views/serializers.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
from rest_framework import serializers
|
@ -39,7 +39,4 @@ urlpatterns = [
|
|||||||
url(r'^page/(?P<page_name>[a-z0-9/-_]*)/rev/(?P<rev>[0-9]+)/', PageRevView.as_view(), name='page_rev'),
|
url(r'^page/(?P<page_name>[a-z0-9/-_]*)/rev/(?P<rev>[0-9]+)/', PageRevView.as_view(), name='page_rev'),
|
||||||
url(r'^page/(?P<page_name>[a-z0-9/-_]*)/$', PageView.as_view(), name='page'),
|
url(r'^page/(?P<page_name>[a-z0-9/-_]*)/$', PageView.as_view(), name='page'),
|
||||||
|
|
||||||
# API
|
|
||||||
url(r'^api/markdown$', render_markdown, name='api_markdown'),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -100,5 +100,3 @@ from .user import *
|
|||||||
from .page import *
|
from .page import *
|
||||||
from .site import *
|
from .site import *
|
||||||
from .group import *
|
from .group import *
|
||||||
from .api import *
|
|
||||||
|
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
from core.templatetags.renderer import markdown
|
|
||||||
from django.http import HttpResponse
|
|
||||||
|
|
||||||
def render_markdown(request):
|
|
||||||
return HttpResponse(markdown(request.GET['text']))
|
|
@ -5,3 +5,4 @@ mistune
|
|||||||
django-jinja
|
django-jinja
|
||||||
pyopenssl
|
pyopenssl
|
||||||
pytz
|
pytz
|
||||||
|
djangorestframework
|
||||||
|
@ -51,6 +51,7 @@ INSTALLED_APPS = (
|
|||||||
'counter',
|
'counter',
|
||||||
'eboutic',
|
'eboutic',
|
||||||
'launderette',
|
'launderette',
|
||||||
|
'rest_framework',
|
||||||
'api',
|
'api',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -29,5 +29,6 @@ urlpatterns = [
|
|||||||
url(r'^accounting/', include('accounting.urls', namespace="accounting", app_name="accounting")),
|
url(r'^accounting/', include('accounting.urls', namespace="accounting", app_name="accounting")),
|
||||||
url(r'^eboutic/', include('eboutic.urls', namespace="eboutic", app_name="eboutic")),
|
url(r'^eboutic/', include('eboutic.urls', namespace="eboutic", app_name="eboutic")),
|
||||||
url(r'^launderette/', include('launderette.urls', namespace="launderette", app_name="launderette")),
|
url(r'^launderette/', include('launderette.urls', namespace="launderette", app_name="launderette")),
|
||||||
|
url(r'^api/', include('api.urls', namespace="api", app_name="api")),
|
||||||
url(r'^admin/', include(admin.site.urls)),
|
url(r'^admin/', include(admin.site.urls)),
|
||||||
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) # TODO: remove me for production!!!
|
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) # TODO: remove me for production!!!
|
||||||
|
Loading…
Reference in New Issue
Block a user