# Path: iprestrict/views.py
# @superuser_required
# def test_rules_page(request):
#     return render_to_response('iprestrict/test_rules.html')
# 
# @superuser_required
# def test_match(request):
#     request_dict = request.GET
#     if request.method == 'POST':
#         request_dict = request.POST
#     url = request_dict['url']
#     ip = request_dict['ip']
# 
#     try:
#         validate_ipv46_address(ip)
#     except ValidationError:
#         return HttpResponse(_test_match_result('Error', msg='Invalid IP address'))
# 
#     matching_rule_id, action = find_matching_rule(url, ip)
#     rules = list_rules(matching_rule_id, url, ip)
# 
#     if matching_rule_id is None:
#         action = 'Allowed'
#         msg = 'No rules matched.'
#     else:
#         msg = 'URL matched Rule highlighted below.'
# 
#     return HttpResponse(_test_match_result(action, msg, rules))
# 
# @superuser_required
# def reload_rules(request):
#     models.ReloadRulesRequest.request_reload()
#     return HttpResponse('ok')
# 
# Path: iprestrict/views.py
# @superuser_required
# def move_rule_up(request, rule_id):
#     rule = models.Rule.objects.get(pk=rule_id)
#     rule.move_up()
#     return HttpResponseRedirect(reverse('admin:iprestrict_rule_changelist'))
# 
# @superuser_required
# def move_rule_down(request, rule_id):
#     rule = models.Rule.objects.get(pk=rule_id)
#     rule.move_down()
#     return HttpResponseRedirect(reverse('admin:iprestrict_rule_changelist'))


from django.conf.urls import url
from .views import test_rules_page, test_match, reload_rules
from .views import move_rule_up, move_rule_down
# -*- coding: utf-8 -*-
from __future__ import unicode_literals


app_name = "iprestrict"
urlpatterns = [
    url(r'^$', test_rules_page),
    url(r'^move_rule_up/(?P<rule_id>\d+)[/]?$', move_rule_up, name='move_rule_up'),
    url(r'^move_rule_down/(?P<rule_id>\d+)[/]?$', move_rule_down, name='move_rule_down'),
    url(r'^reload_rules[/]?$', reload_rules, name='reload_rules'),

# Path: iprestrict/views.py
# @superuser_required
# def test_rules_page(request):
#     return render_to_response('iprestrict/test_rules.html')
# 
# @superuser_required
# def test_match(request):
#     request_dict = request.GET
#     if request.method == 'POST':
#         request_dict = request.POST
#     url = request_dict['url']
#     ip = request_dict['ip']
# 
#     try:
#         validate_ipv46_address(ip)
#     except ValidationError:
#         return HttpResponse(_test_match_result('Error', msg='Invalid IP address'))
# 
#     matching_rule_id, action = find_matching_rule(url, ip)
#     rules = list_rules(matching_rule_id, url, ip)
# 
#     if matching_rule_id is None:
#         action = 'Allowed'
#         msg = 'No rules matched.'
#     else:
#         msg = 'URL matched Rule highlighted below.'
# 
#     return HttpResponse(_test_match_result(action, msg, rules))
# 
# @superuser_required
# def reload_rules(request):
#     models.ReloadRulesRequest.request_reload()
#     return HttpResponse('ok')
# 
# Path: iprestrict/views.py
# @superuser_required
# def move_rule_up(request, rule_id):
#     rule = models.Rule.objects.get(pk=rule_id)
#     rule.move_up()
#     return HttpResponseRedirect(reverse('admin:iprestrict_rule_changelist'))
# 
# @superuser_required
# def move_rule_down(request, rule_id):
#     rule = models.Rule.objects.get(pk=rule_id)
#     rule.move_down()
#     return HttpResponseRedirect(reverse('admin:iprestrict_rule_changelist'))


# Path: iprestrict/urls.py
from django.conf.urls import url
from .views import test_rules_page, test_match, reload_rules
from .views import move_rule_up, move_rule_down

# -*- coding: utf-8 -*-
from __future__ import unicode_literals


app_name = "iprestrict"
urlpatterns = [
    url(r'^$', test_rules_page),
    url(r'^move_rule_up/(?P<rule_id>\d+)[/]?$', move_rule_up, name='move_rule_up'),
    url(r'^move_rule_down/(?P<rule_id>\d+)[/]?$', move_rule_down, name='move_rule_down'),
    url(r'^reload_rules[/]?$', reload_rules, name='reload_rules'),

    url(r'^test_match[/]?$', test_match, name='test_match'),