from django.core.urlresolvers import reverse_lazy
from django.views.generic.edit import UpdateView

from rm.userprofiles.forms import ProfileForm
from rm.userprofiles.models import RMUser


class RMUserUpdate(UpdateView):
    model      = RMUser
    form_class = ProfileForm
    success_url = reverse_lazy('account-edit')

    def get_object(self, *args, **kwargs):
        """
        Override the default get object to return the currently
        logged in user.
        """
        return self.request.user

from django.core.urlresolvers import reverse_lazy
from django.views.generic.edit import UpdateView

from rm.http import LoginRequiredMixin
from rm.userprofiles.forms import ProfileForm
from rm.userprofiles.models import RMUser


class RMUserUpdate(LoginRequiredMixin, UpdateView):
    model      = RMUser
    form_class = ProfileForm
    success_url = reverse_lazy('account-edit')

    def get_object(self, *args, **kwargs):
        """
        Override the default get object to return the currently
        logged in user.
        """
        return self.request.user

Make our account pages require a logged in user.
Make our account pages require a logged in user.

closes #221

  from django.core.urlresolvers import reverse_lazy
  from django.views.generic.edit import UpdateView
  
+ from rm.http import LoginRequiredMixin
  from rm.userprofiles.forms import ProfileForm
  from rm.userprofiles.models import RMUser
  
  
- class RMUserUpdate(UpdateView):
+ class RMUserUpdate(LoginRequiredMixin, UpdateView):
      model      = RMUser
      form_class = ProfileForm
      success_url = reverse_lazy('account-edit')
  
      def get_object(self, *args, **kwargs):
          """
          Override the default get object to return the currently
          logged in user.
          """
          return self.request.user
  
Make our account pages require a logged in user.
## Code Before:
from django.core.urlresolvers import reverse_lazy
from django.views.generic.edit import UpdateView

from rm.userprofiles.forms import ProfileForm
from rm.userprofiles.models import RMUser


class RMUserUpdate(UpdateView):
    model      = RMUser
    form_class = ProfileForm
    success_url = reverse_lazy('account-edit')

    def get_object(self, *args, **kwargs):
        """
        Override the default get object to return the currently
        logged in user.
        """
        return self.request.user

## Instruction:
Make our account pages require a logged in user.
## Code After:
from django.core.urlresolvers import reverse_lazy
from django.views.generic.edit import UpdateView

from rm.http import LoginRequiredMixin
from rm.userprofiles.forms import ProfileForm
from rm.userprofiles.models import RMUser


class RMUserUpdate(LoginRequiredMixin, UpdateView):
    model      = RMUser
    form_class = ProfileForm
    success_url = reverse_lazy('account-edit')

    def get_object(self, *args, **kwargs):
        """
        Override the default get object to return the currently
        logged in user.
        """
        return self.request.user
