def __init__(self, user, *args, **kwargs):
        "Sets choices and initial value"
        super(SettingsForm, self).__init__(*args, **kwargs)

        self.fields['default_perspective'].label = _("Default Perspective")
        self.fields['language'].label = _("Language")
        self.fields['default_timezone'].label = _("Time Zone")
        self.fields['email_notifications'].label = _("E-mail Notifications")

        self.user = user

        self.fields['default_perspective'].queryset = Object.filter_permitted(
            user, Perspective.objects)
        try:
            conf = ModuleSetting.get_for_module(
                'treeio.core', 'default_perspective', user=self.user)[0]
            default_perspective = Perspective.objects.get(pk=long(conf.value))
            self.fields['default_perspective'].initial = default_perspective.id
        except:
            pass

        self.fields['default_timezone'].choices = getattr(
            settings, 'HARDTREE_SERVER_TIMEZONE')
        timezone = settings.HARDTREE_SERVER_DEFAULT_TIMEZONE
        try:
            conf = ModuleSetting.get('default_timezone', user=user)[0]
            timezone = conf.value
        except:
            pass
        self.fields['default_timezone'].initial = timezone

        self.fields['language'].choices = getattr(
            settings, 'HARDTREE_LANGUAGES', [('en', 'English')])
        language = getattr(settings, 'HARDTREE_LANGUAGES_DEFAULT', '')
        try:
            conf = ModuleSetting.get('language', user=user)[0]
            language = conf.value
        except __HOLE__:
            pass
        self.fields['language'].initial = language

        try:
            conf = ModuleSetting.get('email_notifications', user=user)[0]
            self.fields['email_notifications'].initial = conf.value
        except:
            self.fields[
                'email_notifications'].initial = settings.HARDTREE_ALLOW_EMAIL_NOTIFICATIONS

        perspective = user.get_perspective()

        modules = perspective.modules.filter(display=True).order_by('title')
        if not modules:
            modules = Module.objects.filter(display=True).order_by('title')
        self.fields['notifications_for_modules'].choices = [
            (module.pk, module.title) for module in modules]

        try:
            modules = NotificationSetting.objects.get(
                owner=self.user).modules.all()
            self.fields['notifications_for_modules'].initial = [
                m.pk for m in modules]
        except (NotificationSetting.DoesNotExist, NotificationSetting.MultipleObjectsReturned):
            pass
dataset/ETHPy150Open treeio/treeio/treeio/account/forms.py/SettingsForm.__init__