2017-05-18 21:51:17 +00:00
|
|
|
"""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'))
|
|
|
|
"""
|
2017-05-22 23:13:14 +00:00
|
|
|
from django.conf.urls import include, url
|
2017-10-08 20:21:51 +00:00
|
|
|
from django.urls import reverse
|
2017-06-16 17:02:34 +00:00
|
|
|
from django.conf.urls.i18n import i18n_patterns
|
2017-05-18 21:51:17 +00:00
|
|
|
from django.contrib import admin
|
2017-05-22 23:13:14 +00:00
|
|
|
from django.contrib.auth.models import User
|
2018-05-30 18:21:48 +00:00
|
|
|
|
2017-05-22 23:13:14 +00:00
|
|
|
from rest_framework import routers, serializers, viewsets
|
|
|
|
from rest_framework_gis import serializers as gis_serializers
|
|
|
|
|
2018-05-30 18:21:48 +00:00
|
|
|
from apps.files.models import File
|
|
|
|
from apps.map.models import CaseStudy
|
|
|
|
|
2018-05-19 17:52:19 +00:00
|
|
|
from .views import LanguageDropdownView
|
|
|
|
|
2017-05-22 23:13:14 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
|
2018-05-30 18:21:48 +00:00
|
|
|
class FileSerializer(serializers.HyperlinkedModelSerializer):
|
|
|
|
class Meta:
|
|
|
|
model = File
|
|
|
|
fields = ('file',)
|
|
|
|
|
|
|
|
|
2017-05-22 23:13:14 +00:00
|
|
|
class CaseStudySerializer(gis_serializers.GeoFeatureModelSerializer):
|
2018-03-31 11:12:06 +00:00
|
|
|
sector_of_economy = serializers.CharField(source='get_sector_of_economy_display')
|
|
|
|
country_name = serializers.CharField(source='get_country_display')
|
|
|
|
positive_or_negative_display = serializers.CharField(source='get_positive_or_negative_display')
|
2018-05-30 18:21:48 +00:00
|
|
|
images = FileSerializer(many=True)
|
2018-03-31 11:12:06 +00:00
|
|
|
|
2017-05-22 23:13:14 +00:00
|
|
|
class Meta:
|
|
|
|
model = CaseStudy
|
|
|
|
geo_field = "location"
|
2018-03-31 11:12:06 +00:00
|
|
|
fields = (
|
|
|
|
'country',
|
|
|
|
'country_name',
|
|
|
|
'entry_name',
|
2018-05-30 18:21:48 +00:00
|
|
|
'images',
|
2018-03-31 11:12:06 +00:00
|
|
|
'location',
|
|
|
|
'positive_or_negative',
|
|
|
|
'positive_or_negative_display',
|
|
|
|
'sector_of_economy',
|
|
|
|
'slug'
|
|
|
|
)
|
2017-05-22 23:13:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
class CaseStudyViewSet(viewsets.ModelViewSet):
|
2018-03-27 04:14:01 +00:00
|
|
|
queryset = CaseStudy.objects.approved()
|
2017-05-22 23:13:14 +00:00
|
|
|
serializer_class = CaseStudySerializer
|
|
|
|
|
2018-03-27 04:14:01 +00:00
|
|
|
|
2017-05-22 23:13:14 +00:00
|
|
|
apirouter = routers.DefaultRouter()
|
|
|
|
apirouter.register(r'users', UserViewSet)
|
|
|
|
apirouter.register(r'case-studies', CaseStudyViewSet)
|
2017-05-18 21:51:17 +00:00
|
|
|
|
|
|
|
urlpatterns = [
|
2017-05-22 23:13:14 +00:00
|
|
|
url(r'api/', include(apirouter.urls)),
|
2017-05-18 21:51:17 +00:00
|
|
|
url(r'^admin/', admin.site.urls),
|
2017-10-31 14:57:26 +00:00
|
|
|
url(r'^avatar/', include('avatar.urls')),
|
2017-05-22 23:13:14 +00:00
|
|
|
url(r'^cas/', include('cas_server.urls', namespace='cas_server')),
|
2018-04-23 05:15:33 +00:00
|
|
|
url(r'^files/', include('apps.files.urls')),
|
2018-05-19 17:52:19 +00:00
|
|
|
url(r'^set_language/(?P<language>[^/]+)$', LanguageDropdownView.as_view()),
|
2017-10-31 14:57:26 +00:00
|
|
|
# url(r'^contact/', include('apps.contact.urls'), name="contact"),
|
2017-05-18 21:51:17 +00:00
|
|
|
]
|
2017-06-16 17:02:34 +00:00
|
|
|
|
|
|
|
urlpatterns += i18n_patterns(
|
2017-10-31 14:57:26 +00:00
|
|
|
url(r'^accounts/profile/', include('apps.profiles.urls', namespace="profile")),
|
2017-10-08 20:21:51 +00:00
|
|
|
url(r'^accounts/', include('registration.backends.default.urls')),
|
2017-06-16 17:02:34 +00:00
|
|
|
url(r'', include('apps.map.urls'), name="map"),
|
|
|
|
)
|