from django.conf.urls import url, patterns
from .api import AJAX_FUNCTIONS

__author__ = 'jyrkila'

_urls = [url('^checkout.js$', 'checkout_js', name='checkout_js')]
_urls.extend([
    url(func.url, func.name, name=func.view_name)
    for func in AJAX_FUNCTIONS.itervalues()
])

urlpatterns = patterns('kirppu.app.checkout.api', *_urls)

from django.conf import settings
from django.conf.urls import url, patterns
from .api import AJAX_FUNCTIONS

__author__ = 'jyrkila'

if settings.KIRPPU_CHECKOUT_ACTIVE:
    # Only activate API when checkout is active.

    _urls = [url('^checkout.js$', 'checkout_js', name='checkout_js')]
    _urls.extend([
        url(func.url, func.name, name=func.view_name)
        for func in AJAX_FUNCTIONS.itervalues()
    ])

else:
    _urls = []

urlpatterns = patterns('kirppu.app.checkout.api', *_urls)

Fix access to checkout API.
Fix access to checkout API.

Prevent access to checkout API urls when checkout is not activated by
not creating urlpatterns.

+ from django.conf import settings
  from django.conf.urls import url, patterns
  from .api import AJAX_FUNCTIONS
  
  __author__ = 'jyrkila'
  
+ if settings.KIRPPU_CHECKOUT_ACTIVE:
+     # Only activate API when checkout is active.
+ 
- _urls = [url('^checkout.js$', 'checkout_js', name='checkout_js')]
+     _urls = [url('^checkout.js$', 'checkout_js', name='checkout_js')]
- _urls.extend([
+     _urls.extend([
-     url(func.url, func.name, name=func.view_name)
+         url(func.url, func.name, name=func.view_name)
-     for func in AJAX_FUNCTIONS.itervalues()
+         for func in AJAX_FUNCTIONS.itervalues()
- ])
+     ])
+ 
+ else:
+     _urls = []
  
  urlpatterns = patterns('kirppu.app.checkout.api', *_urls)
  
Fix access to checkout API.
## Code Before:
from django.conf.urls import url, patterns
from .api import AJAX_FUNCTIONS

__author__ = 'jyrkila'

_urls = [url('^checkout.js$', 'checkout_js', name='checkout_js')]
_urls.extend([
    url(func.url, func.name, name=func.view_name)
    for func in AJAX_FUNCTIONS.itervalues()
])

urlpatterns = patterns('kirppu.app.checkout.api', *_urls)

## Instruction:
Fix access to checkout API.
## Code After:
from django.conf import settings
from django.conf.urls import url, patterns
from .api import AJAX_FUNCTIONS

__author__ = 'jyrkila'

if settings.KIRPPU_CHECKOUT_ACTIVE:
    # Only activate API when checkout is active.

    _urls = [url('^checkout.js$', 'checkout_js', name='checkout_js')]
    _urls.extend([
        url(func.url, func.name, name=func.view_name)
        for func in AJAX_FUNCTIONS.itervalues()
    ])

else:
    _urls = []

urlpatterns = patterns('kirppu.app.checkout.api', *_urls)
