64 lines
2.2 KiB
Python
64 lines
2.2 KiB
Python
"""ojusomap URL Configuration
|
|
|
|
The `urlpatterns` list routes URLs to views. For more information please see:
|
|
https://docs.djangoproject.com/en/1.11/topics/http/urls/
|
|
Examples:
|
|
Function views
|
|
1. Add an import: from my_app import views
|
|
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
|
|
Class-based views
|
|
1. Add an import: from other_app.views import Home
|
|
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
|
|
Including another URLconf
|
|
1. Import the include() function: from django.conf.urls import url, include
|
|
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
|
|
"""
|
|
from django.conf.urls import include, url
|
|
from django.urls import reverse
|
|
from django.conf.urls.i18n import i18n_patterns
|
|
from django.contrib import admin
|
|
from django.contrib.auth.models import User
|
|
from apps.map.models import CaseStudy
|
|
from rest_framework import routers, serializers, viewsets
|
|
from rest_framework_gis import serializers as gis_serializers
|
|
|
|
class UserSerializer(serializers.HyperlinkedModelSerializer):
|
|
class Meta:
|
|
model = User
|
|
fields = ('url', 'username', 'email', 'is_staff')
|
|
|
|
|
|
class UserViewSet(viewsets.ModelViewSet):
|
|
queryset = User.objects.all()
|
|
serializer_class = UserSerializer
|
|
|
|
|
|
class CaseStudySerializer(gis_serializers.GeoFeatureModelSerializer):
|
|
class Meta:
|
|
model = CaseStudy
|
|
geo_field = "location"
|
|
fields = '__all__'
|
|
|
|
|
|
class CaseStudyViewSet(viewsets.ModelViewSet):
|
|
queryset = CaseStudy.objects.all()
|
|
serializer_class = CaseStudySerializer
|
|
|
|
apirouter = routers.DefaultRouter()
|
|
apirouter.register(r'users', UserViewSet)
|
|
apirouter.register(r'case-studies', CaseStudyViewSet)
|
|
|
|
urlpatterns = [
|
|
url(r'api/', include(apirouter.urls)),
|
|
url(r'^admin/', admin.site.urls),
|
|
url(r'^cas/', include('cas_server.urls', namespace='cas_server')),
|
|
# url(r'^contact/', include('apps.contact.urls'), name="contact")
|
|
]
|
|
|
|
urlpatterns += i18n_patterns(
|
|
url(r'^accounts/profile/', include('apps.profiles.urls')),
|
|
# url(r'^accounts/logout/?$', include('django.contrib.auth.views.logout'), {'next_page': '/'}),
|
|
url(r'^accounts/', include('registration.backends.default.urls')),
|
|
url(r'', include('apps.map.urls'), name="map"),
|
|
)
|