urls.tpl 1.49 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
{% autoescape off %}
# WARNING
# THIS FILE HAS BEEN AUTOMATICALLY GENERATED
# WITH /backend/generate/generate_all.py
# MODIFY THE FILE ABOVE IF YOUR NOT SATISFIED 
# THIS WARNING DOESN'T APPLY TO .tpl FILES...

from django.conf.urls import url, include
from django.conf import settings
from rest_framework import routers

{% spaceless %}
{% for model in data %}{% if 'requires_testing' not in model or not model.requires_testing %}
from backend.models.{{model.import_location}} import {{model.viewset}}
{% endif %}{% endfor %}
{% endspaceless %}

from rest_framework.documentation import include_docs_urls

urlpatterns = [
    url(r'^api-docs/', include_docs_urls(title='Outgoing API'))
]

router = routers.DefaultRouter()

if settings.TESTING:
    {% for model in data %}{% if 'requires_testing' in model or model.requires_testing %}
    from backend.models.{{model.import_location}} import {{model.viewset}}
    router.register(
        r'{{model.api_end_point}}{% if 'api_attr' in model %}/{{model.api_attr}}{% endif %}', 
        {{model.viewset}}{%if 'api_name' in model%},"{{model.api_name}}"{% endif %}
    ){% endif %}{% endfor %}


{% for model in data %}{% if 'requires_testing' not in model or not model.requires_testing %}
router.register(
    r'{{model.api_end_point}}{% if 'api_attr' in model %}/{{model.api_attr}}{% endif %}', 
    {{model.viewset}}{%if 'api_name' in model%},"{{model.api_name}}"{% endif %}
){% endif %}{% endfor %}

urlpatterns += [url(r'^api/', include(router.urls))]
{% endautoescape %}