# Path: InternetSemLimites/api/views.py
# def by_state(request, abbr):
#     state = get_object_or_404(State, abbr=abbr.upper())
#     fame = _serialize_query(state.provider_set.fame())
#     shame = _serialize_query(state.provider_set.shame())
#     return _to_json(fame, shame)
# 
# def fame(request):
#     providers = _serialize_query(Provider.objects.fame())
#     return _to_json(providers)
# 
# def fame_by_state(request, abbr):
#     providers = _serialize_query(_providers_by_state(abbr).fame())
#     return _to_json(providers)
# 
# def home(request):
#     fame = _serialize_query(Provider.objects.fame())
#     shame = _serialize_query(Provider.objects.shame())
#     return _to_json(fame, shame)
# 
# @csrf_exempt
# def provider(request, pk):
#     routes = {
#         'GET': provider_detail,
#         'POST': provider_edit
#     }
# 
#     route = routes.get(request.method)
# 
#     if route:
#         return route(request, pk)
#     return HttpResponseNotAllowed([method for method in routes])
# 
# @csrf_exempt
# def provider_new(request):
#     if request.method != 'POST':
#         return HttpResponseNotAllowed(['POST'])
# 
#     form = ProviderForm(request.POST)
#     if not form.is_valid():
#         return JsonResponse({'errors': form.errors})
# 
#     provider = form.save()
#     _send_mail('+1 InternetSemLimites',
#                settings.DEFAULT_FROM_EMAIL,
#                list(_get_admin_emails()),
#                'core/provider_email.txt',
#                dict(provider=provider))
# 
#     return HttpResponseRedirect(resolve_url('api:provider', provider.pk))
# 
# def shame(request):
#     providers = _serialize_query(Provider.objects.shame())
#     return _to_json(providers)
# 
# def shame_by_state(request, abbr):
#     providers = _serialize_query(_providers_by_state(abbr).shame())
#     return _to_json(providers)


from django.urls import path, register_converter
from InternetSemLimites.api.views import (
    by_state,
    fame,
    fame_by_state,
    home,
    provider,
    provider_new,
    shame,
    shame_by_state
)



class StateConverter:
    regex = '[\w]{2}'

    def to_python(self, value):
        return value.lower()

    def to_url(self, value):
        return value


register_converter(StateConverter, 'state')


app_name = 'api'


urlpatterns = [

# Path: InternetSemLimites/api/views.py
# def by_state(request, abbr):
#     state = get_object_or_404(State, abbr=abbr.upper())
#     fame = _serialize_query(state.provider_set.fame())
#     shame = _serialize_query(state.provider_set.shame())
#     return _to_json(fame, shame)
# 
# def fame(request):
#     providers = _serialize_query(Provider.objects.fame())
#     return _to_json(providers)
# 
# def fame_by_state(request, abbr):
#     providers = _serialize_query(_providers_by_state(abbr).fame())
#     return _to_json(providers)
# 
# def home(request):
#     fame = _serialize_query(Provider.objects.fame())
#     shame = _serialize_query(Provider.objects.shame())
#     return _to_json(fame, shame)
# 
# @csrf_exempt
# def provider(request, pk):
#     routes = {
#         'GET': provider_detail,
#         'POST': provider_edit
#     }
# 
#     route = routes.get(request.method)
# 
#     if route:
#         return route(request, pk)
#     return HttpResponseNotAllowed([method for method in routes])
# 
# @csrf_exempt
# def provider_new(request):
#     if request.method != 'POST':
#         return HttpResponseNotAllowed(['POST'])
# 
#     form = ProviderForm(request.POST)
#     if not form.is_valid():
#         return JsonResponse({'errors': form.errors})
# 
#     provider = form.save()
#     _send_mail('+1 InternetSemLimites',
#                settings.DEFAULT_FROM_EMAIL,
#                list(_get_admin_emails()),
#                'core/provider_email.txt',
#                dict(provider=provider))
# 
#     return HttpResponseRedirect(resolve_url('api:provider', provider.pk))
# 
# def shame(request):
#     providers = _serialize_query(Provider.objects.shame())
#     return _to_json(providers)
# 
# def shame_by_state(request, abbr):
#     providers = _serialize_query(_providers_by_state(abbr).shame())
#     return _to_json(providers)


# Path: InternetSemLimites/api/urls.py
from django.urls import path, register_converter
from InternetSemLimites.api.views import (
    by_state,
    fame,
    fame_by_state,
    home,
    provider,
    provider_new,
    shame,
    shame_by_state
)




class StateConverter:
    regex = '[\w]{2}'

    def to_python(self, value):
        return value.lower()

    def to_url(self, value):
        return value


register_converter(StateConverter, 'state')


app_name = 'api'


urlpatterns = [

    path('', home, name='home'),