@treeio_login_required
def settings_view(request, response_format='html'):
    "Settings view"
    user = request.user.profile

    # default permissions
    try:
        conf = ModuleSetting.get_for_module(
            'treeio.core', 'default_permissions', user=user)[0]
        default_permissions = conf.value
    except:
        default_permissions = settings.HARDTREE_DEFAULT_PERMISSIONS

    # default perspective
    try:
        conf = ModuleSetting.get_for_module(
            'treeio.core', 'default_perspective', user=user)[0]
        default_perspective = Perspective.objects.get(pk=long(conf.value))
    except:
        default_perspective = None

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

    # time zone
    default_timezone = settings.HARDTREE_SERVER_DEFAULT_TIMEZONE
    try:
        conf = ModuleSetting.get('default_timezone')[0]
        default_timezone = conf.value
    except:
        pass

    try:
        conf = ModuleSetting.get('default_timezone', user=user)[0]
        default_timezone = conf.value
    except:
        default_timezone = getattr(
            settings, 'HARDTREE_SERVER_TIMEZONE')[default_timezone][0]

    all_timezones = getattr(settings, 'HARDTREE_SERVER_TIMEZONE')

    # email notifications e.g. new task assigned to you
    email_notifications = getattr(
        settings, 'HARDTREE_ALLOW_EMAIL_NOTIFICATIONS', False)
    try:
        conf = ModuleSetting.get('email_notifications', user=user)[0]
        email_notifications = conf.value
    except:
        pass

    try:
        ns = NotificationSetting.objects.get(owner=user, enabled=True)
        notifications_for_modules = [m.title for m in ns.modules.all()]
    except NotificationSetting.DoesNotExist:
        notifications_for_modules = []

    return render_to_response('account/settings_view',
                              {
                                  'default_permissions': default_permissions,
                                  'default_perspective': default_perspective,
                                  'language': language,
                                  'all_languages': all_languages,
                                  'default_timezone': default_timezone,
                                  'all_timezones': all_timezones,
                                  'email_notifications': email_notifications,
                                  'notifications_for_modules': notifications_for_modules,
                              },
                              context_instance=RequestContext(request), response_format=response_format)
dataset/ETHPy150Open treeio/treeio/treeio/account/views.py/settings_view