def test_decorator_argument(self): """ test that @check_honeypot('fieldname') works """ new_view_func = check_honeypot(view_func, "fieldname") request = _get_POST_request() request.POST[settings.HONEYPOT_FIELD_NAME] = "" resp = new_view_func(request) self.assertEquals(resp.__class__, HttpResponseBadRequest)
Commenting App This module provides generic django URL routing. """ from django.conf.urls import patterns, url from honeypot.decorators import check_honeypot from tunobase.commenting import views, forms urlpatterns = patterns('', url(r'^post-comment/$', check_honeypot(views.PostComment.as_view( form_class=forms.CommentForm, template_name='commenting/includes/comment.html' )), name='post_comment' ), url(r'^report-comment/(?P<pk>\d+)/$', views.ReportComment.as_view(), name='report_comment' ), url(r'^load-more-comments/$', views.LoadMoreComments.as_view( partial_template_name='commenting/includes/comments.html' ), name='load_more_comments' ),
from django.conf.urls import patterns, include, url from django.views import generic as generic_views from honeypot.decorators import check_honeypot from app.jobs import views, forms urlpatterns = patterns( '', url(r'^$', views.JobList.as_view(template_name='jobs/jobs.html', ), name='jobs'), url(r'^post/$', check_honeypot( views.PostJob.as_view(template_name='jobs/post_job.html', form_class=forms.PostJobForm)), name='post_job'), url(r'^post/success/$', views.PostJobSuccess.as_view(template_name='jobs/success.html'), name='success'), url(r'^(?P<slug>[-\w]+)/$', views.JobDetail.as_view(template_name='jobs/job_detail.html', ), name='job_detail'), )
def test_decorator_argument(self): """ test that check_honeypot(view, 'fieldname') works """ new_view_func = check_honeypot(view_func, 'fieldname') request = _get_POST_request() resp = new_view_func(request) self.assertEquals(resp.__class__, HttpResponseBadRequest)
from userena import views as userena_views from userena import settings as userena_settings from apps.member.forms import I4PSignupForm import views as member_views # TODO: Why are we NOT using (r'^members/', include('userena.urls'))? # De-sync with userena has already caused multiple bugs in the past... urlpatterns = patterns( "", url(r"^", include("social_auth.urls")), url(r"^quote/$", member_views.MembersQuoteView.as_view(), name="members_quotations"), # Signup, signin and signout url(r"^signup/$", check_honeypot(member_views.signup), {"signup_form": I4PSignupForm}, name="userena_signup"), url(r"^signin/$", member_views.signin, name="userena_signin"), url(r"^signout/$", auth_views.logout, {"template_name": "userena/signout.html"}, name="userena_signout"), # Reset password url( r"^password/reset/$", auth_views.password_reset, { "template_name": "userena/password_reset_form.html", "email_template_name": "userena/emails/password_reset_message.txt", }, name="userena_password_reset", ), url( r"^password/reset/done/$", auth_views.password_reset_done,
from django.conf.urls.defaults import * from django.views.decorators.cache import never_cache from honeypot.decorators import check_honeypot from brainstorm.views import IdeaList, IdeaDetail, CreateIdea from brainstorm.feeds import SubsiteFeed # feeds live at rss/latest/site-name/ urlpatterns = patterns( '', url(r'^rss/latest/$', SubsiteFeed()), ) urlpatterns += patterns( 'brainstorm.views', url(r'^(?P<slug>[\w-]+)/$', never_cache(IdeaList.as_view(ordering='most_popular')), name='ideas_popular'), url(r'^(?P<slug>[\w-]+)/latest/$', never_cache(IdeaList.as_view(ordering='latest')), name='ideas_latest'), url(r'^(?P<slug>[\w-]+)/(?P<id>\d+)/$', never_cache(IdeaDetail.as_view()), name='idea_detail'), url(r'^(?P<slug>[\w-]+)/new_idea/$', never_cache(check_honeypot(CreateIdea.as_view())), name='new_idea'), url(r'^(?P<slug>[\w-]+)/(?P<id>\d+)/votes(?P<format>(\.json))?/?$', 'vote', name='idea_vote'), )
from apps.member.forms import I4PSignupForm import views as member_views # TODO: Why are we NOT using (r'^members/', include('userena.urls'))? # De-sync with userena has already caused multiple bugs in the past... urlpatterns = patterns( '', url(r'^', include('social_auth.urls')), url(r'^quote/$', member_views.MembersQuoteView.as_view(), name='members_quotations'), # Signup, signin and signout url(r'^signup/$', check_honeypot(member_views.signup), {'signup_form': I4PSignupForm}, name='userena_signup'), url(r'^signin/$', member_views.signin, name='userena_signin'), url(r'^signout/$', auth_views.logout, {'template_name': 'userena/signout.html'}, name='userena_signout'), # Reset password url(r'^password/reset/$', auth_views.password_reset, { 'template_name': 'userena/password_reset_form.html', 'email_template_name': 'userena/emails/password_reset_message.txt' }, name='userena_password_reset'), url(r'^password/reset/done/$', auth_views.password_reset_done,
from django.conf.urls import patterns, url, include from contact.views import ContactView, ContactThanksView from honeypot.decorators import check_honeypot urlpatterns = patterns('', url(r'^$', check_honeypot(ContactView.as_view()), name='contact'), url(r'^thanks/$', ContactThanksView.as_view(), name='contact-thanks'), )
urlpatterns = [ # System/Core url(r'^admin/', include(admin.site.urls)), url(r'^admin/doc/', include('django.contrib.admindocs.urls')), url(r'^accounts/login/','django.contrib.auth.views.login'), url(r'^accounts/logout/','django.contrib.auth.views.logout',{'template_name':'registration/login.html'}), url(r'^sitemap\.xml$', sitemap, {'sitemaps': SITEMAP_OBJECTS}, name='django.contrib.sitemaps.views.sitemap'), # Contributed url(r'^admin_tools/', include('admin_tools.urls')), url(r'^summernote/', include('django_summernote.urls')), # Custom Apps url(r'^gamescripts/', include('secondlife.urls')), url(r'^personal/cooking/menu/', include('deerfood.urls',namespace='deerfood')), url(r'^contact/$',check_honeypot(contact_page.as_view()),name='contact'), url(r'^contact.php',check_honeypot(contact_page.as_view()),name='contact_old'), # Temporary legacy support for partial roll-out # DeerTrees and DeerBooks are special cases for this site. url(r'^$',deertrees_views.homepage.as_view(),name='home'), url(r'^tags/$',deertrees_views.all_tags.as_view(),name='all_tags'), url(r'^tags/(?P<slug>.*)/$',deertrees_views.tag_list.as_view(),name='tag'), url(r'^about/sitemap\.htm$',cache_control(max_age=60*60*48)(deertrees_views.sitemap.as_view()),name='sitemap_htm'), url(r'^(?P<cached_url>[\w\d_/-]+)/book\.(?P<slug>.*)\.tex',deerbooks_views.book_tex.as_view(),name='book_tex'), url(r'^(?P<cached_url>[\w\d_/-]+)/book\.(?P<slug>.*)\.md',deerbooks_views.book_md.as_view(),name='book_md'), url(r'^(?P<cached_url>[\w\d_/-]+)/book\.(?P<slug>.*)\.txt',deerbooks_views.book_txt.as_view(),name='book_txt'), url(r'^(?P<cached_url>[\w\d_/-]+)/(?P<slug>.*)\.htm',deerbooks_views.single_page_htm.as_view(),name='page_htm'), url(r'^(?P<cached_url>[\w\d_/-]+)/(?P<slug>.*)\.txt',deerbooks_views.single_page_txt.as_view(),name='page_txt'), url(r'^(?P<cached_url>[\w\d_/-]+)/(?P<slug>.*)\.md',deerbooks_views.single_page_md.as_view(),name='page_md'),
Created on 23 Oct 2013 @author: michael """ from django.conf.urls import patterns, url from django.views import generic as generic_views from honeypot.decorators import check_honeypot from tunobase.corporate.company_info.contact import views, forms urlpatterns = patterns('', url(r'^contact/$', check_honeypot(views.Contact.as_view( template_name='contact/contact.html', form_class=forms.ContactMessageForm )), name='company_info_contact' ), url(r'^contact/thanks/$', generic_views.TemplateView.as_view( template_name='contact/contact_thanks.html' ), name='company_info_contact_thanks' ), )
from django.conf.urls.defaults import patterns, url from django.views.generic import TemplateView from honeypot.decorators import check_honeypot from .views import CreateStoryView, DetailStoryView, ListStoryView urlpatterns = patterns('', url('^story/add/$', check_honeypot(CreateStoryView.as_view()), name='story_create' ), url('^story/add/success/$', TemplateView.as_view( template_name='stories/story_create_success.html', ), name='story_create_success' ), url('^story/list/', ListStoryView.as_view(), name='story_list' ), url('^story/(?P<pk>\d+)/$', DetailStoryView.as_view(), name='story_detail' ), )
handler404 = not_found handler500 = system_error handler403 = denied_error urlpatterns = [ url(r'^s/(?P<type>.)(?P<pk>[0-9]+)', shortcode_redirect, name='shortcode'), url(r'^admin/', include(admin.site.urls)), url(r'^admin/doc/', include('django.contrib.admindocs.urls')), url(r'^admin_tools/', include('admin_tools.urls')), url(r'^accounts/login/', login_view, name='login'), url(r'^accounts/logout/', logout_view, {'template_name': 'registration/login.html'}, name='logout'), url(r'^accounts/age_form/$', never_cache( check_honeypot(field_name=settings.HONEYPOT_FIELD_NAME_AWIACCESS)( access_views.age_verify_full.as_view())), name='age_form'), url(r'^accounts/age_form_embed/$', never_cache( check_honeypot(field_name=settings.HONEYPOT_FIELD_NAME_AWIACCESS)( access_views.age_verify.as_view())), name='age_form_embed'), url(r'^settings/$', access_views.settings_page.as_view(), name='settings'), url(r'^search/', search_view.as_view(), name='haystack_search'), # APIs and utility views url(r'^tools/category_list/$', permission_required('deertrees.change_leaf')( deertrees_views.all_cats.as_view()), name='all_cats'), url(r'^tools/sunset/(?P<slug>.*)\.json',
from django.views import generic as generic_views from honeypot.decorators import check_honeypot from app.jobs import views, forms urlpatterns = patterns('', url(r'^$', views.JobList.as_view( template_name='jobs/jobs.html', ), name='jobs' ), url(r'^post/$', check_honeypot(views.PostJob.as_view( template_name='jobs/post_job.html', form_class=forms.PostJobForm )), name='post_job' ), url(r'^post/success/$', views.PostJobSuccess.as_view( template_name='jobs/success.html' ), name='success' ), url(r'^(?P<slug>[-\w]+)/$', views.JobDetail.as_view( template_name='jobs/job_detail.html', ),
form_class=forms.UpdateProfilePasswordForm, template_name='authentication/profile_change_password.html'), name='secure_profile_change_password'), # Registration and activation url(r'^secure/activate/(?P<activation_key>\w+)/$', views.ProjectActivation.as_view( template_name='authentication/activation_complete.html'), name='secure_activate'), url(r'^activate/complete/$', TemplateView.as_view( template_name='authentication/activation_complete.html'), name='registration_activation_complete'), url(r'^secure/register/$', check_honeypot( views.ProjectRegistration.as_view( template_name='authentication/apply.html', form_class=forms.ProjectRegistrationForm)), name='secure_register'), url( r'^register/complete/$', TemplateView.as_view( #template_name='authentication/registration_complete.html' template_name='authentication/apply_success.html'), name='registration_complete'), url(r'^register/resend_email/(?P<pk>\d+)/$', staff_member_required(views.ResendRegistrationEmail.as_view()), name='registration_resend_email'), # Authentication url(r'^secure/password_reset/$', 'django.contrib.auth.views.password_reset', {
url(r'', include('whitechapel_pages.urls')), url(r'^blog/', include('whitechapel_blog.urls')), url(r'^users/', include('whitechapel_users.urls')), url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), url(r'^api/v1/', include(router.urls)), url(r'^api/v1/query/features/$', QueryFeatures.as_view(), name='query_features'), url(r'^api/v1/query/documents/$', QueryDocuments.as_view(), name='query_documents'), url(r'^api/v1/query/images/$', QueryImages.as_view(), name='query_images'), url(r'^api/v1/query/media/$', QueryMedia.as_view(), name='query_media'), url(r'^ckeditor/', include('ckeditor_uploader.urls')), # django-filebrowser url(r'^admin/filebrowser/', include(site.urls)), # Search url(r'^search/', include('haystack.urls')), # Grappelli url(r'^grappelli/', include('grappelli.urls')), # django-allauth url(r'^accounts/logout/$', 'django.contrib.auth.views.logout', {'next_page': '/'}), url(r'^accounts/login/$', check_honeypot(account.views.login)), url(r'^accounts/', include('allauth.urls')), url(r'^accounts/profile/$', 'whitechapel_users.views.user_profile', name='user_profile'), url(r'^sitemap\.xml$', sitemap, {'sitemaps': sitemaps}, name='django.contrib.sitemaps.views.sitemap'), ] if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) # urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += staticfiles_urlpatterns()
from honeypot.decorators import check_honeypot from django.urls import path from vote.views import VoteView, json_take app_name = 'vote' urlpatterns = [ # / path('', check_honeypot(VoteView.as_view(), field_name='poll-answer'), name='vote'), # AJAX handlers # takes/<candidate_identifier>/<issue>/ path('takes/<uuid:candidate_identifier>/<str:issue>/', json_take, name='candidate_takes'), ]
never_cache(SessionList.as_view()), name="session_list"), url(r'^(?P<event_slug>[\w-]+)/wall/$', never_cache(SingleDayView.as_view(template_name="sked/wall.html")), name="wall"), url(r'^(?P<event_slug>[\w-]+)/print/$', never_cache( SingleDayView.as_view(template_name="sked/analog_wall.html")), name="analog_wall"), url(r'^(?P<event_slug>[\w-]+)/print/timeslot/$', never_cache( CurrentTimeslotView.as_view( template_name="sked/analog_wall.html")), name="analog_wall_for_timeslot"), url(r'^(?P<event_slug>[\w-]+)/tv/$', never_cache(CurrentTimeslotView.as_view(template_name="sked/tv.html")), name="tv"), url(r'^(?P<event_slug>[\w-]+)/new/$', never_cache(check_honeypot(CreateSession.as_view())), name="new_session"), url(r'^(?P<event_slug>[\w-]+)/(?P<slug>[\w-]+)/edit/$', never_cache(UpdateSession.as_view()), name="edit_session"), url(r'^(?P<event_slug>[\w-]+)/(?P<slug>[\w-]+)/preview/$', SessionDetail.as_view(preview=True), name="session_preview"), url(r'^(?P<event_slug>[\w-]+)/(?P<slug>[\w-]+)/$', SessionDetail.as_view(), name="session_detail"), )
profile.add_redirect_on_next_page(redirect_with_next(reverse('cosinnus:welcome-settings'), self.request), message=None, priority=True) return ret def dispatch(self, *args, **kwargs): if self.request.user.is_authenticated(): messages.info(self.request, _('You are already logged in!')) return redirect('/') return super(UserCreateView, self).dispatch(*args, **kwargs) def get_context_data(self, **kwargs): context = super(UserCreateView, self).get_context_data(**kwargs) context['submit_label'] = _('Create') return context user_create = check_honeypot(UserCreateView.as_view()) class WelcomeSettingsView(RequireLoggedInMixin, TemplateView): """ A welcome settings page that saves the two most important privacy aspects: the global notification setting and the userprofile visibility setting. """ template_name = 'cosinnus/user/welcome_settings.html' message_success = _('Your privacy settings were saved. Welcome!') def post(self, request, *args, **kwargs): self.get_data() with transaction.atomic(): # save language preference: notification_setting = request.POST.get('notification_setting', None) if notification_setting is not None and int(notification_setting) in (choice for choice, label in self.notification_choices):
def test_default_decorator(self): """ test that @check_honeypot works and defaults to HONEYPOT_FIELD_NAME """ new_view_func = check_honeypot(view_func) request = _get_POST_request() resp = new_view_func(request) self.assertEquals(resp.__class__, HttpResponseBadRequest)
from django.conf.urls.defaults import patterns, url from django.contrib.auth import views as auth_views from honeypot.decorators import check_honeypot from userena import views as userena_views from userena import settings as userena_settings from apps.member.forms import I4PSignupForm import views as member_views urlpatterns = patterns( '', # Signup, signin and signout url(r'^signup/$', check_honeypot(userena_views.signup), { 'signup_form': I4PSignupForm, 'success_url': '/member/activate_success' }, name='userena_signup'), url(r'^signin/$', member_views.signin, name='userena_signin'), url(r'^signout/$', auth_views.logout, {'template_name': 'userena/signout.html'}, name='userena_signout'), # Reset password url(r'^password/reset/$', auth_views.password_reset, { 'template_name': 'userena/password_reset_form.html', 'email_template_name': 'userena/emails/password_reset_message.txt' },
from django.conf.urls.defaults import patterns, url, include from django.contrib.auth import views as auth_views from honeypot.decorators import check_honeypot from userena import views as userena_views from userena import settings as userena_settings from apps.member.forms import I4PSignupForm import views as member_views urlpatterns = patterns('', url(r'^', include('social_auth.urls')), # Signup, signin and signout url(r'^signup/$', check_honeypot(userena_views.signup), {'signup_form' : I4PSignupForm}, name='userena_signup'), url(r'^signin/$', member_views.signin, name='userena_signin'), url(r'^signout/$', auth_views.logout, {'template_name': 'userena/signout.html'}, name='userena_signout'), # Reset password url(r'^password/reset/$', auth_views.password_reset, {'template_name': 'userena/password_reset_form.html', 'email_template_name': 'userena/emails/password_reset_message.txt'},
from django.conf.urls import patterns, include, url from django.views.generic import RedirectView from django.views.decorators.cache import never_cache from honeypot.decorators import check_honeypot from camper.sked.views import (SessionList, SessionDetail, CreateSession, UpdateSession, SingleDayView, CurrentTimeslotView, LazyEventRedirectView) urlpatterns = patterns( 'camper.sked.views', url(r'^new/$', LazyEventRedirectView.as_view(viewname='sked:new_session')), url(r'^$', LazyEventRedirectView.as_view(viewname='sked:session_list')), url(r'^(?P<event_slug>[\w-]+)/$', never_cache(SessionList.as_view()), name="session_list"), url(r'^(?P<event_slug>[\w-]+)/wall/$', never_cache(SingleDayView.as_view(template_name="sked/wall.html")), name="wall"), url(r'^(?P<event_slug>[\w-]+)/print/$', never_cache(SingleDayView.as_view(template_name="sked/analog_wall.html")), name="analog_wall"), url(r'^(?P<event_slug>[\w-]+)/print/timeslot/$', never_cache(CurrentTimeslotView.as_view(template_name="sked/analog_wall.html")), name="analog_wall_for_timeslot"), url(r'^(?P<event_slug>[\w-]+)/tv/$', never_cache(CurrentTimeslotView.as_view(template_name="sked/tv.html")), name="tv"), url(r'^(?P<event_slug>[\w-]+)/new/$', never_cache(check_honeypot(CreateSession.as_view())), name="new_session"), url(r'^(?P<event_slug>[\w-]+)/(?P<slug>[\w-]+)/edit/$', never_cache(UpdateSession.as_view()), name="edit_session"), url(r'^(?P<event_slug>[\w-]+)/(?P<slug>[\w-]+)/preview/$', SessionDetail.as_view(preview=True), name="session_preview"), url(r'^(?P<event_slug>[\w-]+)/(?P<slug>[\w-]+)/$', SessionDetail.as_view(), name="session_detail"), )
views.ProjectActivation.as_view( template_name='authentication/activation_complete.html' ), name='secure_activate' ), url(r'^activate/complete/$', TemplateView.as_view( template_name='authentication/activation_complete.html' ), name='registration_activation_complete' ), url(r'^secure/register/$', check_honeypot(views.ProjectRegistration.as_view( template_name='authentication/apply.html', form_class=forms.ProjectRegistrationForm )), name='secure_register' ), url(r'^register/complete/$', TemplateView.as_view( #template_name='authentication/registration_complete.html' template_name='authentication/apply_success.html' ), name='registration_complete' ), url(r'^register/resend_email/(?P<pk>\d+)/$', staff_member_required( views.ResendRegistrationEmail.as_view()
from django.views.decorators.cache import never_cache from honeypot.decorators import check_honeypot from brainstorm.views import IdeaList, IdeaDetail, CreateIdea from brainstorm.feeds import SubsiteFeed # feeds live at rss/latest/site-name/ urlpatterns = patterns( '', url(r'^rss/latest/$', SubsiteFeed()), ) urlpatterns += patterns( 'brainstorm.views', url(r'^(?P<slug>[\w-]+)/$', never_cache(IdeaList.as_view(ordering='most_popular')), name='ideas_popular'), url(r'^(?P<slug>[\w-]+)/latest/$', never_cache(IdeaList.as_view(ordering='latest')), name='ideas_latest'), url(r'^(?P<slug>[\w-]+)/(?P<id>\d+)/$', never_cache(IdeaDetail.as_view()), name='idea_detail'), url(r'^(?P<slug>[\w-]+)/new_idea/$', never_cache(check_honeypot(CreateIdea.as_view())), name='new_idea'), url(r'^(?P<slug>[\w-]+)/(?P<id>\d+)/votes(?P<format>(\.json))?/?$', 'vote', name='idea_vote'), )
from apps.member.forms import I4PSignupForm import views as member_views # TODO: Why are we NOT using (r'^members/', include('userena.urls'))? # De-sync with userena has already caused multiple bugs in the past... urlpatterns = patterns('', url(r'^', include('social_auth.urls')), url(r'^quote/$', member_views.MembersQuoteView.as_view(), name='members_quotations'), # Signup, signin and signout url(r'^signup/$', check_honeypot(member_views.signup), {'signup_form' : I4PSignupForm}, name='userena_signup'), url(r'^signin/$', member_views.signin, name='userena_signin'), url(r'^signout/$', auth_views.logout, {'template_name': 'userena/signout.html'}, name='userena_signout'), # Reset password url(r'^password/reset/$', auth_views.password_reset, {'template_name': 'userena/password_reset_form.html', 'email_template_name': 'userena/emails/password_reset_message.txt'},
from honeypot.decorators import check_honeypot from django.urls import path from login.views import VoterLoginView, AdminLoginView app_name = 'login' urlpatterns = [ # /login/ path('', check_honeypot(VoterLoginView.as_view(), field_name="idnumber"), name='login'), # /admin_login/ path('admin/', check_honeypot(AdminLoginView.as_view(), field_name="username1"), name='admin_login'), ]