text: # -*- coding: utf-8 -*-
  from __future__ import unicode_literals
  
  from django.contrib.auth.decorators import login_required
  from django.contrib.auth.views import LoginView
  from django.http import HttpResponseForbidden, HttpResponse
  
  from django.urls import reverse_lazy
  from django.utils.decorators import method_decorator
  from django.views.generic import CreateView, TemplateView
  
  from partner.partner.forms import RegisterUserForm, LoginForm
  
  
  class RegisterUserView(CreateView):
      form_class = RegisterUserForm
      template_name = "partner/account/register.html"
  
      def dispatch(self, request, *args, **kwargs):
          if request.user.is_authenticated():
              return HttpResponseForbidden()
  
          return super(RegisterUserView, self).dispatch(request, *args, **kwargs)
  
      def form_valid(self, form):
          user = form.save(commit=False)
          user.set_password(form.cleaned_data['password'])
          user.save()
          return HttpResponse('User registered')
  
  
  class LoginUserView(LoginView):
      form_class = LoginForm
      template_name = "partner/account/login.html"
      redirect_authenticated_user = True
      success_url = reverse_lazy('dashboard')
  
  
  @method_decorator(login_required, name='dispatch')
  class DashboardView(TemplateView):
      template_name = 'partner/account/dashboard.html'
      
      def dispatch(self, request, *args, **kwargs):
          return super(DashboardView, self).dispatch(request, *args, **kwargs)