# Path: userprofiles/settings.py
# class Settings(object):
#     def __init__(self, **kwargs):
#     def __getattr__(self, key):
# def validate_settings():


from django import forms
from django.utils.translation import ugettext_lazy as _
from userprofiles.settings import up_settings
from userprofiles.utils import UserProfile
    last_name = forms.CharField(label=_('Last name'), required=False)
    email = forms.EmailField(label=_('E-mail'))

    def __init__(self, *args, **kwargs):
        super(ProfileForm, self).__init__(*args, **kwargs)

        if not up_settings.PROFILE_ALLOW_EMAIL_CHANGE:
            del self.fields['email']
        else:
            self.fields.keyOrder.remove('email')
            self.fields.keyOrder.insert(0, 'email')

        if not up_settings.REGISTRATION_FULLNAME:
            del self.fields['first_name']
            del self.fields['last_name']
        else:
            self.fields.keyOrder.remove('first_name')
            self.fields.keyOrder.remove('last_name')
            self.fields.keyOrder.insert(0, 'first_name')
            self.fields.keyOrder.insert(1, 'last_name')

    def save(self, *args, **kwargs):
        obj = super(ProfileForm, self).save(*args, **kwargs)
        if up_settings.REGISTRATION_FULLNAME:
            obj.user.first_name = self.cleaned_data['first_name']
            obj.user.last_name = self.cleaned_data['last_name']

        if up_settings.PROFILE_ALLOW_EMAIL_CHANGE:
            obj.user.email = self.cleaned_data['email']


# Path: userprofiles/settings.py
# class Settings(object):
#     def __init__(self, **kwargs):
#     def __getattr__(self, key):
# def validate_settings():


# Path: userprofiles/contrib/profiles/forms.py
from django import forms
from django.utils.translation import ugettext_lazy as _
from userprofiles.settings import up_settings
from userprofiles.utils import UserProfile

    last_name = forms.CharField(label=_('Last name'), required=False)
    email = forms.EmailField(label=_('E-mail'))

    def __init__(self, *args, **kwargs):
        super(ProfileForm, self).__init__(*args, **kwargs)

        if not up_settings.PROFILE_ALLOW_EMAIL_CHANGE:
            del self.fields['email']
        else:
            self.fields.keyOrder.remove('email')
            self.fields.keyOrder.insert(0, 'email')

        if not up_settings.REGISTRATION_FULLNAME:
            del self.fields['first_name']
            del self.fields['last_name']
        else:
            self.fields.keyOrder.remove('first_name')
            self.fields.keyOrder.remove('last_name')
            self.fields.keyOrder.insert(0, 'first_name')
            self.fields.keyOrder.insert(1, 'last_name')

    def save(self, *args, **kwargs):
        obj = super(ProfileForm, self).save(*args, **kwargs)
        if up_settings.REGISTRATION_FULLNAME:
            obj.user.first_name = self.cleaned_data['first_name']
            obj.user.last_name = self.cleaned_data['last_name']

        if up_settings.PROFILE_ALLOW_EMAIL_CHANGE:
            obj.user.email = self.cleaned_data['email']


        if up_settings.REGISTRATION_FULLNAME or up_settings.PROFILE_ALLOW_EMAIL_CHANGE: