예제 #1
0
from django import VERSION
from django.views import generic

from autocomplete_light.compat import url, urls
from .forms import AutocompleteItemForm, DjangoItemForm
from .models import Item

urlpatterns = urls([
    url(r'autocomplete/(?P<pk>\d+)/', generic.UpdateView.as_view(
        form_class=AutocompleteItemForm,
        queryset=Item.objects.filter(private=False))),
    url(r'django/(?P<pk>\d+)/', generic.UpdateView.as_view(
        form_class=DjangoItemForm,
        queryset=Item.objects.filter(private=False))),
])
from django import VERSION
from autocomplete_light.compat import urls, url


urlpatterns = urls([
    url(r'^$', 'navigation_autocomplete', name='navigation_autocomplete'),
])
예제 #3
0
if django.VERSION < (1, 7):
    import autocomplete_light.shortcuts as autocomplete_light
    autocomplete_light.autodiscover()

    from django.contrib import admin
    admin.autodiscover()

try:
    from hvad_autocomplete import urls as hvad
except ImportError:
    # django 1.6 not support by hvad
    hvad = None

urlpatterns = urls([
    url(r'^admin/', include(admin.site.urls)),
    url(r'^autocomplete/', include('autocomplete_light.urls')),
    url(r'^navigation/', include('navigation_autocomplete.urls')),
    url(r'^security_test/',
        include('autocomplete_light.example_apps.security_test.urls')),
    url(r'^non_admin_add_another/',
        include('autocomplete_light.example_apps.non_admin_add_another.urls')),
    url(r'^favicon.ico',
        generic.RedirectView.as_view(url='http://mozilla.org/favicon.ico')),
    url(r'^$', generic.TemplateView.as_view(template_name='index.html')),
    url(r'^bootstrap_modal/', include('bootstrap_modal.urls')),
])

from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns += staticfiles_urlpatterns()
예제 #4
0

if django.VERSION < (1, 7):
    import autocomplete_light.shortcuts as autocomplete_light
    autocomplete_light.autodiscover()

    from django.contrib import admin
    admin.autodiscover()
 
try:
    from hvad_autocomplete import urls as hvad
except ImportError:
    # django 1.6 not support by hvad
    hvad = None

urlpatterns = urls([
    url(r'^admin/', include(admin.site.urls)),
    url(r'^autocomplete/', include('autocomplete_light.urls')),
    url(r'^navigation/', include('navigation_autocomplete.urls')),
    url(r'^security_test/',
        include('autocomplete_light.example_apps.security_test.urls')),
    url(r'^non_admin_add_another/',
        include('autocomplete_light.example_apps.non_admin_add_another.urls')),
    url(r'^favicon.ico', generic.RedirectView.as_view(url='http://mozilla.org/favicon.ico')),
    url(r'^$', generic.TemplateView.as_view(template_name='index.html')),
    url(r'^bootstrap_modal/', include('bootstrap_modal.urls')),
])

from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns += staticfiles_urlpatterns()
예제 #5
0
import autocomplete_light.shortcuts as al

from autocomplete_light.compat import url, urls
from django.views import generic

from .forms import NonAdminAddAnotherModelForm
from .models import NonAdminAddAnotherModel

urlpatterns = urls([
    url(r'$', al.CreateView.as_view(
        model=NonAdminAddAnotherModel, form_class=NonAdminAddAnotherModelForm),
        name='non_admin_add_another_model_create'),
    url(r'(?P<pk>\d+)/$', generic.UpdateView.as_view(
        model=NonAdminAddAnotherModel, form_class=NonAdminAddAnotherModelForm),
        name='non_admin_add_another_model_update'),
])
예제 #6
0
from django import VERSION
from django.views import generic

from autocomplete_light.compat import url, urls
from .forms import AutocompleteItemForm, DjangoItemForm
from .models import Item

urlpatterns = urls([
    url(
        r'autocomplete/(?P<pk>\d+)/',
        generic.UpdateView.as_view(
            form_class=AutocompleteItemForm,
            queryset=Item.objects.filter(private=False))),
    url(
        r'django/(?P<pk>\d+)/',
        generic.UpdateView.as_view(
            form_class=DjangoItemForm,
            queryset=Item.objects.filter(private=False))),
])
try:
    from unittest import mock
except ImportError:  # python2
    import mock

import autocomplete_light.shortcuts as autocomplete_light
from autocomplete_light.compat import urls, url
from django import test

try:
    from django.test import override_settings
except ImportError:
    override_settings = None

urlpatterns = urls([
    url(r'nokwarg/$', mock.Mock, name='test_nokwarg'),
    url(r'onekwarg/(?P<param>\w+)/$', mock.Mock, name='test_onekwarg'),
])


class GetAddAnotherUrlTestCase(test.TestCase):

    def generate_url(self, name, kwargs=None):
        class TestAutocomplete(autocomplete_light.AutocompleteBase):
            add_another_url_name = name
            add_another_url_kwargs = kwargs

        return TestAutocomplete().get_add_another_url()

    def test_no_kwargs(self):
        self.assertEquals(self.generate_url('test_nokwarg'),
                          '/nokwarg/?_popup=1')
예제 #8
0
from django.conf.urls import url
from django.views.generic.base import TemplateView
from autocomplete_light.compat import urls, url

urlpatterns = urls([
    url(r'^$', TemplateView.as_view(template_name="bootstrap_modal/modal.html"), name="bootstrap_modal"),
])
예제 #9
0
try:
    from unittest import mock
except ImportError:  # python2
    import mock

import autocomplete_light.shortcuts as autocomplete_light
from autocomplete_light.compat import urls, url
from django import test

try:
    from django.test import override_settings
except ImportError:
    override_settings = None

urlpatterns = urls([
    url(r'nokwarg/$', mock.Mock, name='test_nokwarg'),
    url(r'onekwarg/(?P<param>\w+)/$', mock.Mock, name='test_onekwarg'),
])


class GetAddAnotherUrlTestCase(test.TestCase):
    def generate_url(self, name, kwargs=None):
        class TestAutocomplete(autocomplete_light.AutocompleteBase):
            add_another_url_name = name
            add_another_url_kwargs = kwargs

        return TestAutocomplete().get_add_another_url()

    def test_no_kwargs(self):
        self.assertEquals(self.generate_url('test_nokwarg'),
                          '/nokwarg/?_popup=1')