示例#1
0
 def _create_json_catalog(self, locale, domain, packages):
     activate(locale)
     catalog = JSONCatalog()
     packages = get_packages(packages)
     # we are passing None as the request, as the request object is
     # currently not used by django
     response = catalog.get(self, None, domain=domain, packages=packages)
     return force_str(response.content)
示例#2
0
    def _create_json_catalog(self, locale, domain, packages):
        activate(locale)
        if django.VERSION < (2, 0):
            catalog, plural = get_javascript_catalog(locale, domain, packages)
            data = {
                'catalog': catalog,
                'formats': get_formats(),
                'plural': plural,
            }

            return force_text(json.dumps(data, ensure_ascii=False))
        else:
            catalog = JSONCatalog()
            packages = get_packages(packages)
            # we are passing None as the request, as the request object is currently not used by django
            response = catalog.get(self, None, domain=domain, packages=packages)
            return force_text(response.content)
    def _create_json_catalog(self, locale, domain, packages):
        activate(locale)
        if django.VERSION < (2, 0):
            catalog, plural = get_javascript_catalog(locale, domain, packages)
            data = {
                'catalog': catalog,
                'formats': get_formats(),
                'plural': plural,
            }

            return force_text(json.dumps(data, ensure_ascii=False))
        else:
            catalog = JSONCatalog()
            packages = get_packages(packages)
            # we are passing None as the request, as the request object is
            # currently not used by django
            response = catalog.get(self, None, domain=domain, packages=packages)
            return force_text(response.content)
示例#4
0
                CategoryOptionsViewSet,
                basename='category')
router.register(r'type-attachment',
                TypeAttachmentViewSet,
                basename='type-attachment')
router.register(r'thesis-year-options',
                ThesisYearViewSet,
                basename='thesis-year')
router.register(r'reservation-state-options',
                ReservationStateOptionsViewSet,
                basename='reservation-state')
router.register(r'thesis-state-options',
                ThesisStateOptionsViewSet,
                basename='thesis-state')

app_name = 'api'
urlpatterns = [
    path('v1/', include((router.urls, 'v1'))),
    path('v1/login', LoginView.as_view()),
    path('v1/dashboard', DashboardView.as_view()),
    path('v1/has-perm/<str:perm>', UserPermView.as_view(), name='has-perm'),
    path('v1/review-pdf-detail/<uuid:pk>',
         ReviewPdfView.as_view(),
         name='review-pdf-detail'),
    path(
        'i18n/catalog',
        last_modified(lambda req, **kw: last_modified_date)(
            JSONCatalog.as_view(domain='django'))),
    path('i18n/', include('django.conf.urls.i18n')),
]
示例#5
0
from django.conf.urls import url
from django.utils import timezone
from django.views.decorators.http import last_modified
from django.views.i18n import JavaScriptCatalog, JSONCatalog

from . import views

last_modified_date = timezone.now()

packages = ['website.home']


def cache(view):
    return last_modified(lambda req, **kw: last_modified_date)(view)


urlpatterns = [
    url(r'^$', views.IndexView.as_view(), name='index'),
    url(r'^i18n/$',
        cache(JavaScriptCatalog.as_view(packages=packages)),
        name='javascript-catalog'),
    url(r'^i18n/json/$',
        cache(JSONCatalog.as_view(packages=packages)),
        name='json-catalog'),
]
示例#6
0
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import path, include
from django.views.i18n import JSONCatalog

urlpatterns = [
    # django built in
    path('admin/', admin.site.urls),

    # project specific
    path('pages/', include('pages.urls')),
    path('accounts/', include('accounts.urls')),

    # localization
    path('i18n/django/', JSONCatalog.as_view(domain='django')),
    path('i18n/djangojs/', JSONCatalog.as_view(domain='djangojs')),

    # rest framework specific
    path('auth/', include('rest_framework.urls', namespace='rest_framework')),
]

urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)