Example #1
0
 def get_urls(self):
     urls = super(MalasakitAdminSite, self).get_urls()
     urls += [
         url(r'^configuration/$', self.admin_view(self.configuration),
             name='configuration'),
         url(r'^statistics/$', self.admin_view(self.statistics),
             name='statistics'),
         url(r'^change-landing-image/$',
             self.admin_view(require_POST(self.change_landing_image)),
             name='change-landing-image'),
         url(r'^change-bloom-icon/$', self.admin_view(require_POST(self.change_bloom_icon)),
             name='change-bloom-icon'),
     ]
     return urls
Example #2
0
def disconnect_view(func):
    @wraps(func)
    def wrapper(request, *args, **kwargs):
        return func(request, *args, **kwargs)
    if setting('SOCIAL_AUTH_FORCE_POST_DISCONNECT'):
        wrapper = require_POST(csrf_protect(wrapper))
    return wrapper
Example #3
0
    def decorator(request, *args, **kwargs):
        # Here we'll use the twilio library's request validation code to ensure
        # that the current request actually came from twilio, and isn't a
        # forgery if settings.DEBUG is True. If it is a forgery, then we'll
        #return a HTTP 403 error (forbidden).
        if not settings.DEBUG:
            try:
                url = request.build_absolute_uri()
                signature = request.META['HTTP_X_TWILIO_SIGNATURE']
            except (AttributeError, KeyError):
                return HttpResponseForbidden()
    
            validator = RequestValidator(settings.TWILIO_AUTH_TOKEN)
            if not validator.validate(url, request.POST, signature):
                return HttpResponseForbidden()
    
            # Run the wrapped view, and capture the data returned.
            response = require_POST(f(request, *args, **kwargs))
        else:
            response = f(request, *args, **kwargs)

        # If the view returns a string, we'll assume it is XML TwilML data and
        # pass it back with the appropriate mimetype. We won't check the XML
        # data because that would be too time consuming for every request.
        # Instead, we'll let the errors pass through to be dealt with by the
        # developer.
        if isinstance(response, Verb):
            return HttpResponse(response, mimetype='text/xml')
        else:
            return response
Example #4
0
	def get_urls(self):
		from django.conf.urls import patterns, url
		
		info = self.model._meta.app_label, self.model._meta.module_name
		urlpatterns = patterns('',
			url(r'^add/preview/$',
				require_POST(self.admin_site.admin_view(self.preview_view)),
				name = '%s_%s_preview' % info
			),
			url(r'^(.+)/preview/$',
				require_POST(self.admin_site.admin_view(self.preview_view)),
				name = '%s_%s_preview' % info
			)
		)
		
		return urlpatterns + super(PreviewableModelAdmin, self).get_urls()
Example #5
0
    def decorator(request, *args, **kwargs):

        # Only handle Twilio forgery protection stuff if we're running in
        # production. This way, developers can test their Twilio view code
        # without getting errors.
        if not settings.DEBUG:

            # Attempt to gather all required information to allow us to check the
            # incoming HTTP request for forgery. If any of this information is not
            # available, then we'll throw a HTTP 403 error (forbidden).
            #
            # The required fields to check for forged requests are:
            #
            #   1. ``TWILIO_ACCOUNT_SID`` (set in the site's settings module).
            #   2. ``TWILIO_AUTH_TOKEN`` (set in the site's settings module).
            #   3. The full URI of the request, eg: 'http://mysite.com/test/view/'.
            #      This may not necessarily be available if this view is being
            #      called via a unit testing library, or in certain localized
            #      environments.
            #   4. A special HTTP header, ``HTTP_X_TWILIO_SIGNATURE`` which
            #      contains a hash that we'll use to check for forged requests.
            # Ensure the request method is POST
            response = require_POST(f)(request, *args, **kwargs)
            if isinstance(response, HttpResponse):
                return response

            # Validate the request
            try:
                validator = RequestValidator(django_twilio_settings.TWILIO_AUTH_TOKEN)
                url = request.build_absolute_uri()
                signature = request.META['HTTP_X_TWILIO_SIGNATURE']
            except (AttributeError, KeyError):
                return HttpResponseForbidden()

            # Now that we have all the required information to perform forgery
            # checks, we'll actually do the forgery check.
            if not validator.validate(url, request.POST, signature):
                return HttpResponseForbidden()

        # If the user requesting service is blacklisted, reject their
        # request.
        blacklisted_resp = get_blacklisted_response(request)
        if blacklisted_resp:
            return blacklisted_resp

        # Run the wrapped view, and capture the data returned.
        response = f(request, *args, **kwargs)

        # If the view returns a string (or a ``twilio.Verb`` object), we'll
        # assume it is XML TwilML data and pass it back with the appropriate
        # mimetype. We won't check the XML data because that would be too time
        # consuming for every request. Instead, we'll let the errors pass
        # through to be dealt with by the developer.
        if isinstance(response, str):
            return HttpResponse(response, mimetype='application/xml')
        elif isinstance(response, Verb):
            return HttpResponse(str(response), mimetype='application/xml')
        else:
            return response
Example #6
0
def disconnect_view(func):
    @wraps(func)
    def wrapper(request, *args, **kwargs):
        return func(request, *args, **kwargs)

    if setting('SOCIAL_AUTH_FORCE_POST_DISCONNECT'):
        wrapper = require_POST(csrf_protect(wrapper))
    return wrapper
Example #7
0
 def get_urls(self):
     return patterns(
         '',
         url(
             r'^(?P<object_id>\d+)/upload/$',
             require_POST(self.admin_site.admin_view(self.upload)),
         ),
     ) + super(AlbumAdmin, self).get_urls()
Example #8
0
    def test_decorator_order(self):
        # It used to be the case that allow_lazy_user had to be first in the
        # decorator list. This is no longer the case.
        self.request.user = AnonymousUser()
        self.request.method = 'POST'
        v = require_POST(lazy_view)

        response = v(self.request)
        self.assertEqual(200, response.status_code)
Example #9
0
    def test_decorator_order(self):
        # It used to be the case that allow_lazy_user had to be first in the
        # decorator list. This is no longer the case.
        self.request.user = AnonymousUser()
        self.request.method = 'POST'
        v = require_POST(lazy_view)

        response = v(self.request)
        self.assertEqual(200, response.status_code)
Example #10
0
def generic_ajax_func(func):
    return require_POST(
        csrf_protect(
            serialize_as_json(
                param_from_post(
                    func
                )
            )
        )
    )
Example #11
0
def encrypted_json_post(view_func):
    def inner(request, *args, **kwargs):
        try:
            decrypted_body = rsa_decrypt(request.body, SERVER_KEY)
            request.decrypted_json = json.loads(decrypted_body)
            return view_func(request, *args, **kwargs)
        except ValueError:
            msg = "This endpoint expects a JSON object, " "encrypted with the server's public RSA key"
            return HttpResponseBadRequest(msg)

    return csrf_exempt(require_POST(inner))
Example #12
0
 def get_urls(self):
     urls = super(ClonedRepoAdmin, self).get_urls()
     more_urls = patterns('',
         url(r'^(.+)/pull/$',
             self.admin_site.admin_view(self.git_pull_view),
             name='pull'),
         url(r'^update-all$',
             self.admin_site.admin_view(require_POST(self.update_all_view)),
             name='update-all'),
     )
     return more_urls + urls
Example #13
0
def encrypted_json_post(view_func):
    def inner(request, *args, **kwargs):
        try:
            decrypted_body = rsa_decrypt(request.body, SERVER_KEY)
            request.decrypted_json = json.loads(decrypted_body)
            return view_func(request, *args, **kwargs)
        except ValueError:
            msg = ("This endpoint expects a JSON object, "
                   "encrypted with the server's public RSA key")
            return HttpResponseBadRequest(msg)
    return csrf_exempt(require_POST(inner))
Example #14
0
    def get_urls(self):
        from django.conf.urls import patterns, url, include

        def wrap(view):
            def wrapper(*args, **kwargs):
                return self.api_view(view, *args, **kwargs)

            return update_wrapper(wrapper, view)

        urlpatterns = patterns(
            '', url(r'^' + DOCS_ROOT + '/$', self.docs_index_view, name='doc'))

        if not self.auth.app_model is None and getattr(
                settings, 'API_APPS_MANAGEABLE', True):
            urlpatterns += patterns(
                '',
                url(r'^' + APPS_ROOT + '/$',
                    login_required(self.apps_view),
                    name='apps'),
                url(r'^' + APPS_ROOT + '/add/$',
                    require_POST(login_required(self.add_app_view)),
                    name='add_app'),
                url(r'^' + APPS_ROOT + '/(?P<pk>\d+)/$',
                    login_required(self.edit_app_view),
                    name='edit_app'),
                url(r'^' + APPS_ROOT + '/(?P<pk>\d+)/delete/$',
                    login_required(self.delete_app_view),
                    name='delete_app'),
            )

        urlpatterns += patterns(
            '',
            url(r'^' + DOCS_ROOT + '/(?P<app_label>[\w]+)/(?P<model>[/\w]+)/$',
                self.docs_model_view,
                name='doc_model'),
            url(r'^' + DOCS_ROOT + '/(?P<app_label>[\w]+)/$',
                self.docs_app_view,
                name='doc_appindex'),
            url(r'^api/', include(self.auth.get_urls())))

        for model, model_api in self._registry.iteritems():
            urlpatterns += patterns(
                '',
                url(
                    r'^api/%s/%s' %
                    (model._meta.app_label, model._meta.module_name),
                    include(model_api.urls)))

        return urlpatterns
Example #15
0
 def get_urls(self):
     urls = super(StatementAdmin, self).get_urls()
     my_urls = patterns('',
         url(r'^import-url/$', self.admin_site.admin_view(
             self.import_url_view, 
             cacheable=True
         ), name="statements_statement_import_url"),
         url(r'^import-csv/$', self.admin_site.admin_view(
             self.import_csv_view, 
             cacheable=True
         ), name="statements_statement_import_csv"),
         url(r'^process/$', self.admin_site.admin_view(
             require_POST(self.process_view), 
             cacheable=True
         ), name="statements_statement_process")
     )
     return my_urls + urls
Example #16
0
from . import views
from . import api_views

app_name = 'simulator'

urlpatterns = [
    path('', views.index, name='index'),
    path('login', LoginView.as_view(template_name='login.html'), name='login'),
    path('register', views.RegisterView.as_view(), name='register'),
    path('logout', views.logout_view, name='logout'),
    path('stock', views.stock_data, name='stock_data'),
    path('stock/<slug:name>', views.StockDetail.as_view(),
         name='stock_detail'),
    path('buy-stock',
         require_POST(views.StockBuyFormView.as_view()),
         name='buy_stock'),
    path('sell-stock/<int:wallet_pk>',
         views.StockSellFormView.as_view(),
         name='sell_stock'),
    path('account', views.account_view, name='account'),
    path('transaction-history',
         views.transaction_history_view,
         name='transaction-history'),
    path('charge-account',
         views.ChargeAccountView.as_view(),
         name='charge_account'),
    path('download/stock',
         views.download_stock_data,
         name='download_stock_data'),
    path('settings', views.StockSettingsFormView.as_view(), name='settings'),
from django.views.decorators.http import require_http_methods, require_GET, require_POST
from django.views.decorators.vary import vary_on_headers, vary_on_cookie
from django.views.decorators.cache import cache_page, never_cache, cache_control
from django.utils.decorators import method_decorator
from django.contrib.auth.decorators import login_required, permission_required, user_passes_test
from django.contrib.admin.views.decorators import staff_member_required

def fully_decorated(request):
    """Expected __doc__"""
    return HttpResponse('<html><body>dummy</body></html>')
fully_decorated.anything = "Expected __dict__"

# django.views.decorators.http
fully_decorated = require_http_methods(["GET"])(fully_decorated)
fully_decorated = require_GET(fully_decorated)
fully_decorated = require_POST(fully_decorated)

# django.views.decorators.vary
fully_decorated = vary_on_headers('Accept-language')(fully_decorated)
fully_decorated = vary_on_cookie(fully_decorated)

# django.views.decorators.cache
fully_decorated = cache_page(60*15)(fully_decorated)
fully_decorated = cache_control(private=True)(fully_decorated)
fully_decorated = never_cache(fully_decorated)

# django.contrib.auth.decorators
# Apply user_passes_test twice to check #9474
fully_decorated = user_passes_test(lambda u:True)(fully_decorated)
fully_decorated = login_required(fully_decorated)
fully_decorated = permission_required('change_world')(fully_decorated)
Example #18
0
        ctx.update({'options_form': options_form,
                    'widget_class': widget_class_obj})
        model_form = get_model_form_for_widget(widget_class_obj)
        if model_form:
            ctx.update({'model_form': model_form})
            extra_js += model_form.extra_js

        options = o.render(ctx)
        extra_js += options_form.extra_js
        data = {'valid': False, 'type': 'fi', 'data': options, 'extra_js': extra_js}
    else:
        data = ajaxerror(widget_form)
    return HttpResponse(json_serializer.encode(data), mimetype='application/json')


create_widget = require_POST(widget_list)


@login_required
@admin_can(Widget, fail404=True)
def create_widget(request, **kwargs):
    """
    Renders widget options based on supplied widget
    class or displays a select screen
    """
    data = {}
    widget_class = request.POST["widget_class"]
    widget_class_obj = get_widget(widget_class)
    containsModel = hasModel(widget_class_obj)

    slot = request.POST["widgetslot"]
Example #19
0
def no_conflict_require_POST(fn):
    """
    Catches resource conflicts on save and returns a 409 error.
    Also includes require_POST decorator
    """
    return require_POST(no_conflict(fn))
Example #20
0
from django.conf.urls.defaults import url, patterns, include
from django.views.decorators.http import require_GET, require_POST
from . import views, admin
from occupywallst import utils
 
#adminsite = admin.AdminSite(name='rideshareadmin') 

urlpatterns = patterns('rideshare',
    #rides
    url(r'^$', 'views.rides', name='rides'),
    url(r'^create/$', 'views.ride_create', name='ride_create'),
    url(r'^(?P<ride_id>\d+)/$', 'views.ride_info', name='ride_info'),
    url(r'^(?P<ride_id>\d+)/delete/$', 'views.ride_delete', name='ride_delete'),
    url(r'^(?P<ride_id>\d+)/edit/$', 'views.ride_edit', name='ride_edit'),
    #ride requests
    url(r'^(?P<request_id>\d+)/request/view/$', 'views.ride_request_view', name='ride_request_view'),
    url(r'^(?P<ride_id>\d+)/request/add/$', 'views.ride_request_add_update', name='ride_request_add_update'),
    url(r'^(?P<ride_id>\d+)/request/delete/$', 'views.ride_request_delete', name="ride_request_delete"),
    #ride ajax
    url(r'^api/safe/rides/$', require_GET(utils.api_view(views.rides_get))),
    url(r'^api/ride_request_update/$', require_POST(utils.api_view(views.ride_request_update)), name="ride_request_update"),
    #url(r'^api/ride_edit_rendezvous/$', require_POST(utils.api_view(views.ride_edit_rendezvous)), name="ride_edit_rendezvous"),  
    #url(r'^admin/', include(adminsite.urls)),
)
Example #21
0
from django.urls import path
from . import views
from django.contrib.auth import views as auth_views
from django.contrib import admin
from django.views.decorators.http import require_POST
from .feeds import LatestPollsFeed

app_name = 'polls'
urlpatterns = [path("", views.IndexView.as_view(), name="index"),
				path("<int:pk>/", views.DetailView.as_view(), name='detail'),
				path('<int:pk>/results/', views.ResultsView.as_view(), name="results"),
				path('<int:question_id>/vote/', views.vote, name='vote'),
				path("new/", views.question_new, name="question_new"),
				path("<int:pk>/edit/", views.question_edit, name="question_edit"),
				path("<int:question_id>/share", views.post_share, name="post_share"),
				path("commentform/", require_POST(views.CommentFormView.as_view()), name="commentform"),
				path("feed/", LatestPollsFeed(), name="polls_feed"),
				
				]

Example #22
0
# Copyright 2011, hast. All rights reserved.
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.

from django.conf.urls.defaults import patterns, url
from django.views.generic.simple import direct_to_template
from django.contrib.auth.views import login, logout
from django.contrib.auth.decorators import login_required
from django.views.decorators.http import require_POST
from utils.decorators import AR, chk_perm, enforce_post
from users.views import mask_welcome, get_courses, follow, add_perm, rm_perm
from users.views import new_user, unfollow

urlpatterns = patterns(
    "users.views",
    url(r"^$", AR(login_required(direct_to_template)), {"template": "user_show.tpl"}, name="profile"),
    url(r"^mask_welcome$", AR(login_required(mask_welcome)), name="mask_welcome"),
    url(r"^courses$", login_required(get_courses), name="user_courses"),
    url(r"^follow$", require_POST(login_required(follow)), name="user_follow"),
    url(r"^unfollow$", require_POST(login_required(unfollow)), name="user_unfollow"),
    url(r"^login/$", login, {"template_name": "user_login.tpl"}, name="user_login"),
    url(r"^logout/$", logout, {"next_page": "/"}, name="user_logout"),
    url(r"^new$", enforce_post(chk_perm(login_required(new_user), "user_manage")), name="user_new"),
    url(r"^add_perm$", enforce_post(chk_perm(login_required(add_perm), "user_manage")), name="user_add_perm"),
    url(r"^remove_perm$", enforce_post(chk_perm(login_required(rm_perm), "user_manage")), name="user_remove_perm"),
)
Example #23
0
from django.urls import path
from django.views.decorators.http import require_GET, require_POST
from . import views

app_name = 'books'

urlpatterns = [
    path('', views.InfoView.as_view(), name='info'),
    path('doc', views.DocView.as_view(), name='doc'),
    path('v1/books/<str:id>',
         require_GET(views.SingleBookView.as_view()),
         name='single_book'),
    path('v1/books',
         require_GET(views.ListBooksView.as_view()),
         name='book_list'),
    path('v1/db', require_POST(views.ListBooksView.as_view()), name='db'),
]
Example #24
0
# coding: utf-8

from django.conf.urls import url
from django.views.decorators.http import require_POST  # require_GET

from blog.views import PostDetailView, PostsListView, CommentFormView

app_name = 'blog'
urlpatterns = [
    url(r'^$', PostsListView.as_view(), name='post-list'),
    url(r'^post/(?P<pk>\d+)/$', PostDetailView.as_view(), name='post-detail'),
    url(r'^post/comment/$', require_POST(CommentFormView.as_view()),
        name='post-add-comment')
]
Example #25
0
def generic_ajax_func(func):
    return require_POST(csrf_protect(serialize_as_json(param_from_post(func))))
Example #26
0
        formfields = dict([(fieldname, form[fieldname]) for fieldname in form.fields.keys()]) 
        final_errors = {}
        for key, val in errors.iteritems():
            if '__all__' in key:
                final_errors[key] = val
            else:# not isinstance(formfields[key].field):
                html_id = formfields[key].field.widget.attrs.get('id') or formfields[key].auto_id
                html_id = formfields[key].field.widget.id_for_label(html_id)
                final_errors[html_id] = val
        data = {
            'valid': False,
            'errors': final_errors,
        }
    return data

add = require_POST(add)

@ajax_view()
def edit(request):
    """
    Process the inline editing form.
    """
    try:
        model = get_model(request.POST["app"], request.POST["model"])
        if not can("change", model, request.user):
            return {"valid": True, "permissionerror":"You don't have permission to edit!"}
        obj = model.objects.get(id=request.POST["id"])
        form = get_model_form(obj, request.POST["fields"], data=request.POST,
                             files=request.FILES)
    except Exception:
        pass
Example #27
0
                        widget = Widget(widgetslot=slot, page=page_obj,
                                        widget_class=widget_class,
                                        user=request.user)
                        widget.save()

                    if options_form.save(widget=widget):
                        data = {'valid': True, 'form': 'saved'}
                elif options_form.errors:
                    data = ajaxerror(options_form)
            except Exception, e:
                data = {"valid": "false", "error": { "_all_": ["Something went wrong, please refresh the page"],}}

    return HttpResponse(json_serializer.encode(data),\
                                 mimetype='application/json')

create_widget = require_POST(create_widget)


@admin_can(Widget, action="change")
def delete_widget(request, id):
    try:
        obj = Widget.objects.get(id=id)
        obj.delete()
    except Exception:
        pass


@ajax_view()
@admin_can(Widget)
def widget_options(request, type):
    try:
Example #28
0
from django.conf.urls import url
from django.views.decorators.http import require_POST

from main import views


urlpatterns = [
    url(r'^$', views.Index.as_view(), name='index'),
    url(r'^home/$', views.Home.as_view(), name='home'),
    url(r'^create/post/$', views.CreateQuestion.as_view(), name='create_post'),
    url(r'^questions/$', views.ListQuestions.as_view(), name='questions_list'),
    url(r'^question/(?P<pk>\d+)/$', views.QuestionDetail.as_view(), name='question_detail'),
    url(r'^create/answer/(?P<pk>\d+)/$', require_POST(views.CreateAnswer.as_view()), name='create_answer'),
    url(r'^upvote/(?P<pk>\d+)/(?P<answer_id>\d+)/$', views.UpVote.as_view(), name='upvote'),
    url(r'^downvote/(?P<pk>\d+)/(?P<answer_id>\d+)/$', views.DownVote.as_view(), name='downvote'),
    url(r'^delete/post/(?P<pk>\d+)/$', views.DeleteQuestion.as_view(), name='delete_question'),
    url(r'^pokemon/search/$', views.Pokemon.as_view(), name='pokemon_search'),
    url(r'^search/question/$', views.SearchQuestion.as_view(), name='search_question'),
    url(r'^charge/$', views.Charge.as_view(), name='charge'),
]
Example #29
0
    url(r'^(?P<package_name>[A-Za-z][A-Za-z0-9-_]+)/version/(?P<version>[^\/]+)/approve/$', version_approve, {}, name='version_approve'),
    url(r'^(?P<package_name>[A-Za-z][A-Za-z0-9-_]+)/version/(?P<version>[^\/]+)/unapprove/$', version_unapprove, {}, name='version_unapprove'),
]

# RPC
urlpatterns += [
    # rpc4django will need to be in your Python path
    url(r'^RPC2/$', serve_rpc_request),
]


# plugin rating
from djangoratings.views import AddRatingFromModel
from django.views.decorators.http import require_POST
from django.views.decorators.csrf import csrf_protect, ensure_csrf_cookie


urlpatterns += [
    url(r'rate/(?P<object_id>\d+)/(?P<score>\d+)/', require_POST(csrf_protect(AddRatingFromModel())), {
        'app_label': 'plugins',
        'model': 'plugin',
        'field_name': 'rating',
    }, name='plugin_rate'),
]


# Plugin detail (keep last)
urlpatterns += [
    url(r'^(?P<package_name>[A-Za-z][A-Za-z0-9-_]+)/$', PluginDetailView.as_view(slug_url_kwarg='package_name', slug_field='package_name'), name='plugin_detail'),
]
Example #30
0
# -*- coding: utf-8 -*-
from django.conf.urls import include, patterns, url

from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_POST
from django.contrib.auth.decorators import user_passes_test
from django.db import transaction

from .views import EpayCallback, PaymentDetail
from . import PaymentProcessor

has_perm = PaymentProcessor.get_backend_setting("has_perm",
                                                lambda u: u.is_superuser)

my_urls = patterns(
    '',
    url(r'^callback/$',
        csrf_exempt(require_POST(transaction.atomic(EpayCallback.as_view()))),
        name='postlink'),
    url(r'^status/(?P<pk>\d+)/$',
        user_passes_test(has_perm)(PaymentDetail.as_view()),
        name='status'),
)

urlpatterns = patterns('', url(r'', include(my_urls, namespace='epay')))
Example #31
0
from django.conf.urls import url, include
from django.views.decorators.http import require_POST

import social_django.views

import weblate.accounts.views

# Follows copy of social_django.urls with few changes:
# - authentication requires POST (issue submitted upstream)
# - removed some configurability (just to avoid additional deps)
# - the association_id has to be numeric (patch accepted upstream)
social_urls = [
    # authentication / association
    url(
        r'^login/(?P<backend>[^/]+)/$',
        require_POST(social_django.views.auth),
        name='begin'
    ),
    url(
        r'^complete/(?P<backend>[^/]+)/$',
        social_django.views.complete,
        name='complete'
    ),
    # disconnection
    url(
        r'^disconnect/(?P<backend>[^/]+)/$',
        social_django.views.disconnect,
        name='disconnect'
    ),
    url(
        r'^disconnect/(?P<backend>[^/]+)/(?P<association_id>\d+)/$',
Example #32
0
 url(r'^rides/$', 'occupywallst.views.rides', name='rides'),
 url(r'^rides/(?P<ride_id>\d+)/$', 'occupywallst.views.ride_info', name='ride_info'),
 url(r'^rides/create/$', 'occupywallst.views.ride_create', name='ride_create'),
 url(r'^rides/(?P<ride_id>\d+)/edit/$', 'occupywallst.views.ride_edit', name='ride_edit'),
 url(r'^rides/(?P<ride_id>\d+)/request/$', 'occupywallst.views.ride_request_add', name='ride_request'),
 url(r'^rides/(?P<ride_id>\d+)/request/delete/$', 'occupywallst.views.ride_request_delete', name='ride_request_delete'),
 url(r'^login/$', 'occupywallst.views.login', name='login'),
 url(r'^logout/$', 'occupywallst.views.logout', name='logout'),
 url(r'^signup/$', 'occupywallst.views.signup', name='signup'),
 url(r'^error/$', 'occupywallst.views.error', name='error'),
 url(r'^users/(?P<username>[-_\d\w]+)/$', 'occupywallst.views.user_page', name='user'),
 url(r'^users/(?P<username>[-_\d\w]+)/edit/$', 'occupywallst.views.edit_profile', name='user-edit'),
 url(r'^api/safe/attendees/$', require_GET(utils.api_view(api.attendees))),
 url(r'^api/safe/attendee_info/$', require_GET(utils.api_view(api.attendee_info))),
 url(r'^api/safe/rides/$', require_GET(utils.api_view(api.rides))),
 url(r'^api/ride_request_update/$', require_POST(utils.api_view(api.ride_request_update)), name="ride_request_update"),
 url(r'^api/safe/article_get/$', require_GET(utils.api_view(api.article_get))),
 url(r'^api/safe/article_get_comments/$', require_GET(utils.api_view(api.article_get_comments))),
 url(r'^api/safe/article_get_comment_votes/$', require_GET(utils.api_view(api.article_get_comment_votes))),
 url(r'^api/safe/comment_get/$', require_GET(utils.api_view(api.comment_get))),
 url(r'^api/safe/carousel_get/$', require_GET(utils.api_view(api.carousel_get))),
 url(r'^api/safe/forumlinks/$', require_GET(utils.api_view(api.forumlinks))),
 url(r'^api/article_new/$', require_POST(utils.api_view(api.article_new))),
 url(r'^api/article_edit/$', require_POST(utils.api_view(api.article_edit))),
 url(r'^api/article_delete/$', require_POST(utils.api_view(api.article_delete))),
 url(r'^api/article_remove/$', require_POST(utils.api_view(api.article_remove))),
 url(r'^api/comment_new/$', require_POST(utils.api_view(api.comment_new))),
 url(r'^api/comment_edit/$', require_POST(utils.api_view(api.comment_edit))),
 url(r'^api/comment_remove/$', require_POST(utils.api_view(api.comment_remove))),
 url(r'^api/comment_delete/$', require_POST(utils.api_view(api.comment_delete))),
 url(r'^api/comment_upvote/$', require_POST(utils.api_view(api.comment_upvote))),
Example #33
0
from django.conf.urls import url
from django.views.decorators.http import require_POST
from . import views

app_name = 'video'

urlpatterns = [
    url(r'^$', views.IndexView.as_view(), name='index'),
    url(r'^register/$', views.UserRegisterView.as_view(), name='register'),
    url(r'^login/$', views.UserLoginView.as_view(), name='login'),
    url(r'^logout/$', views.logout_view, name='logout'),
    url(r'^(?P<pk>[0-9]+)/(?P<show>[tf])/$', views.detail_view, name='detail'),
    url(r'^radio_form/(?P<comment_pk>[0-9]+)$',
        require_POST(views.radio_form_view),
        name='radio_form_view'),
    url(r'^leaderboard/$', views.LeaderBoardView.as_view(),
        name='leaderboard'),
    url(r'^profile/$', views.ProfileView.as_view(), name='profile'),
]
Example #34
0
        data = {
            'valid': True,
        }
        if request.POST.get('save'):
            signin_user(form)
            username = form.cleaned_data['username']
            password = form.cleaned_data['password1']
            user = authenticate(username=username, password=password)
            if user is not None:
                if user.is_active:
                    login(request, user)
    else:        
        data = processErrors(request, form)
    json_serializer = LazyEncoder()
    return HttpResponse(json_serializer.encode(data), mimetype='application/json')
validate = require_POST(validate)

def validate_profile(request, *args, **kwargs):    
    if request.user.is_authenticated():
        form_class = kwargs.pop('form_class')
        edit_form = form_class(user=request.user, data=request.POST)
        if edit_form.is_valid():
            data = {
                'valid': True,
            }
            if request.POST.get('save'):
                user = edit_form.save() 
                request.user.message_set.create(message='Ваши данные обновлены')
        else:
            data = processErrors(request, edit_form)
    else:
Example #35
0
	def get_urls(self):
		from django.conf.urls.defaults import patterns, url, include
		
		def wrap(view):
			def wrapper(*args, **kwargs):
				return self.api_view(view, *args, **kwargs)
			
			return update_wrapper(wrapper, view)
		
		urlpatterns = patterns('',
			url(
				r'^develop/$', self.docs_index_view,
				name = 'doc'
			)
		)
		
		if not self.auth.app_model is None:
			urlpatterns += patterns('',
				url(
					r'^develop/apps/$', login_required(self.apps_view),
					name = 'apps'
				),
				url(
					r'^develop/apps/add/$', require_POST(login_required(self.add_app_view)),
					name = 'add_app'
				),
				url(
					r'^develop/apps/(?P<pk>\d+)/$', login_required(self.edit_app_view),
					name = 'edit_app'
				),
				url(
					r'^develop/apps/(?P<pk>\d+)/delete/$', login_required(self.delete_app_view),
					name = 'delete_app'
				),
			)
		
		urlpatterns += patterns('',
			url(
				r'^develop/(?P<app_label>[\w]+)/(?P<model>[\w]+)/$',
				self.docs_model_view,
				name = 'doc_model'
			),
			url(
				r'^develop/(?P<app_label>[\w]+)/$',
				self.docs_app_view,
				name = 'doc_appindex'
			),
			url(r'^api/', include(self.auth.get_urls()))
		)
		
		for model, model_api in self._registry.iteritems():
			urlpatterns += patterns('',
				url(
					r'^api/%s/%s' % (
						model._meta.app_label, model._meta.module_name
					),
					include(model_api.urls)
				)
			)
		
		return urlpatterns
Example #36
0
from django.urls import path
from django.contrib.auth.decorators import login_required
from django.views.decorators.http import require_POST
from projects import views

urlpatterns = [
    path('', views.projects_home, name='projects_home'),
    path('add', views.ProjectAddView.as_view(), name='add_project'),
    path('edit/<int:pk>', views.ProjectEditView.as_view(),
         name='edit_project'),
    path('<int:pk>', views.ProjectDetailView.as_view(), name='view_project'),
    path('addtask/<int:pk>', require_POST(views.add_task), name='add_task'),
    path('complete/<int:pk>', views.complete_task, name='complete_task'),
    path('uncomplete/<int:pk>', views.uncomplete_task, name='uncomplete_task'),
    path('participe/<int:pk>',
         login_required(views.add_participation),
         name='project_add_participation'),
    path('noparticipe/<int:pk>',
         login_required(views.remove_participation),
         name='project_remove_participation'),
    path('<int:project_id>/upvote/<int:comment_id>',
         login_required(views.upvote_comment),
         name='upvote'),
    path('<int:project_id>/downvote/<int:comment_id>',
         login_required(views.downvote_comment),
         name='downvote'),
    path('<int:project_id>/comment/add',
         login_required(views.add_comment),
         name='add_comment'),
]
Example #37
0
    form_class = forms.IndexForm
    success_url = reverse_lazy("restaurant:index")

    def form_valid(self, form):
        dishes = form.cleaned_data["dishes"]
        total_price = sum(dish.price for dish in dishes)
        allergens = {
            allergen
            for dish in dishes.prefetch_related("allergens")
            for allergen in dish.allergens.all()
        }
        return TemplateResponse(self.request,
                                "restaurant/order.html",
                                context={
                                    "total_price": total_price,
                                    "dishes": dishes,
                                    "allergens": allergens
                                })

    def get_context_data(self, **kwargs):
        kwargs["create_dish_form"] = forms.CreateDishForm(prefix="create_dish")
        return super().get_context_data(**kwargs)


index = require_GET(IndexView.as_view())
order = require_POST(IndexView.as_view())


class CreatePasteView(TemplateView):
    template_name = "restaurant/paste.html"
Example #38
0
 url(r'^login/$', 'occupywallst.views.login', name='login'),
 url(r'^logout/$', 'occupywallst.views.logout', name='logout'),
 url(r'^signup/$', 'occupywallst.views.signup', name='signup'),
 url(r'^error/$', 'occupywallst.views.error', name='error'),
 url(r'^users/(?P<username>[-_\d\w]+)/$',
     'occupywallst.views.user_page',
     name='user'),
 url(r'^users/(?P<username>[-_\d\w]+)/edit/$',
     'occupywallst.views.edit_profile',
     name='user-edit'),
 url(r'^api/safe/attendees/$', require_GET(utils.api_view(api.attendees))),
 url(r'^api/safe/attendee_info/$',
     require_GET(utils.api_view(api.attendee_info))),
 url(r'^api/safe/rides/$', require_GET(utils.api_view(api.rides))),
 url(r'^api/ride_request_update/$',
     require_POST(utils.api_view(api.ride_request_update)),
     name="ride_request_update"),
 url(r'^api/safe/article_get/$',
     require_GET(utils.api_view(api.article_get))),
 url(r'^api/safe/article_get_comments/$',
     require_GET(utils.api_view(api.article_get_comments))),
 url(r'^api/safe/article_get_comment_votes/$',
     require_GET(utils.api_view(api.article_get_comment_votes))),
 url(r'^api/safe/comment_get/$',
     require_GET(utils.api_view(api.comment_get))),
 url(r'^api/safe/carousel_get/$',
     require_GET(utils.api_view(api.carousel_get))),
 url(r'^api/safe/forumlinks/$',
     require_GET(utils.api_view(api.forumlinks))),
 url(r'^api/article_new/$', require_POST(utils.api_view(api.article_new))),
 url(r'^api/article_edit/$',
Example #39
0
        else:
            errors = form.errors
            formfields = dict([(fieldname, form[fieldname])
                               for fieldname in form.fields.keys()])

        # if fields have been specified then restrict the error list
        if request.POST.getlist('fields'):
            fields = request.POST.getlist('fields') + ['__all__']
            errors = dict([(key, val) for key, val in errors.iteritems()
                           if key in fields])

        final_errors = {}
        for key, val in errors.iteritems():
            if '__all__' in key:
                final_errors[key] = val
            elif not isinstance(formfields[key].field, forms.FileField):
                html_id = formfields[key].field.widget.attrs.get(
                    'id') or formfields[key].auto_id
                html_id = formfields[key].field.widget.id_for_label(html_id)
                final_errors[html_id] = val
        data = {
            'valid': False or not final_errors,
            'errors': final_errors,
        }
    json_serializer = LazyEncoder()
    return HttpResponse(json_serializer.encode(data),
                        content_type='application/json')


validate = require_POST(validate)
Example #40
0
from django.conf.urls import url
from django.views.generic import TemplateView
from django.views.decorators.http import require_POST

from taas.reservation import views


urlpatterns = [
    url(r'^fields/$', views.get_fields, name='fields'),
    url(r'^all/$', views.get_reservations, name='all_reservations'),
    url(r'^add/$', views.add_reservation, name='add_reservation'),
    url(r'^update/(?P<pk>\d+)/$', views.ReservationDetailView.as_view(), name='detail_reservation'),
    url(r'^update/(?P<pk>\d+)/confirm/$', require_POST(views.UpdateReservationView.as_view()),
        name='update_reservation'),
    url(r'^remove/$', views.remove_reservation, name='remove_reservation'),
    url(r'^remove/all/$', views.remove_unpaid_reservations, name='remove_all_reservations'),
    url(r'^list/$', views.ReservationList.as_view(), name='reservation_list'),
    url(r'^payment/success/$', views.payment_success, name='payment_success'),
    url(r'^payment/cancel/$', views.payment_cancelled, name='payment_cancel'),
    url(r'^payment/transaction/$', views.ProceedTransactionView.as_view(), name='proceed_transaction'),
    url(r'^payment/budget/$', views.BudgetPaymentView.as_view(), name='budget_payment'),
    url(r'^expire/$', views.get_expire_time, name='get_expire_time'),
    url(r'^history/$', views.history, name='reservation_history'),
    url(r'^help/', TemplateView.as_view(template_name="help.html")),
]
Example #41
0
from .views import (
    ActivateOverviewView,
    ConsentView,
    HomeView,
    QuizView,
    ToggleSharingView,
    WithdrawView,
)

app_name = "public-data"

urlpatterns = [
    path("", HomeView.as_view(), name="home"),
    # Enrollment process pages. User must be logged in to access.
    path(
        "activate-1-overview/", ActivateOverviewView.as_view(), name="enroll-overview"
    ),
    path("activate-2-information/", ConsentView.as_view(), name="enroll-information"),
    path("activate-3-quiz/", QuizView.as_view(), name="enroll-quiz"),
    path(
        "activate-4-complete/",
        require_POST(ConsentView.as_view()),
        name="enroll-signature",
    ),
    # Withdraw from the public data study
    path("deactivate/", WithdrawView.as_view(), name="deactivate"),
    # Data management
    path("toggle-sharing/", ToggleSharingView.as_view(), name="toggle-sharing"),
]
Example #42
0
from django.conf.urls import url
from django.views.decorators.http import require_POST

from valhalla.proposals.views import ProposalDetailView, ProposalListView, InviteCreateView
from valhalla.proposals.views import MembershipDeleteView, SemesterDetailView

urlpatterns = [
    url(r'^membership/(?P<pk>.+)/delete/$', MembershipDeleteView.as_view(), name='membership-delete'),
    url(r'^semester/(?P<pk>.+)/$', SemesterDetailView.as_view(), name='semester-detail' ),
    url(r'^$', ProposalListView.as_view(), name='list'),
    url(r'^(?P<pk>.+)/invite/$', require_POST(InviteCreateView.as_view()), name='invite'),
    url(r'^(?P<pk>.+)/$', ProposalDetailView.as_view(), name='detail'),
]
Example #43
0
from django.contrib.auth.views import LoginView, logout_then_login
from django.urls import path
from django.views.decorators.http import require_POST
from django.views.generic.base import TemplateView


class HomeView(TemplateView):
    template_name = "web/home.html"


class LoginView(LoginView):
    template_name = "web/login.html"


safe_logout_then_login = require_POST(logout_then_login)

app_name = "web"
urlpatterns = [
    path("", HomeView.as_view(), name="home"),
    path("logout/", safe_logout_then_login, name="logout"),
    path("login/", LoginView.as_view(), name="login"),
]
Example #44
0
from django.urls import path, include
from qpoll import views as qv
from django.views.decorators.http import require_POST
# from django.conf import settings
# from django.conf.urls.static import static

app_name = 'qpoll'
urlpatterns = [
    path('', qv.IndexQuestionView.as_view(), name='qpoll'),
    path('detail/<int:pk>/', qv.QuestionDetailView.as_view(), name='detail'),
    path('vote/<int:ans_id>/', qv.vote, name='vote'),
    path('result/<int:pk>/', qv.ResultView.as_view(), name='result'),
    path('chart/<int:qust_id>/', qv.chart_data, name='chart'),
    path('my_form/', require_POST(qv.FormsView.as_view()), name='form'),
    path('edit/<int:output_id>', qv.edit_form_view, name='edit'),
    path('delete/<int:pk>', qv.QuestionDelete.as_view(), name='delete')
]
# ] +static(settings.STATIC_URL,document_root=settings.STATIC_ROOT)
Example #45
0
 url(r'^api/service/toggleEnable/$',
     services.toggleEnable,
     name='toggle-services'),
 url(r'^api/service/singleToggleEnable/$',
     services.singleToggleEnable,
     name='single-toggle-services'),
 url(r'^api/service/searchQuickForwarders/$',
     services.quickSearchForwarders,
     name='quick-search-forwarders'),
 url(r'^api/service/searchForwarders/$',
     services.searchP2PForwarders,
     name='search-forwarders'),
 url(r'^api/service/searchPackageCollectors/$',
     services.searchPackageCollectors,
     name='search-collectors'),
 url(r'^api/order/$', require_POST(orders.getOrders), name='get-orders'),
 url(r'^api/order/forwarder/$',
     require_POST(orders.getForwarderOrders),
     name='get-forwarder-orders'),
 url(r'^api/order/forwarder/feedback/$',
     require_POST(orders.addOrderForwarderFeedbackToBuyer),
     name='forwarder-order-feedback'),
 url(r'^api/order/create/$', orders.createOrder, name='create-order'),
 url(r'^api/order/edit/$', orders.editOrder, name='edit-order'),
 url(r'^api/order/delete/$', orders.deleteOrder, name='delete-order'),
 url(r'^api/order/(?P<order_id>\d+)$',
     require_http_methods(['GET'])(orders.getOrder),
     name='get-forwarder-order'),
 url(r'^api/order/forwarder/(?P<order_id>\d+)$',
     require_http_methods(['GET'])(orders.getForwarderOrder),
     name='get-order'),
Example #46
0
    url(r'^(?P<package_name>[A-Za-z][A-Za-z0-9-_]+)/version/(?P<version>[^\/]+)/unapprove/$', 'version_unapprove', {}, name='version_unapprove'),
)

# RPC
urlpatterns += patterns('',
    # rpc4django will need to be in your Python path
    (r'^RPC2/$', 'rpc4django.views.serve_rpc_request'),
)


# plugin rating
from djangoratings.views import AddRatingFromModel
from django.views.decorators.http import require_POST
from django.views.decorators.csrf import csrf_protect, ensure_csrf_cookie


urlpatterns += patterns('',
    url(r'rate/(?P<object_id>\d+)/(?P<score>\d+)/', require_POST(csrf_protect(AddRatingFromModel())), {
        'app_label': 'plugins',
        'model': 'plugin',
        'field_name': 'rating',
    }, name='plugin_rate'),
)


# Plugin detail (keep last)
urlpatterns += patterns('plugins.views',
    url(r'^(?P<package_name>[A-Za-z][A-Za-z0-9-_]+)/$', PluginDetailView.as_view(slug_url_kwarg='package_name', slug_field='package_name'), name='plugin_detail'),
)

Example #47
0
from django.core.urlresolvers import reverse
from django.views.generic import ListView, DetailView, TemplateView, CreateView

__author__ = 'derya'

from django.conf.urls import patterns, url
from django.template.defaultfilters import register
from django.views.decorators.http import require_http_methods, require_POST, require_GET
from django.views.decorators.cache import cache_page

from views import Index, HauntedLocationSearch, HauntedLocationDetail, AboutUs, HowItWorks, TestView, HauntedEpisodeGuide
from models import Newsletter, Comment

urlpatterns = patterns('',


    url(r'^$', cache_page(60 * 1)(Index.as_view()), name="HauntedIndex"),
    url(r'^detail/(?P<slug>[-\w\d]+),(?P<pk>\d+)$', cache_page(60 * 1)(HauntedLocationDetail.as_view()), name='HauntedLocationDetail'),
    url(r'^about_us$',AboutUs.as_view(), name='AboutUs'),
    url(r'^how_it_works$',HowItWorks.as_view(), name='HowItWorks'),
    url(r'^test$',TestView.as_view(), name='test'),
    url(r'^episode_guide',cache_page(60 * 1)(HauntedEpisodeGuide.as_view()), name='HauntedEpisodeGuide'),
    #GET Form returns
    url(r'^search$',HauntedLocationSearch.as_view(), name='HauntedLocationSearch'),
    #POST Form returns
    url(r'^newsletter$',require_POST(CreateView.as_view(model=Newsletter, success_url="/website/", template_name="website/partial/_dummy.html")), name='NewsletterView' ),
    url(r'^comment$',CreateView.as_view(model=Comment, success_url="/website/",template_name="website/partial/_dummy.html"), name='CommentView' ),


)
Example #48
0
from rideshare import views, admin
from occupywallst import utils

urlpatterns = patterns(
    'rideshare',
    #rides
    url(r'^$', 'views.rides', name='rides'),
    url(r'^create/$', 'views.ride_create', name='ride_create'),
    url(r'^(?P<ride_id>\d+)/$', 'views.ride_info', name='ride_info'),
    url(r'^(?P<ride_id>\d+)/delete/$', 'views.ride_delete',
        name='ride_delete'),
    url(r'^(?P<ride_id>\d+)/edit/$', 'views.ride_edit', name='ride_edit'),
    #ride requests
    url(r'^(?P<request_id>\d+)/request/view/$',
        'views.ride_request_view',
        name='ride_request_view'),
    url(r'^(?P<ride_id>\d+)/request/add/$',
        'views.ride_request_add_update',
        name='ride_request_add_update'),
    url(r'^(?P<ride_id>\d+)/request/delete/$',
        'views.ride_request_delete',
        name="ride_request_delete"),
    #ride ajax
    url(r'^api/safe/rides/$', require_GET(utils.api_view(views.rides_get))),
    url(r'^api/ride_request_update/$',
        require_POST(utils.api_view(views.ride_request_update)),
        name="ride_request_update"),
    #url(r'^api/ride_edit_rendezvous/$', require_POST(utils.api_view(views.ride_edit_rendezvous)), name="ride_edit_rendezvous"),
)
Example #49
0
def no_conflict_require_POST(fn):
    """
    Catches resource conflicts on save and returns a 409 error.
    Also includes require_POST decorator
    """
    return require_POST(no_conflict(fn))
Example #50
0
from django.urls import path
from django.views.decorators.http import require_POST

from . import views

app_name = "places"

urlpatterns = [
    path(
        "add_image/<int:pk>/",
        require_POST(views.AddImageView.as_view()),
        name="add_image",
    ),
    path("create/", views.CreatePlaceView.as_view(), name="create"),
    path(
        "update/<int:pk>/<slug:slug>/", views.UpdatePlaceView.as_view(), name="update"
    ),
    path("delete/<int:pk>/", views.DeletePlaceView.as_view(), name="delete"),
    path("<str:username>/data.geojson", views.MapLayer.as_view(), name="data"),
    path("list/<str:username>/", views.PlaceListView.as_view(), name="list"),
    path("<int:pk>/<slug:slug>/", views.PlaceDetailView.as_view(), name="detail"),
]
Example #51
0
from igreport.views.messages import show_messages
from igreport.views.reports import show_reports, submit_report, accept_report
from igreport.views.ajax import create_report, get_report, send_sms, demo_send, demo_get
from igreport.views.ajax import create_district, edit_district
from igreport.views.sync import sync_report
from igreport.views.printer import print_preview
from igreport.views.demo import demo_view
from igreport.views.sms import drop_message
from igreport.views.utils import show_categories, show_districts, show_subcounties
from django.contrib.auth.views import login, logout

urlpatterns = patterns('',
    (r'^admin/', include(admin.site.urls)),

    url('^$', direct_to_template, {'template':'igreport/index.html'}),
    url('^login$', require_POST(login), {'template_name':'igreport/index.html'}),
    url('^logout$', require_POST(logout)),
    (r'^accounts/login/$', direct_to_template, {'template':'igreport/login.html'}),

    (r'^test/$', login_required(direct_to_template), {'template':'igreport/tester.html'}),
    url('^test/progress/\d*/$', check_progress),
    url('^messages/(?P<identity>\d{7,20})/$', show_messages),
    url('^messages/(?P<identity>\d{7,20})/(?P<start_year>\d{4})/(?P<start_month>\d{2})/(?P<start_day>\d{2})/(?P<start_hour>\d{2})/(?P<start_minute>\d{2})/(?P<start_second>\d{2})/\d*/$', show_messages),
    url('^messages/(?P<identity>\d{7,20})/(?P<start_year>\d{4})/(?P<start_month>\d{2})/(?P<start_day>\d{2})/(?P<start_hour>\d{2})/(?P<start_minute>\d{2})/(?P<start_second>\d{2})/(?P<end_year>\d{4})/(?P<end_month>\d{2})/(?P<end_day>\d{2})/(?P<end_hour>\d{2})/(?P<end_minute>\d{2})/(?P<end_second>\d{2})/$', show_messages),

    (r'^reports/$', login_required(direct_to_template), {'template':'igreport/reports.html'}),
    url('^categories/$', show_categories),
    url('^districts/$', show_districts),
    url('^subcounties/$', show_subcounties),
    url('^igreports/(?P<identity>\d{7,20})/$', show_reports),
    url('^igreports/(?P<report_id>\d*)/$', submit_report),
Example #52
0
from django.conf.urls import patterns, url
from django.contrib.auth.decorators import login_required
from django.views.decorators.http import require_POST
from .views import (
    ProjectDetailView, ProjectAddView, ProjectEditView,
    projects_home, add_participation, remove_participation,
    add_task, complete_task, uncomplete_task)

urlpatterns = patterns(
    '',
    url(r'^$', projects_home, name='projects_home'),
    url(r'^add$', ProjectAddView.as_view(), name='add_project'),
    url(r'^edit/(?P<pk>[0-9]+)$', ProjectEditView.as_view(), name='edit_project'),
    url(r'^(?P<pk>[0-9]+)$', ProjectDetailView.as_view(), name='view_project'),
    url(r'^addtask/(?P<pk>[0-9]+)$', require_POST(add_task), name='add_task'),
    url(r'^complete/(?P<pk>[0-9]+)$', complete_task, name='complete_task'),
    url(r'^uncomplete/(?P<pk>[0-9]+)$', uncomplete_task, name='uncomplete_task'),
    url(r'^participe/(?P<pk>[0-9]+)$', login_required(add_participation), name='project_add_participation'),
    url(r'^noparticipe/(?P<pk>[0-9]+)$', login_required(remove_participation), name='project_remove_participation'),
)
Example #53
0
from .views import (ConsentView, HomeView, QuizView, ToggleSharingView,
                    WithdrawView)

urlpatterns = [
    url(r'^$', HomeView.as_view(), name='home'),

    # Is this here so we can link to the consent form for anonymous visitors?
    url(r'^consent/',
        TemplateView.as_view(template_name='public_data/consent.html'),
        name='consent'),

    # Enrollment process pages. User must be logged in to access.
    url(r'^enroll-1-overview',
        participant_required(
            TemplateView.as_view(template_name='public_data/overview.html')),
        name='enroll-overview'),
    url(r'^enroll-2-consent', ConsentView.as_view(), name='enroll-consent'),
    url(r'^enroll-3-quiz', QuizView.as_view(), name='enroll-quiz'),
    url(r'^enroll-4-signature',
        require_POST(ConsentView.as_view()),
        name='enroll-signature'),

    # Withdraw from the public data study
    url(r'^withdraw', WithdrawView.as_view(), name='withdraw'),

    # Data management
    url(r'^toggle-sharing/',
        ToggleSharingView.as_view(),
        name='toggle-sharing'),
]
Example #54
0
from django.views.decorators.http import require_POST

__author__ = 'Alexandre Cloquet'

from django.conf.urls import patterns, include, url
from django.contrib import admin
from .views import OpenEnrollementView, CharacterAttributesView, EnrollementView, EnrollementListView, \
    EnrollmentDetailView, \
    CommentEnrollmentFormView, EnrollmentDetail, voteUp, voteDown, redirect_to_bnet, tmp
from Portal.views import index as portal_index
from Forum.views import index as forum_index

urlpatterns = patterns('',
                       url(r'^$', OpenEnrollementView.as_view(), name='enrollement_index'),
                       url(r'^list_enrollement/$', EnrollementListView.as_view(), name='enrollement_list'),

                       url(r'^test/$', redirect_to_bnet, name='test_battlenet'),
                       url(r'^tmp/$', tmp, name='test_battlenet'),

                       url(r'^detail/(?P<pk>\d+)/$', EnrollmentDetail.as_view(), name='enrollment_detail'),
                       url(r'^detail/(?P<pk>\d+)/comment/$', require_POST(CommentEnrollmentFormView.as_view()),
                           name='enrollment_detail_comment'),
                       url(r'^detail/(?P<pk>\d+)/voteup/$', voteUp, name='voteup'),
                       url(r'^detail/(?P<pk>\d+)/votedown/$', voteDown, name='votedown'),

                       url(r'^(?P<id_application>(\d+))/$', EnrollementView.as_view(), name='enrollement_application'),
                       url(r'^character_attributes$', CharacterAttributesView.as_view(), name='character_attributes'),
                       )
Example #55
0
from django.conf.urls import url
from django.views.decorators.http import require_POST

from observation_portal.proposals.views import ProposalDetailView, ProposalListView, InviteCreateView
from observation_portal.proposals.views import MembershipDeleteView, SemesterAdminView, MembershipLimitView
from observation_portal.proposals.views import GlobalMembershipLimitView, SemesterDetailView, ProposalInviteDeleteView

app_name = 'proposals'
urlpatterns = [
    url(r'^membership/(?P<pk>.+)/delete/$', MembershipDeleteView.as_view(), name='membership-delete'),
    url(r'^membership/(?P<pk>.+)/limit/$', MembershipLimitView.as_view(), name='membership-limit'),
    url(r'^semester/(?P<pk>.+)/$', SemesterDetailView.as_view(), name='semester-detail'),
    url(r'^semesteradmin/(?P<pk>.+)/$', SemesterAdminView.as_view(), name='semester-admin'),
    url(r'^invitation/(?P<pk>.+)/delete/$', ProposalInviteDeleteView.as_view(), name='proposalinvite-delete'),
    url(r'^$', ProposalListView.as_view(), name='list'),
    url(r'^(?P<pk>.+)/invite/$', require_POST(InviteCreateView.as_view()), name='invite'),
    url(r'^(?P<pk>.+)/globallimit/$', require_POST(GlobalMembershipLimitView.as_view()), name='membership-global'),
    url(r'^(?P<pk>.+)/$', ProposalDetailView.as_view(), name='detail'),
]
Example #56
0
    PostDetailView,
    PostCreateView,
    PostUpdateView,
    PostDeleteView,
    UserPostListView,
    BranchPostListView,
    YearPostListView,
    CommentFormView,
    CommentUpdateView
)
from django.views.decorators.http import require_POST
from . import views
from django.conf.urls import url

urlpatterns = [
    path('', PostListView.as_view(), name='blog-home'),
    path('post/<int:pk>/', PostDetailView.as_view(), name='post-detail'),
    path('post/new/', PostCreateView.as_view(), name='post-create'),
    path('post/<int:pk>/update/', PostUpdateView.as_view(), name='post-update'),
    path('post/<int:pk>/delete/', PostDeleteView.as_view(), name='post-delete'),
    path('user/blog/<str:username>', UserPostListView.as_view(), name='user-posts'),
    path('blog/<str:branch>', BranchPostListView.as_view(), name='branch-posts'),
    path('blog/<str:branch>/<str:year_of_admission>', YearPostListView.as_view(), name='year-posts'),
    url('like/',views.like , name='like'),
    url('just_parent/',views.just_parent , name='just-parent'),
    path('comment_form/<str:pkey>/',require_POST(CommentFormView.as_view()),name='comment-form'),
    path('comment_update/<str:pkey>/<int:pk>/',require_POST(CommentUpdateView.as_view()),name='comment-update'),
]

#url('like/',views.like , name='like'),
Example #57
0
    form_class = kwargs.pop('form_class')
    extra_args_func = kwargs.pop('callback', lambda request, *args, **kwargs: {})
    kwargs = extra_args_func(request, *args, **kwargs)
    kwargs['data'] = request.POST
    form = form_class(**kwargs)
    if form.is_valid():
        data = {
            'valid': True,
        }
    else:
        if request.POST.getlist('fields'):
            fields = request.POST.getlist('fields') + ['__all__']
            errors = dict([(key, val) for key, val in form.errors.iteritems() if key in fields])
        else:
            errors = form.errors
        final_errors = {}
        for key, val in errors.iteritems():
            if key == '__all__':
                final_errors['__all__'] = val
            if not isinstance(form.fields[key], forms.FileField):
                html_id = form.fields[key].widget.attrs.get('id') or form[key].auto_id
                html_id = form.fields[key].widget.id_for_label(html_id)
                final_errors[html_id] = val
        data = {
            'valid': False,
            'errors': final_errors,
        }
    json_serializer = LazyEncoder()
    return HttpResponse(json_serializer.encode(data), mimetype='application/json')
validate = require_POST(validate)
Example #58
0
from django.conf.urls import url
from django.contrib.auth.decorators import login_required
from django.views.decorators.http import require_POST
from .views import (ProjectDetailView, ProjectAddView, ProjectEditView,
                    projects_home, add_participation, remove_participation,
                    add_task, complete_task, uncomplete_task)

urlpatterns = [
    url(r'^$', projects_home, name='projects_home'),
    url(r'^add$', ProjectAddView.as_view(), name='add_project'),
    url(r'^edit/(?P<pk>[0-9]+)$',
        ProjectEditView.as_view(),
        name='edit_project'),
    url(r'^(?P<pk>[0-9]+)$', ProjectDetailView.as_view(), name='view_project'),
    url(r'^addtask/(?P<pk>[0-9]+)$', require_POST(add_task), name='add_task'),
    url(r'^complete/(?P<pk>[0-9]+)$', complete_task, name='complete_task'),
    url(r'^uncomplete/(?P<pk>[0-9]+)$',
        uncomplete_task,
        name='uncomplete_task'),
    url(r'^participe/(?P<pk>[0-9]+)$',
        login_required(add_participation),
        name='project_add_participation'),
    url(r'^noparticipe/(?P<pk>[0-9]+)$',
        login_required(remove_participation),
        name='project_remove_participation'),
]