from allauth.account import views as account_views
from django.contrib.messages.views import SuccessMessageMixin
from django.core.urlresolvers import reverse
from django.shortcuts import get_object_or_404
from django.utils.translation import ugettext as _
from django.views import generic

from apps.users.models import User
from . import forms


class AccountEmailView(account_views.EmailView):
    template_name = 'meinberlin_account/email.html'
    menu_item = 'email'

    def get_success_url(self):
        return reverse('account-email')


class ProfileUpdateView(SuccessMessageMixin,
                        generic.UpdateView):

    model = User
    template_name = "meinberlin_account/profile.html"
    form_class = forms.ProfileForm
    success_message = _("Your profile was successfully updated.")
    menu_item = 'profile'

    def get_success_url(self):
        return reverse('account-profile')

    def get_object(self):
        return get_object_or_404(User, pk=self.request.user.id)


class ChangePasswordView(account_views.PasswordChangeView):
    menu_item = 'password'
    template_name = 'meinberlin_account/password.html'
    menu_item = 'password'

    def get_success_url(self):
        return reverse('account-password')

@@ -357,18 +357,149 @@
 ount
-EmailView(
+BaseMixin:%0A    def get_success_url(self):%0A        return self.request.path%0A%0A%0Aclass AccountEmailView(AccountBaseMixin,%0A                       
 acco
@@ -601,105 +601,75 @@
 l'%0A%0A
-    def get_success_url(self):%0A        return reverse('account-email')%0A%0A%0Aclass ProfileUpdateView(
+%0Aclass ProfileUpdateView(AccountBaseMixin,%0A                        
 Succ
@@ -934,82 +934,8 @@
 e'%0A%0A
-    def get_success_url(self):%0A        return reverse('account-profile')%0A%0A
     
@@ -1047,16 +1047,59 @@
 ordView(
+AccountBaseMixin,%0A                         
 account_
@@ -1238,79 +1238,4 @@
 rd'%0A
-%0A    def get_success_url(self):%0A        return reverse('account-password')%0A

refactor success_urls