urls.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3. from django.apps import apps
  4. from django.conf import settings
  5. from django.conf.urls import patterns, include, url
  6. from django.conf.urls.static import static
  7. from django.contrib.staticfiles.urls import staticfiles_urlpatterns
  8. from coin import views
  9. import coin.apps
  10. import autocomplete_light
  11. autocomplete_light.autodiscover()
  12. from django.contrib import admin
  13. admin.autodiscover()
  14. from coin.isp_database.views import isp_json
  15. def apps_urlpatterns():
  16. """ Yields url lists ready to be appended to urlpatterns list
  17. """
  18. for app_config in apps.get_app_configs():
  19. if isinstance(app_config, coin.apps.AppURLs):
  20. for prefix, pats in app_config.exported_urlpatterns:
  21. yield url(
  22. r'^{}/'.format(prefix),
  23. include(pats, namespace=prefix))
  24. urlpatterns = patterns(
  25. '',
  26. url(r'^$', 'coin.members.views.index', name='home'),
  27. url(r'^isp.json$', isp_json),
  28. url(r'^members/', include('coin.members.urls', namespace='members')),
  29. url(r'^billing/', include('coin.billing.urls', namespace='billing')),
  30. url(r'^subscription/', include('coin.offers.urls', namespace='subscription')),
  31. url(r'^hardware-provisioning/', include('hardware_provisioning.urls',
  32. namespace='hardware_provisioning')),
  33. url(r'^admin/', include(admin.site.urls)),
  34. # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
  35. url(r'^feed/(?P<feed_name>.+)', views.feed, name='feed'),
  36. url(r'^autocomplete/', include('autocomplete_light.urls')),
  37. )
  38. urlpatterns += staticfiles_urlpatterns()
  39. urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
  40. # Pluggable apps URLs
  41. urlpatterns += list(apps_urlpatterns())