# Path: tango_user/filters.py
# class ProfileFilter(django_filters.FilterSet):
#     display_name = django_filters.CharFilter(lookup_expr='icontains')
# 
#     class Meta:
#         model = get_user_model()
#         fields = ['display_name']
# 
# Path: tango_user/forms.py
# class PublicProfileForm(forms.ModelForm):
#     """
#     Allows for profile and settings updates.
#     Note that template checks for "Open board links" label.
#     Anything below that will be in a 'settings' fieldset.
#     """
#     class Meta:
#         model = Profile
#         fields = (
#             'display_name',
#             'street_address',
#             'city',
#             'state',
#             'country',
#             'zipcode',
#             'occupation',
#             'interests',
#             'birthday',
#             'homepage',
#             'bio',
#             'avatar',
#             'signature',
#         )
# 
# class ProfileSettingsForm(forms.ModelForm):
#     """
#     Allows for modifying profile settings
#     """
#     class Meta:
#         model = Profile
#         fields = (
#             'display_on_map',
#             'show_signatures',
#             'theme'
#         )


import datetime
import json
from django.contrib.auth import get_user_model
from django.contrib.auth.decorators import login_required
from django.contrib import messages
from django.http import HttpResponse
from django.shortcuts import render, get_object_or_404
from django.urls import reverse
from django.utils.decorators import method_decorator
from django.views.generic import ListView
from django.views.generic.edit import UpdateView
from .filters import ProfileFilter
from .forms import PublicProfileForm, ProfileSettingsForm

        context = super(MemberList, self).get_context_data(**kwargs)
        if 'display_name' in self.request.GET or 'state' in self.request.GET:
            filter = ProfileFilter(self.request.GET, queryset=self.queryset)
        else:
            filter = ProfileFilter()
        context['filter'] = filter
        return context
member_index = MemberList.as_view()


class EditProfile(UpdateView):
    model = UserModel
    template_name = "users/user_edit_form.html"
    form_class = PublicProfileForm

    @method_decorator(login_required)
    def dispatch(self, *args, **kwargs):
        return super(EditProfile, self).dispatch(*args, **kwargs)

    def get_object(self, queryset=None):
        return self.request.user

    def get_context_data(self, **kwargs):
        context = super(EditProfile, self).get_context_data(**kwargs)
        context['settings_form'] = ProfileSettingsForm(instance=self.get_object())
        return context
edit_profile = EditProfile.as_view()


class EditProfileSettings(EditProfile):

# Path: tango_user/filters.py
# class ProfileFilter(django_filters.FilterSet):
#     display_name = django_filters.CharFilter(lookup_expr='icontains')
# 
#     class Meta:
#         model = get_user_model()
#         fields = ['display_name']
# 
# Path: tango_user/forms.py
# class PublicProfileForm(forms.ModelForm):
#     """
#     Allows for profile and settings updates.
#     Note that template checks for "Open board links" label.
#     Anything below that will be in a 'settings' fieldset.
#     """
#     class Meta:
#         model = Profile
#         fields = (
#             'display_name',
#             'street_address',
#             'city',
#             'state',
#             'country',
#             'zipcode',
#             'occupation',
#             'interests',
#             'birthday',
#             'homepage',
#             'bio',
#             'avatar',
#             'signature',
#         )
# 
# class ProfileSettingsForm(forms.ModelForm):
#     """
#     Allows for modifying profile settings
#     """
#     class Meta:
#         model = Profile
#         fields = (
#             'display_on_map',
#             'show_signatures',
#             'theme'
#         )


# Path: tango_user/views.py
import datetime
import json
from django.contrib.auth import get_user_model
from django.contrib.auth.decorators import login_required
from django.contrib import messages
from django.http import HttpResponse
from django.shortcuts import render, get_object_or_404
from django.urls import reverse
from django.utils.decorators import method_decorator
from django.views.generic import ListView
from django.views.generic.edit import UpdateView
from .filters import ProfileFilter
from .forms import PublicProfileForm, ProfileSettingsForm

        context = super(MemberList, self).get_context_data(**kwargs)
        if 'display_name' in self.request.GET or 'state' in self.request.GET:
            filter = ProfileFilter(self.request.GET, queryset=self.queryset)
        else:
            filter = ProfileFilter()
        context['filter'] = filter
        return context
member_index = MemberList.as_view()


class EditProfile(UpdateView):
    model = UserModel
    template_name = "users/user_edit_form.html"
    form_class = PublicProfileForm

    @method_decorator(login_required)
    def dispatch(self, *args, **kwargs):
        return super(EditProfile, self).dispatch(*args, **kwargs)

    def get_object(self, queryset=None):
        return self.request.user

    def get_context_data(self, **kwargs):
        context = super(EditProfile, self).get_context_data(**kwargs)
        context['settings_form'] = ProfileSettingsForm(instance=self.get_object())
        return context
edit_profile = EditProfile.as_view()


class EditProfileSettings(EditProfile):

    form_class = ProfileSettingsForm
