Exemplo n.º 1
0
 def urls(cls, name_prefix=None):
     urlpatterns = super(ItemHandlingResource, cls).urls(name_prefix=name_prefix)
     return urlpatterns + patterns('',
         url(r'^item/pdf$', csrf_exempt(cls.as_view('fileupload')), name=cls.build_url_name('fileupload', name_prefix)),
         url(r'^item/cover$', csrf_exempt(cls.as_view('coverupload')), name=cls.build_url_name('coverupload', name_prefix)),
         url(r'^item/background$', csrf_exempt(cls.as_view('backgroundupload')), name=cls.build_url_name('backgroundupload', name_prefix))
         )
 def get_urls(self):
     urlpatterns = patterns('',
         url(r'^$', self.view_that_asks_for_money, name='postfinance' ),
         url(r'^success/$', self.postfinance_return_successful_view, name='postfinance_success'),
         url(r'^instantpaymentnotification/$', csrf_exempt(self.postfinance_ipn), name='postfinance_ipn'),
         url(r'^somethinghardtoguess/instantpaymentnotification/$', csrf_exempt(self.postfinance_ipn), kwargs={'deprecated': True}),
     )
     return urlpatterns
Exemplo n.º 3
0
 def urls(cls):
     resource_name = cls._meta.resource_name
     pk_pattern = cls._meta.pk_pattern
     urlpatterns = patterns('',
         url(r"^(?P<resource_name>%s)/$" % (resource_name, ), csrf_exempt(cls.as_view()), name=resource_name),
         url(r"^(?P<resource_name>%s)/%s/$" % (resource_name, pk_pattern), csrf_exempt(cls.as_view()), name=resource_name),
     )
     return urlpatterns
Exemplo n.º 4
0
def include_resource(resource, single_name=None, collection_name=None):
    '''
    include resource urls for single and collection access
    '''
    urlpatterns = patterns('',
        # url for resource collection access
        url( r'^/(?P<id>[0-9]+)/?$', csrf_exempt(resource(single)), name=single_name ),
        # url for single resource access
        url( r'^/?$',                csrf_exempt(resource(collection)), name=collection_name ),
    )
    return include( urlpatterns )
Exemplo n.º 5
0
 def get_urls(self):
     urlpatterns = patterns('',
         url(r'^$', self.make_request, name='sofort'),
         url(r'^success/$', self.success, name='sofort_success'),
         url(r'^notify/$', csrf_exempt(self.notify), name='sofort_notify'),
     )
     return urlpatterns
Exemplo n.º 6
0
def wrap_api_function(site, view, detail_level, allowed_methods, processor):
	"""
	A decorator which wraps certain functions, so that a number of checks can be run before the function
	is called (ie: checking that the HTTP method is allowed).
	"""
	
	def wrapper(request, format, *args, **kwargs):
		if not request.method in allowed_methods:
			return HttpResponse('')
		
		response = site.api_view(
			view, request, format, *args,
			detail_level = detail_level + (request.method == 'POST' and 1 or 0),
			processor = processor,
			**kwargs
		)
		
		patch_vary_headers(response,
			('X-Platform', 'X-Device', 'Cookie')
		)
		
		return response
	
	return csrf_exempt(
		update_wrapper(wrapper, view)
	)
Exemplo n.º 7
0
def api_function(view_func):
    if settings.DEBUG:
        return view_func
    else:
        # TODO: Check OAuth -- if this is authorized, then allow it a
        # and mark it as not needing csrf.
        return csrf_exempt(view_func)
Exemplo n.º 8
0
def _patch_pattern(regex_pattern):
    """
    Patch pattern callback using csrf_exempt. Enforce
    RegexURLPattern callback to get resolved if required.

    """
    if hasattr(regex_pattern, "_get_callback"):  # Django==1.2
        if not regex_pattern._callback:
            # enforce _callback resolving
            regex_pattern._get_callback()

        regex_pattern._callback = \
            csrf.csrf_exempt(regex_pattern._callback)
    else:
        regex_pattern._callback = \
            csrf.csrf_exempt(regex_pattern.callback)
Exemplo n.º 9
0
    def test_minimum_data_fills_user(self):
        request = self.requests.post('/')
        request._user = self.user

        resp = csrf_exempt(views.handle_post)(request)
        assert resp.status_code == 200
        assert resp.data['status'] == 'success'
Exemplo n.º 10
0
 def test_csrf_exempt(self):
     # This is an odd test. We're testing that, when a view is csrf_exempt,
     # process_view will bail without performing any processing.
     request = RequestFactory().post('/', HTTP_X_CSRFTOKEN="aB$AHM")
     middleware = CSRFCryptMiddleware()
     middleware.process_view(request, csrf_exempt(test_view), (), {})
     self.assertEqual("aB$AHM", request.META['HTTP_X_CSRFTOKEN'])
Exemplo n.º 11
0
    def as_view(cls, **initkwargs):
        """
        Store the original class on the view function.

        This allows us to discover information about the view when we do URL
        reverse lookups.  Used for breadcrumb generation.
        """
        if isinstance(getattr(cls, "queryset", None), models.query.QuerySet):

            def force_evaluation():
                raise RuntimeError(
                    "Do not evaluate the `.queryset` attribute directly, "
                    "as the result will be cached and reused between requests. "
                    "Use `.all()` or call `.get_queryset()` instead."
                )

            cls.queryset._fetch_all = force_evaluation

        view = super(APIView, cls).as_view(**initkwargs)
        view.cls = cls
        view.initkwargs = initkwargs

        # Note: session based authentication is explicitly CSRF validated,
        # all other authentication is CSRF exempt.
        return csrf_exempt(view)
Exemplo n.º 12
0
    def get_urls(self):
        from django.conf.urls import url, include

        urlpatterns = [
            # filebrowser urls (views)
            url(r"^browse/$", path_exists(self, self.filebrowser_view(self.browse)), name="fb_browse"),
            url(r"^createdir/", path_exists(self, self.filebrowser_view(self.createdir)), name="fb_createdir"),
            url(r"^upload/", path_exists(self, self.filebrowser_view(self.upload)), name="fb_upload"),
            url(
                r"^delete_confirm/$",
                file_exists(self, path_exists(self, self.filebrowser_view(self.delete_confirm))),
                name="fb_delete_confirm",
            ),
            url(
                r"^delete/$", file_exists(self, path_exists(self, self.filebrowser_view(self.delete))), name="fb_delete"
            ),
            url(
                r"^detail/$", file_exists(self, path_exists(self, self.filebrowser_view(self.detail))), name="fb_detail"
            ),
            url(
                r"^version/$",
                file_exists(self, path_exists(self, self.filebrowser_view(self.version))),
                name="fb_version",
            ),
            # non-views
            # url(r'^upload_file/$', staff_member_required(csrf_exempt(self._upload_file)), name="fb_do_upload"),
            url(r"^upload_file/$", login_required(csrf_exempt(self._upload_file)), name="fb_do_upload"),
        ]

        return urlpatterns
Exemplo n.º 13
0
def jsonrpc(func):
    @wraps(func)
    def wrapper(request):
        if request.method != 'POST':
            return HttpResponse('You seem to be lost.',
                                content_type='text/plain')
        try:
            args = json.loads(request.raw_post_data)
        except:
            return HttpResponse(json.dumps({'error': 'Malformed JSON args'}),
                                content_type='text/json')
        auth_token = args.get('auth_token')
        if auth_token is None:
            token = None
            user = None
        else:
            try:
                token = AuthToken.objects.get(tokenstring=auth_token)
            except AuthToken.DoesNotExist:
                token = None
                user = None
            else:
                if (token.user.profile and
                    token.user.profile.characterid is not None):
                    # Authenticated!
                    user = token.user
                else:
                    user = None
        try:
            return HttpResponse(json.dumps({'result': func(user, args)}),
                                content_type='text/json')
        except RPCError as e:
            return HttpResponse(json.dumps({'error': str(e)}),
                                content_type='text/json')
    return csrf_exempt(wrapper)
Exemplo n.º 14
0
    def get_urls(self):
        "URLs for a filebrowser.site"
        try:
            from django.conf.urls import url, patterns
        except ImportError:
            # for Django version less then 1.4
            from django.conf.urls.defaults import url, patterns

        # filebrowser urls (views)
        urlpatterns = patterns(
            "",
            url(r"^browse/$", path_exists(self, filebrowser_view(self.browse)), name="fb_browse"),
            url(r"^createdir/", path_exists(self, filebrowser_view(self.createdir)), name="fb_createdir"),
            url(r"^upload/", path_exists(self, filebrowser_view(self.upload)), name="fb_upload"),
            url(
                r"^delete_confirm/$",
                file_exists(self, path_exists(self, filebrowser_view(self.delete_confirm))),
                name="fb_delete_confirm",
            ),
            url(r"^delete/$", file_exists(self, path_exists(self, filebrowser_view(self.delete))), name="fb_delete"),
            url(r"^detail/$", file_exists(self, path_exists(self, filebrowser_view(self.detail))), name="fb_detail"),
            url(r"^version/$", file_exists(self, path_exists(self, filebrowser_view(self.version))), name="fb_version"),
            url(r"^upload_file/$", staff_member_required(csrf_exempt(self._upload_file)), name="fb_do_upload"),
        )
        return urlpatterns
Exemplo n.º 15
0
    def as_view(cls, **initkwargs):
        """
        Store the original class on the view function.

        This allows us to discover information about the view when we do URL
        reverse lookups.  Used for breadcrumb generation.
        """
        # 价差queryset属性是不是django的QuerySet对象;通常定义queryset=ClassModel.objects.all()
        if isinstance(getattr(cls, 'queryset', None), models.query.QuerySet):
            def force_evaluation():
                raise RuntimeError(
                    'Do not evaluate the `.queryset` attribute directly, '
                    'as the result will be cached and reused between requests. '
                    'Use `.all()` or call `.get_queryset()` instead.'
                )
            # django中查询所有数据是通过_fetch_all方法来执行的
            cls.queryset._fetch_all = force_evaluation
        # 调用View返回的view视图函数 view中回去调用dispatch方法
        view = super(APIView, cls).as_view(**initkwargs)
        # 给视图函数指明类名和以及初始化参数,方便在异常处理中去调用
        view.cls = cls
        view.initkwargs = initkwargs

        # Note: session based authentication is explicitly CSRF validated,
        # all other authentication is CSRF exempt.
        return csrf_exempt(view)
Exemplo n.º 16
0
def get_urls():
    urls = []
    urls.extend(get_module_urls())

    urls.extend([
        admin_url(r'^$', DashboardView.as_view(), name='dashboard', permissions=()),
        admin_url(r'^home/$', HomeView.as_view(), name='home', permissions=()),
        admin_url(r'^wizard/$', WizardView.as_view(), name='wizard', permissions=()),
        admin_url(r'^tour/$', TourView.as_view(), name='tour', permissions=()),
        admin_url(r'^search/$', SearchView.as_view(), name='search', permissions=()),
        admin_url(r'^select/$', MultiselectAjaxView.as_view(), name='select', permissions=()),
        admin_url(r'^edit/$', EditObjectView.as_view(), name='edit', permissions=()),
        admin_url(r'^menu/$', MenuView.as_view(), name='menu', permissions=()),
        admin_url(r'^toggle-menu/$', MenuToggleView.as_view(), name='menu_toggle', permissions=()),
        admin_url(
            r'^login/$',
            login,
            kwargs={"template_name": "shuup/admin/auth/login.jinja"},
            name='login',
            require_authentication=False,
            permissions=()
        ),
        admin_url(
            r'^logout/$',
            auth_views.logout,
            kwargs={"template_name": "shuup/admin/auth/logout.jinja"},
            name='logout',
            require_authentication=False,
            permissions=()
        ),
        admin_url(
            r'^recover-password/(?P<uidb64>.+)/(?P<token>.+)/$',
            ResetPasswordView,
            name='recover_password',
            require_authentication=False,
            permissions=()
        ),
        admin_url(
            r'^request-password/$',
            RequestPasswordView,
            name='request_password',
            require_authentication=False,
            permissions=()
        ),
        admin_url(
            r'^set-language/$',
            csrf_exempt(set_language),
            name="set-language",
            permissions=()
        ),
    ])

    for u in urls:  # pragma: no cover
        if not isinstance(u, AdminRegexURLPattern):
            warnings.warn("Admin URL %r is not an AdminRegexURLPattern" % u)

    # Add Django javascript catalog url
    urls.append(url(r'^i18n.js$', javascript_catalog_all, name='js-catalog'))

    return tuple(urls)
Exemplo n.º 17
0
def get_urls():
    urls = []
    urls.extend(get_module_urls())

    urls.extend(
        [
            admin_url(r"^$", DashboardView.as_view(), name="dashboard"),
            admin_url(r"^search/$", SearchView.as_view(), name="search"),
            admin_url(r"^menu/$", MenuView.as_view(), name="menu"),
            admin_url(
                r"^login/$",
                login,
                kwargs={"template_name": "shoop/admin/auth/login.jinja"},
                name="login",
                require_authentication=False,
            ),
            admin_url(
                r"^logout/$",
                auth_views.logout,
                kwargs={"template_name": "shoop/admin/auth/logout.jinja"},
                name="logout",
                require_authentication=False,
            ),
            admin_url(r"^set-language/$", csrf_exempt(set_language), name="set-language"),
        ]
    )

    for u in urls:  # pragma: no cover
        if not isinstance(u, AdminRegexURLPattern):
            warnings.warn("Admin URL %r is not an AdminRegexURLPattern" % u)

    # Add Django javascript catalog url
    urls.append(url(r"^i18n.js$", javascript_catalog_all, name="js-catalog"))

    return tuple(urls)
Exemplo n.º 18
0
    def get_urls(self):
        from django.conf.urls.defaults import patterns, url, include

        urlpatterns = patterns(
            "",
            # filebrowser urls (views)
            url(r"^browse/$", path_exists(self, self.filebrowser_view(self.browse)), name="fb_browse"),
            url(r"^createdir/", path_exists(self, self.filebrowser_view(self.createdir)), name="fb_createdir"),
            url(r"^upload/", path_exists(self, self.filebrowser_view(self.upload)), name="fb_upload"),
            url(
                r"^delete_confirm/$",
                file_exists(self, path_exists(self, self.filebrowser_view(self.delete_confirm))),
                name="fb_delete_confirm",
            ),
            url(
                r"^delete/$", file_exists(self, path_exists(self, self.filebrowser_view(self.delete))), name="fb_delete"
            ),
            url(
                r"^detail/$", file_exists(self, path_exists(self, self.filebrowser_view(self.detail))), name="fb_detail"
            ),
            url(
                r"^version/$",
                file_exists(self, path_exists(self, self.filebrowser_view(self.version))),
                name="fb_version",
            ),
            # non-views
            url(r"^upload_file/$", csrf_exempt(self._upload_file), name="fb_do_upload"),
        )

        return urlpatterns
Exemplo n.º 19
0
def authenticate(request):
    csrf_exempt(authenticate)
    user=request.POST["username"]
    json=simplejson.dumps("")
    pwd=request.POST["password"]
    if(request.is_ajax()):
        u=usr.objects.get(username=user,password=pwd)
        if u is not None:
            request.session['userid'] = u.id
            message = {"uid": u.id, "uname": user,"status":"success"}

        else:
            message={"status": "fail"}

        json=simplejson.dumps(message)
    return HttpResponse(json,mimetype="application/json")
Exemplo n.º 20
0
    def as_view(cls, actions=None, **initkwargs):
        """
        Because of the way class based views create a closure around the
        instantiated view, we need to totally reimplement `.as_view`,
        and slightly modify the view function that is created and returned.
        """
        # The suffix initkwarg is reserved for identifying the viewset type
        # eg. 'List' or 'Instance'.
        cls.suffix = None

        # actions must not be empty
        if not actions:
            raise TypeError("The `actions` argument must be provided when "
                            "calling `.as_view()` on a ViewSet. For example "
                            "`.as_view({'get': 'list'})`")

        # sanitize keyword arguments
        for key in initkwargs:
            if key in cls.http_method_names:
                raise TypeError("You tried to pass in the %s method name as a "
                                "keyword argument to %s(). Don't do that."
                                % (key, cls.__name__))
            if not hasattr(cls, key):
                raise TypeError("%s() received an invalid keyword %r" % (
                    cls.__name__, key))

        def view(request, *args, **kwargs):
            self = cls(**initkwargs)
            # We also store the mapping of request methods to actions,
            # so that we can later set the action attribute.
            # eg. `self.action = 'list'` on an incoming GET request.
            self.action_map = actions

            # Bind methods to actions
            # This is the bit that's different to a standard view
            for method, action in actions.items():
                handler = getattr(self, action)
                setattr(self, method, handler)

            # Patch this in as it's otherwise only present from 1.5 onwards
            if hasattr(self, 'get') and not hasattr(self, 'head'):
                self.head = self.get

            # And continue as usual
            return self.dispatch(request, *args, **kwargs)

        # take name and docstring from class
        update_wrapper(view, cls, updated=())

        # and possible attributes set by decorators
        # like csrf_exempt from dispatch
        update_wrapper(view, cls.dispatch, assigned=())

        # We need to set these on the view function, so that breadcrumb
        # generation can pick out these bits of information from a
        # resolved URL.
        view.cls = cls
        view.suffix = initkwargs.get('suffix', None)
        view.actions = actions
        return csrf_exempt(view)
Exemplo n.º 21
0
def wrap_api_function(site, view, detail_level, allowed_methods, processor, verbose_name = None):
	"""
	A decorator which wraps certain functions, so that a number of checks can be run before the function
	is called (ie: checking that the HTTP method is allowed).
	"""

	def wrapper(request, format, *args, **kwargs):
		if not request.method in allowed_methods:
			return HttpResponse('')

		response = site.api_view(
			view, request, format, *args,
			detail_level = detail_level + (request.method == 'POST' and 1 or 0),
			processor = processor,
			**kwargs
		)

		if isinstance(response, HttpResponse):
			patch_vary_headers(response,
				getattr(settings, 'API_CACHE_VARY_HEADERS', ('Cookie',))
			)

		return response

	wrapped = csrf_exempt(
		update_wrapper(wrapper, view)
	)

	wrapped.api_verbose_name = verbose_name
	wrapped.api_call_type = 'view'
	return wrapped
Exemplo n.º 22
0
 def get_urls(self):
     urlpatterns = patterns(
         '',
         url(r'^pay/(?P<order_id>[0-9]+)/$', self.payment_redirect_view.as_view(), name='payment-redirect-form'),
         url(r'^post/$', csrf_exempt(self.ecard_response_view.as_view())),
     )
     return urlpatterns
Exemplo n.º 23
0
 def test_get_token_for_exempt_view(self):
     """
     Check that get_token still works for a view decorated with 'csrf_exempt'.
     """
     req = self._get_GET_csrf_cookie_request()
     CsrfViewMiddleware().process_view(req, csrf_exempt(token_view), (), {})
     resp = token_view(req)
     self._check_token_present(resp)
Exemplo n.º 24
0
Arquivo: api.py Projeto: ageron/commis
 def get_urls(self):
     urlpatterns = patterns('')
     dispatch_views = self.dispatch_views.items()
     dispatch_views.sort(key=lambda x: len(x[0]), reverse=True)
     for url_pattern, dispatch_view in dispatch_views:
         bound_view = dispatch_view(self)
         urlpatterns.append(url(url_pattern, csrf_exempt(bound_view), name=bound_view.name))
     return urlpatterns
Exemplo n.º 25
0
def secure_write(func):
    """Depending on configuration, wrap each request in the appropriate
    security checks"""
    func = csrf_exempt(func)
    if settings.HTTP_AUTH_USER and settings.HTTP_AUTH_PASSWORD:
        func = basic_auth(func)

    return func
Exemplo n.º 26
0
 def test_process_request_csrf_cookie_no_token_exempt_view(self):
     """
     Check that if a CSRF cookie is present and no token, but the csrf_exempt
     decorator has been applied to the view, the middleware lets it through
     """
     req = self._get_POST_csrf_cookie_request()
     req2 = CsrfViewMiddleware().process_view(req, csrf_exempt(post_form_view), (), {})
     self.assertIsNone(req2)
Exemplo n.º 27
0
 def dispatch(self, *args, **kwargs):
     original = super(DynaformMixin, self)
     if self.disable_csrf:
         response = csrf_exempt(original.dispatch)(*args, **kwargs)
     else:
         response = original.dispatch(*args, **kwargs)
     response['P3P'] = 'CP="Link b"'
     return response
Exemplo n.º 28
0
def simple_handler_view(handler_class):
    handler = handler_class()
    methods_decorator = require_http_methods(list(handler.allowed_methods))

    def output_view(request, *args, **kwargs):
        return handler.handle_request(request, *args, **kwargs)

    return methods_decorator(csrf_exempt(json_view(output_view)))
Exemplo n.º 29
0
 def as_view(cls, **kwargs):
     """
     Optionally decorates the base view function with
     django.views.decorators.csrf.csrf_exempt().
     
     """
     view = super(CsrfExempt, cls).as_view(**kwargs)
     return csrf.csrf_exempt(view) if cls.csrf_exempt else view
Exemplo n.º 30
0
def _patch_pattern(regex_pattern):
    """
    Patch pattern callback using csrf_exempt. Enforce
    RegexURLPattern callback to get resolved if required.

    """
    regex_pattern._callback = \
        csrf.csrf_exempt(regex_pattern.callback)
Exemplo n.º 31
0
router.register(r"tags", TagViewSet)

urlpatterns = [

    # API
    url(r"^api/auth/",
        include('rest_framework.urls', namespace="rest_framework")),
    url(r"^api/", include(router.urls, namespace="drf")),

    # File downloads
    url(r"^fetch/(?P<kind>doc|thumb)/(?P<pk>\d+)$",
        FetchView.as_view(),
        name="fetch"),

    # File uploads
    url(r"^push$", csrf_exempt(PushView.as_view()), name="push"),

    # The Django admin
    url(r"admin/", admin.site.urls),

    # Redirect / to /admin
    url(r"^$",
        RedirectView.as_view(permanent=True, url=reverse_lazy("admin:index"))),
] + static.static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

# Text in each page's <h1> (and above login form).
admin.site.site_header = 'Paperless'
# Text at the end of each page's <title>.
admin.site.site_title = 'Paperless'
# Text at the top of the admin index page.
admin.site.index_title = 'Paperless administration'
Exemplo n.º 32
0
from .views import views
from .views.register import Register
from .views.login import Login
from .views.logout import logout_view
from .views.make_order import MakeOrder
from .views.update_users_permissions import UpdateUsersPermissions
from .views.medicines_filtering import MedicineFilter
from .views.get_substitutes_strings import GetSubstitutesStrings
from .views.add_medicine import AddMedicine

urlpatterns = [
    url(r'^$', views.index, name='index'),
    url(r'^register$', Register.as_view(), name='register'),
    url(r'^login$', Login.as_view(), name='login'),
    url(r'^logout$', logout_view, name='logout_view'),
    url(r'^make-order$', MakeOrder.as_view(), name='make_order'),
    url('^users/updateUsersPermissions$',
        UpdateUsersPermissions.as_view(),
        name='update_users_permissions'),
    url('^medicines_filtering$',
        MedicineFilter.as_view(),
        name='medicines_filtering'),
    url(r'^get_substitutes_strings$',
        GetSubstitutesStrings.as_view(),
        name='get_substitutes_strings'),
    url(r'^add_medicine$',
        csrf_exempt(AddMedicine.as_view()),
        name='add_medicine'),
]
Exemplo n.º 33
0
from django.urls import path
from django.views.decorators.csrf import csrf_exempt

from core import views

urlpatterns = [
    path('', views.index),
    path('telegram_bot_path',
         csrf_exempt(views.TelegramBotWebhookView.as_view()))
]
Exemplo n.º 34
0
try:
    from django.urls import url
except ImportError:
    from django.conf.urls import url
from django.views.decorators.csrf import csrf_exempt

from oidc_provider import (
    settings,
    views,
)

app_name = 'oidc_provider'
urlpatterns = [
    url(r'^authorize/?$', views.AuthorizeView.as_view(), name='authorize'),
    url(r'^token/?$', csrf_exempt(views.TokenView.as_view()), name='token'),
    url(r'^userinfo/?$', csrf_exempt(views.userinfo), name='userinfo'),
    url(r'^end-session/?$', views.EndSessionView.as_view(),
        name='end-session'),
    url(r'^\.well-known/openid-configuration/?$',
        views.ProviderInfoView.as_view(),
        name='provider-info'),
    url(r'^jwks/?$', views.JwksView.as_view(), name='jwks'),
]

if settings.get('OIDC_SESSION_MANAGEMENT_ENABLE'):
    urlpatterns += [
        url(r'^check-session-iframe/?$',
            views.CheckSessionIframeView.as_view(),
            name='check-session-iframe'),
    ]
Exemplo n.º 35
0
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# __author__ = "lyon"
"""
API 文档URLS :
    url(r'^$', csrf_exempt(DocsView.as_view())),
    url(r'^login/$', csrf_exempt(LoginDocsView.as_view())),
    url(r'^logout/$', csrf_exempt(LogoutDocsView.as_view())),
"""

from django.conf.urls import url
from django.views.decorators.csrf import csrf_exempt
from docs.view import DocsView, LoginDocsView, LogoutDocsView

urlpatterns = [
    url(r'^$', csrf_exempt(DocsView.as_view())),
    url(r'^login/$', csrf_exempt(LoginDocsView.as_view())),
    url(r'^logout/$', csrf_exempt(LogoutDocsView.as_view())),
]
Exemplo n.º 36
0
from django.contrib import admin
from django.urls import path, include
from django.views.decorators.csrf import csrf_exempt
from rest_framework import routers

from Livraria.Accounts.views import AccountsViewSet
from Livraria.Books.views import BooksViewSet, book_by_user_id, reserve_by_id_client, return_by_id_client

router = routers.DefaultRouter()
router.register(r'Books', BooksViewSet)
router.register(r'Accounts', AccountsViewSet)

urlpatterns = [
    path('admin/', admin.site.urls),
    path('client/<int:id_client>/books', book_by_user_id),
    path('books/<int:id_book>/reserve/<int:id_client>',
         csrf_exempt(reserve_by_id_client)),
    path('books/<int:id_book>/return/<int:id_client>',
         csrf_exempt(return_by_id_client)),
    path('', include(router.urls)),
]
Exemplo n.º 37
0
from graphene_django.views import GraphQLView
from refreshtoken.views import delegate_jwt_token
from rest_framework_jwt.views import obtain_jwt_token, verify_jwt_token

from apiv2.views import generate_basic_auth_token
from bestiary.autocomplete import *
from herders import views as herder_views
from herders.autocomplete import *
from herders.forms import CrispyAuthenticationForm, CrispyPasswordChangeForm, CrispyPasswordResetForm, \
    CrispySetPasswordForm

urlpatterns = [
    # AJAX-y stuff first
    url(
        r'graphql',
        csrf_exempt(GraphQLView.as_view(
            graphiql=True)) if settings.DEBUG else GraphQLView.as_view()),
    url(
        r'^autocomplete/',
        include([
            url(r'^bestiary/$',
                BestiaryAutocomplete.as_view(),
                name='bestiary-monster-autocomplete'),
            url(r'^quick-search/$',
                QuickSearchAutocomplete.as_view(),
                name='bestiary-quicksearch-autocomplete'),
            url(r'^monster-tag/$',
                MonsterTagAutocomplete.as_view(),
                name='monster-tag-autocomplete'),
            url(r'^monster-instance/$',
                MonsterInstanceAutocomplete.as_view(),
                name='monster-instance-autocomplete'),
Exemplo n.º 38
0
from django.conf.urls import url, include
from rest_framework import routers
from . import views
from django.views.decorators.csrf import csrf_exempt

router = routers.DefaultRouter()
router.register(r'stats', views.GameStatViewSet, base_name='game stat')

urlpatterns = [
    url(r'^register', csrf_exempt(views.CreateUser.as_view())),
    url(r'^', include('rest_framework.urls', namespace='rest_framework')),
    url(r'^participant_register',
        csrf_exempt(views.CreateGameParticipant.as_view())),
    url(r'^participant_details/(?P<name>[\w\-]+)',
        csrf_exempt(views.DetailGameParticipant.as_view())),
    url(r'^access/$', csrf_exempt(views.AddGroup.as_view())),
    url(r'^access/(?P<name>[\w\-]+)', csrf_exempt(views.CheckGroup.as_view())),
    url(r'^wordlist/(?P<name>[\w\-]+)',
        csrf_exempt(views.RetrieveWordList.as_view())),
    url(r'^', include(router.urls)),
]

from rest_framework.authtoken import views
urlpatterns += [url(r'^api-auth/', views.obtain_auth_token)]
Exemplo n.º 39
0
"""tracksApp URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.0/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from graphene_django.views import GraphQLView  # bring in graphiql
from django.views.decorators.csrf import csrf_exempt  # allow different clients to interact with data with csrf

urlpatterns = [
    path('admin/', admin.site.urls),
    path('graphql/', csrf_exempt(GraphQLView.as_view(
        graphiql=True)))  # add url pattern to visit graphiql
]
Exemplo n.º 40
0
    url(r'^adduser/$', AdduserView.as_view(), name='adduser'),
    #文件上传 AdduserdetailView
    url(r'^adduserdet/$', AdduserdetailView.as_view(), name='adduserdet'),
    #配置media文件缓存
    url(r'^media/(?P<path>.*)$', serve,
        {'document_root': settings.MEDIA_ROOT}),
    #统计分析
    url(r'^tj/$', StatisticalView.as_view(), name='tj'),
    #统计分析学院
    url(r'^tjcollage/$', StacollageView.as_view(), name='tjcollage'),
    # 关联分析
    url(r'^associate/$', AssociateView.as_view(), name='associate'),

    #助学到学情自动登录
    url(r'^autologin/(\d+)/(.*)/(.*)$',
        csrf_exempt(AutoLogin.as_view()),
        name='autologin'),

    #涉及技能
    url(r'^AboutTc/$', AboutTc.as_view(), name='AboutTc'),

    #助学进度
    url(r'^hplan/$', Helplan.as_view(), name='hplan'),

    #插入信息
    # url(r'^insertmsg/$', InsertStudnetMSG.as_view(), name='insertmsg'),
]
# #全局404配置
# handler404 = 'users.views.page_not_found'
# handler500 = 'users.views.page_error'
# handler503 = 'users.views.page_reject'
Exemplo n.º 41
0
from .views import (CajasList, CreateCaja)
from django.conf.urls import url
from django.views.decorators.csrf import csrf_exempt

urlpatterns = [
    url(r'^cajas/', CajasList, name='listaCaja'),
    url(r'^cajasCreate/', csrf_exempt(CreateCaja), name='crearCaja')
]


Exemplo n.º 42
0
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""

# from django.contrib import admin
# from django.urls import path
# from django.views.decorators.csrf import csrf_exempt

# from graphene_django.views import GraphQLView

# from staff.schema import schema

# urlpatterns = [
#     path("admin/", admin.site.urls),
#     path("graphql/", csrf_exempt(GraphQLView.as_view(graphiql=True, schema=schema))),
# ]

from django.contrib import admin
from django.urls import path
from django.views.decorators.csrf import csrf_exempt

from graphene_django.views import GraphQLView

from staff.schema import schema

urlpatterns = [
    path("admin/", admin.site.urls),
    path("graphql/", csrf_exempt(GraphQLView.as_view(graphiql=True, schema=schema))),
]
Exemplo n.º 43
0
from graphene_django.views import GraphQLView
from django.views.decorators.csrf import csrf_exempt
from django.urls import path, re_path, include
from .views import GeneratePDF
from payment.views import checkout


class UserSerializer(serializers.ModelSerializer):
    class Meta:
        model = User
        fields = ['url', 'username']


class UserViewSet(viewsets.ModelViewSet):
    queryset = User.objects.all()
    serializer_class = UserSerializer


router = routers.DefaultRouter()
router.register(r'users', UserViewSet)

urlpatterns = [
    path('', include(router.urls)),
    path("admin/", admin.site.urls),
    re_path(r"^graphql/$", csrf_exempt(GraphQLView.as_view(graphiql=True))),
    re_path(r"^graphql/pdf/$", csrf_exempt(GeneratePDF.as_view())),
    re_path(r"^graphql/create-charge/$", csrf_exempt(checkout)),
    path('api-auth/', include('rest_framework.urls',
                              namespace='rest_framework'))
]
Exemplo n.º 44
0
from django.urls import path, re_path, include
from django.views.decorators.csrf import csrf_exempt
from . import views
urlpatterns = [
    path('signup/', views.SignUpView.as_view()),
    path('signup/student/', views.SignUpStudentView.as_view()),
    path('signin/',csrf_exempt(views.SignIn.as_view())),
    path('editprofile/', views.EditProfile.as_view()),
    path('email/', views.RequestForgetEmail.as_view()),
    path('logout/', views.LogOutView.as_view()),
    # path('forgetpassword/', views.RequestForgetEmail.as_view()),
    ]
Exemplo n.º 45
0
from django.urls import path
from django.views.decorators.csrf import csrf_exempt
from . import views

urlpatterns = [
    path('', views.product_list, name='product_list'),
    # path('<slug:category_slug>/', views.product_list, name='product_list_by_category'),
    path('product-details', views.product_details, name='product_details'),
    path('checkout/', views.checkout, name='checkout_list'),
    path('cart', views.cart_list, name='cart_list'),
    path('update_item/', views.updateItem, name='update_item'),
    path('process_order/', views.proceOrder, name='process_order'),
    path('username-valid/',
         csrf_exempt(views.usernameValidation),
         name='username-valid'),
    path('email-validation/',
         csrf_exempt(views.emailValidation),
         name='email-validation'),
]
Exemplo n.º 46
0
    path('blue_ecg1/', views.electrocardiograpy1_blue, name='blue_ecg1'),
    path('blue_ecg2/', views.electrocardiograpy2_blue, name='blue_ecg2'),
    path('blue_ecg3/', views.electrocardiograpy3_blue, name='blue_ecg3'),
    path('blue_ecg/index/',
         views.electrocardiograpy_index_blue,
         name='blue_ecgIndex'),
    path('short/', views.short, name='short'),
    path('win/', views.win, name='win'),
    path('short_term_num/', views.short_term_num, name='short_term'),
    path('mid/', views.mid, name='mid'),
    path('long/', views.long, name='long'),
    path('selectNo/', views.selectNo, name='selectNo'),
    path('showNo/', views.showNo, name='showNo'),
    path('getAnalysisNum/', views.getAnalysisNum, name='getAnalysisNum'),
    # path('notHitTermTable/',views.not_hit_term_table,name='not_hit_term_table'),
    path('tendencyRevertAnalysis/',
         views.tendencyRevertAnalysis,
         name='tendencyRevertAnalysis'),
    path('upThreeWavesAnalysis/',
         views.tendencyRevertAnalysis,
         name='upThreeWavesAnalysis'),
    path('downThreeWavesAnalysis/',
         views.tendencyRevertAnalysis,
         name='downThreeWavesAnalysis'),
    path('midAnalysis/', views.midAnalysis, name='midAnalysis'),
    path('recordNum/', csrf_exempt(views.recordNum), name='recordNum'),
    path('matrix/', csrf_exempt(views.rotaryMaritx), name='matrix'),
    path('selectNumByMatrix/',
         csrf_exempt(views.selectNumByMatrix),
         name='selectNumByMatrix'),
]
Exemplo n.º 47
0
from django.urls import path
from rest_framework.urlpatterns import format_suffix_patterns
from graphene_django.views import GraphQLView
from graphql_jwt.decorators import jwt_cookie
from django.views.decorators.csrf import csrf_exempt

from api.menu import rest_api

app_name = 'menu'

urlpatterns = [
    path('', csrf_exempt(jwt_cookie(rest_api.menu_list))),
    path('<int:pk>', rest_api.menu_detail),
]

urlpatterns = format_suffix_patterns(urlpatterns)
Exemplo n.º 48
0
from django.contrib import admin
from django.urls import path, include
from django.conf.urls.static import static
from django.conf import settings
from django.views.decorators.csrf import csrf_exempt

from graphene_django.views import GraphQLView

urlpatterns = [path("", csrf_exempt(GraphQLView.as_view(graphiql=True)))]
Exemplo n.º 49
0
"""hackernews URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from django.views.decorators.csrf import csrf_exempt
from graphene_django.views import GraphQLView

urlpatterns = [
    path('admin/', admin.site.urls),
    path('graphql/', csrf_exempt(GraphQLView.as_view(graphiql=True))),
    path('', include('links.urls')),
]
Exemplo n.º 50
0
"""MainServer URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from django.views.decorators.csrf import csrf_exempt

from graphene_django.views import GraphQLView

urlpatterns = [
    path('', include('storage.urls')),
    path('admin/', admin.site.urls),
    path("graphql", csrf_exempt(GraphQLView.as_view(graphiql=True))),
]
Exemplo n.º 51
0
    return HttpResponse("Not here yet: %s (%r, %r)" %
                        (request.path, args, kwargs),
                        status=410)


# Use a different js catalog function in front urlpatterns to prevent forcing
# the shop language settings in admin js catalog.
def front_javascript_catalog_all(request, domain='djangojs'):
    from shuup.utils.i18n import javascript_catalog_all
    return javascript_catalog_all(request, domain)


checkout_view = get_checkout_view()

urlpatterns = [
    url(r'^set-language/$', csrf_exempt(set_language), name="set-language"),
    url(r'^i18n.js$', front_javascript_catalog_all, name='js-catalog'),
    url(r'^checkout/$', checkout_view, name='checkout'),
    url(r'^checkout/(?P<phase>.+)/$', checkout_view, name='checkout'),
    url(r'^basket/$', csrf_exempt(BasketView.as_view()), name='basket'),
    url(r'^dashboard/$',
        login_required(DashboardView.as_view()),
        name="dashboard"),
    url(r'^toggle-allseeing/$',
        login_required(toggle_all_seeing),
        name="toggle-all-seeing"),
    url(r'^force-anonymous-contact/$',
        login_required(force_anonymous_contact),
        name="force-anonymous-contact"),
    url(r'^force-company-contact/$',
        login_required(force_company_contact),
Exemplo n.º 52
0
from django.conf.urls import include, url

#Django Rest Framework
from rest_framework import routers

from api import controllers
from django.views.decorators.csrf import csrf_exempt

#REST API routes
router = routers.DefaultRouter(trailing_slash=False)

urlpatterns = [
    url(r'^dogs', csrf_exempt(controllers.DogList.as_view())),
    url(r'^dogs/<pk>', csrf_exempt(controllers.DogDetail.as_view())),
    url(r'^breeds', csrf_exempt(controllers.BreedList.as_view())),
    url(r'^breeds/<pk>', csrf_exempt(controllers.BreedDetail.as_view())),
    url(r'^session', csrf_exempt(controllers.Session.as_view())),
    url(r'^register', csrf_exempt(controllers.Register.as_view())),
    url(r'^events', csrf_exempt(controllers.Events.as_view())),
    url(r'^activateifttt', csrf_exempt(controllers.ActivateIFTTT.as_view())),
    url(r'^', include(router.urls)),
]
Exemplo n.º 53
0
from django.conf import settings
from django.contrib import admin
# from django.contrib.auth.views import LoginView
from gsmap.views import CustomLoginView, logout, SnapshotFileUploadView
from django.urls import path
from django.views.decorators.csrf import csrf_exempt
from graphene_django.views import GraphQLView

urlpatterns = [
    path('api/v1/snapshots/<str:snapshot_id>/',
         csrf_exempt(SnapshotFileUploadView.as_view())),
    path('account/login/',
         CustomLoginView.as_view(template_name='registration/login.html'),
         name='login'),
    path('account/logout/', logout, name='logout'),
    path('gmanage/', admin.site.urls),
    path('graphql/', csrf_exempt(GraphQLView.as_view(graphiql=True))),
]

if settings.DEBUG:
    from django.conf.urls.static import static
    from django.contrib.staticfiles.urls import staticfiles_urlpatterns

    urlpatterns += staticfiles_urlpatterns()
    urlpatterns += static(settings.MEDIA_URL,
                          document_root=settings.MEDIA_ROOT)
    urlpatterns += static('/downloads', document_root=settings.MEDIA_ROOT)
Exemplo n.º 54
0
from django.urls import path
from .views import ScooterList, ScooterOperations
from django.views.decorators.csrf import csrf_exempt

urlpatterns = [
    path('', csrf_exempt(ScooterList.as_view())),
    path('<int:id>', csrf_exempt(ScooterOperations.as_view())),
]
Exemplo n.º 55
0
from django.conf.urls import include, url
from django.contrib import admin

from wagtail.wagtailadmin import urls as wagtailadmin_urls
from wagtail.wagtailcore import urls as wagtail_urls
from wagtail.wagtaildocs import urls as wagtaildocs_urls

from search import views as search_views

from django.views.decorators.csrf import csrf_exempt
from graphene_django.views import GraphQLView

#from ui_mgmt import urls as ui_mgmt_urls

urlpatterns = [
    url(r'^api/graphql', csrf_exempt(GraphQLView.as_view())),
    url(r'^api/graphiql',
        csrf_exempt(GraphQLView.as_view(graphiql=True, pretty=True))),
    url(r'^django-admin/', include(admin.site.urls)),
    url(r'^admin/', include(wagtailadmin_urls)),
    url(r'^documents/', include(wagtaildocs_urls)),
    url(r'^_search/$', search_views.search, name='search'),
    #url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
    #url(r'^rest-api/', include(ui_mgmt_urls)),

    # For anything not caught by a more specific rule above, hand over to
    # Wagtail's page serving mechanism. This should be the last pattern in
    # the list:
    url(r'', include('puput.urls')),
    url(r'', include(wagtail_urls)),
Exemplo n.º 56
0
urlpatterns += [
    # API base url
    path("api/", include("config.api_router")),
    # DRF auth token
    path("auth-token/", obtain_auth_token),
    # DRF API docs
    path("api-docs/",
         include_docs_urls(title="web-interactive REST API", public=False)),
]

# API URLS
urlpatterns += [
    # GraphQL
    path(
        "graphql/",
        csrf_exempt(FileUploadGraphQLView.as_view(graphiql=True,
                                                  pretty=True))),
]

if settings.DEBUG:
    # This allows the error pages to be debugged during development, just visit
    # these url in browser to see how these error pages look like.
    urlpatterns += [
        path(
            "400/",
            default_views.bad_request,
            kwargs={"exception": Exception("Bad Request!")},
        ),
        path(
            "403/",
            default_views.permission_denied,
            kwargs={"exception": Exception("Permission Denied")},
Exemplo n.º 57
0
from __future__ import unicode_literals
from django.conf.urls import patterns, url
from django.views.decorators.csrf import csrf_exempt
from views import FacebookTokenView, CreatePublicationJson

urlpatterns = patterns(
    '',
    url(r'^facebook_token/',
        csrf_exempt(FacebookTokenView.as_view()),
        name='social_media_facebook'),
    url(r'^publication.json',
        csrf_exempt(CreatePublicationJson.as_view()),
        name='social_media_publication_json'))
Exemplo n.º 58
0
from django.conf.urls import url
from django.views.decorators.csrf import csrf_exempt
from getpaid.backends.epaydk.views import CallbackView, AcceptView, CancelView


urlpatterns = [
    url(r'^online/(?P<secret_path>[a-zA-Z0-9]{32,96})/$',
        csrf_exempt(CallbackView.as_view()),
        name='online'),
    url(r'^online/$',
        csrf_exempt(CallbackView.as_view()),
        name='online'),
    url(r'^success/',
        csrf_exempt(AcceptView.as_view()),
        name='success'),
    url(r'^failure/',
        csrf_exempt(CancelView.as_view()),
        name='failure'),
]
Exemplo n.º 59
0
from django.urls import path
from django.views.decorators.csrf import csrf_exempt
from .views import login, UserAPI, AddresAPIView

urlpatterns = [
    path('login', csrf_exempt(login), name='login'),
    path('user', csrf_exempt(UserAPI.as_view()), name='user_list'),
    path('address', csrf_exempt(AddresAPIView.as_view()))
]
Exemplo n.º 60
0
        name='questionary_detail_view'),
    #compare two candidates
    url(r'^eleccion/(?P<slug>[-\w]+)/face-to-face/(?P<slug_candidate_one>[-\w]+)/(?P<slug_candidate_two>[-\w]+)/?$',
        cache_page(60 * settings.CACHE_MINUTES)(FaceToFaceView.as_view(template_name='elections/compare_candidates.html')),
        name='face_to_face_two_candidates_detail_view'),
    #one candidate for compare
    url(r'^eleccion/(?P<slug>[-\w]+)/face-to-face/(?P<slug_candidate_one>[-\w]+)/?$',
        cache_page(60 * settings.CACHE_MINUTES)(ElectionDetailView.as_view(template_name='elections/compare_candidates.html')),
        name='face_to_face_one_candidate_detail_view'),
    #no one candidate
    url(r'^eleccion/(?P<slug>[-\w]+)/face-to-face/?$',
        cache_page(60 * settings.CACHE_MINUTES)(ElectionDetailView.as_view(template_name='elections/compare_candidates.html')),
        name='face_to_face_no_candidate_detail_view'),
    #soulmate
    url(r'^eleccion/(?P<slug>[-\w]+)/soul-mate/?$',
        csrf_exempt(SoulMateDetailView.as_view(template_name='elections/soulmate_candidate.html')),
        name='soul_mate_detail_view'),
    #soulmate
    url(r'^eleccion/(?P<slug>[-\w]+)/embedded-soul-mate/?$',
        xframe_options_exempt(csrf_exempt(SoulMateDetailView.as_view(template_name='elections/soulmate_candidate.html', layout="elections/embedded.html"))),
        name='embedded_soul_mate_detail_view'),

    url(r'^eleccion/(?P<election_slug>[-\w]+)/(?P<slug>[-\w]+)/?$',
        cache_page(60 * settings.CACHE_MINUTES)(CandidateDetailView.as_view(template_name='elections/candidate_detail.html')),
        name='candidate_detail_view'
        ),
    url(r'^candidaturas/(?P<area_slug>[-\w]+)/(?P<slug>[-\w]+)/?$',
        cache_page(60 * settings.CACHE_MINUTES)(CandidateDetailView.as_view(template_name='elections/candidate_detail.html')),
        name='candidate_detail_view_area'
        ),
    # End Preguntales