Exemple #1
0
class Logout(auth_views.LogoutView):
    LOGOUT_REDIRECT_URL = reverse_lazy(
        'customers:login', host="customers"
    )

    def get_next_page(self):
        if self.next_page is not None:
            next_page = resolve_url(self.next_page)
        elif self.LOGOUT_REDIRECT_URL:
            next_page = resolve_url(self.LOGOUT_REDIRECT_URL)
        else:
            next_page = self.next_page

        if self.redirect_field_name in self.request.POST or self.redirect_field_name in self.request.GET:
            next_page = self.request.POST.get(
                self.redirect_field_name,
                self.request.GET.get(self.redirect_field_name)
            )
            url_is_safe = is_safe_url(
                url=next_page,
                allowed_hosts=self.get_success_url_allowed_hosts(),
                require_https=self.request.is_secure(),
            )
            # Security check -- Ensure the user-originating redirection URL is
            # safe.
            if not url_is_safe:
                next_page = self.request.path

        return next_page
Exemple #2
0
 def test_post(self):
     """A user who posts their email should be sent an email."""
     data = {'email': self.user.email}
     kwargs = {
         'template_name':
         'foiamachine/views/registration/password_reset.html',
         'email_template_name':
         'foiamachine/emails/password_reset_email.html',
         'post_reset_redirect':
         reverse_lazy('password-reset-done', host='foiamachine'),
         'password_reset_form':
         PasswordResetForm
     }
     response = http_post_response(self.url, self.view, data, **kwargs)
     eq_(response.status_code, 302)
Exemple #3
0
    def post(self, request, *args, **kwargs):
        cf = CustomerForm(request.POST)
        uc = UserCreationForm(request.POST)

        if not cf.is_valid() or not uc.is_valid():
            ctx = dict()
            ctx.update({
                "customer_form": cf,
                "auth_form": uc
            })
            return HttpResponse(render(request, self.template_name, ctx))

        else:
            c = cf.save()
            u = uc.save()
            c.user = u
            c.save()
            return HttpResponseRedirect(
                reverse_lazy("customers:login", host="customers")
            )
Exemple #4
0
 url(r'^$', views.Homepage.as_view(), name='index'),
 url(r'^accounts/signup/$', views.Signup.as_view(), name='signup'),
 url(r'^accounts/login/$',
     auth_views.login,
     {'template_name': 'foiamachine/views/registration/login.html'},
     name='login'),
 url(r'^accounts/logout/$',
     auth_views.logout, {'next_page': 'index'},
     name='logout'),
 url(r'^accounts/profile/$', views.Profile.as_view(), name='profile'),
 url(r'^accounts/password_change/$',
     auth_views.password_change, {
         'template_name':
         'foiamachine/views/registration/password_change.html',
         'post_change_redirect':
         reverse_lazy('password-change-done', host='foiamachine')
     },
     name='password-change'),
 url(r'^accounts/password_change/done/$',
     auth_views.password_change_done, {
         'template_name':
         'foiamachine/views/registration/password_change_done.html'
     },
     name='password-change-done'),
 url(r'^accounts/password_reset/$',
     auth_views.password_reset, {
         'template_name':
         'foiamachine/views/registration/password_reset.html',
         'email_template_name':
         'foiamachine/emails/password_reset_email.html',
         'post_reset_redirect':
 def get_redirect_url(self, *args, **kwargs):
     url = reverse_lazy(host='www', viewname='mount', kwargs={'stream': kwargs["stream"]})
     return url
from django.conf.urls import patterns, include, url
from django.views.generic import RedirectView

from django_hosts.resolvers import reverse_lazy

from . import handler500

class MountRedirectView(RedirectView):

    def get_redirect_url(self, *args, **kwargs):
        url = reverse_lazy(host='www', viewname='mount', kwargs={'stream': kwargs["stream"]})
        return url


urlpatterns = patterns('',
    url(r'^$', RedirectView.as_view(url=reverse_lazy(host='www', viewname='root'), permanent=True)),
    url(r'^(?P<stream>.*\.(mp3|ogg|ogm|nsv|aac|m3u8))$', MountRedirectView.as_view(permanent=True)),
    url(r'^', include('shorturls.urls')),
    url(r'^', include('extshorturls.urls')),
)
Exemple #7
0
 def get_success_url(self):
     return reverse_lazy("customers:dashboard", host="customers")
Exemple #8
0
 def get_login_url(self):
     return reverse_lazy(
         "customers:login", host="customers"
     )
Exemple #9
0
urlpatterns = [
    url(r'^$', views.Homepage.as_view(), name='index'),
    url(
        r'^accounts/signup/$',
        RedirectView.as_view(
            url=settings.SQUARELET_URL + '/accounts/signup/?intent=foiamachine'
        ),
        name='signup'
    ),
    url(
        r'^accounts/login/$',
        RedirectView.as_view(
            url=reverse_lazy(
                'social:begin',
                host='foiamachine',
                kwargs={'backend': 'squarelet'},
            ),
            query_string=True
        ),
        name='login'
    ),
    url(r'^accounts/logout/$', views.account_logout, name='acct-logout'),
    url(r'^accounts/profile/$', views.Profile.as_view(), name='profile'),
    url(
        r'^foi/create/$',
        views.FoiaMachineRequestCreateView.as_view(),
        name='foi-create'
    ),
    url(
        r'^foi/(?P<slug>[\w-]+)-(?P<pk>\d+)/$',
Exemple #10
0
 url(r'^accounts/signup/$', views.Signup.as_view(), name='signup'),
 url(r'^accounts/login/$',
     auth_views.login,
     {'template_name': 'foiamachine/views/registration/login.html'},
     name='login'),
 url(r'^accounts/logout/$',
     auth_views.logout,
     {'next_page': 'index'},
     name='logout'),
 url(r'^accounts/profile/$',
     views.Profile.as_view(),
     name='profile'),
 url(r'^accounts/password_change/$',
     auth_views.password_change,
     {'template_name': 'foiamachine/views/registration/password_change.html',
      'post_change_redirect': reverse_lazy('password-change-done', host='foiamachine')},
     name='password-change'),
 url(r'^accounts/password_change/done/$',
     auth_views.password_change_done,
     {'template_name': 'foiamachine/views/registration/password_change_done.html'},
     name='password-change-done'),
 url(r'^accounts/password_reset/$',
     auth_views.password_reset,
     {
         'template_name': 'foiamachine/views/registration/password_reset.html',
         'email_template_name': 'foiamachine/emails/password_reset_email.html',
         'post_reset_redirect': reverse_lazy('password-reset-done', host='foiamachine'),
         'password_reset_form': PasswordResetForm
     },
     name='password-reset'),
 url(r'^accounts/password_reset/(?P<uidb64>[0-9A-Za-z]+)-(?P<token>.+)/$',