def handle_gruntserver(self):
     # Set up the staticfiles app to serve files in STATIC_ROOT.
     settings.STATICFILES_FINDERS = (
         "django.contrib.staticfiles.finders.FileSystemFinder",
     )
     settings.STATICFILES_DIRS = (
         settings.STATIC_ROOT,
     )
     settings.STATIC_ROOT = ""
     
     # Add staticfiles handler to urls?
     if self.options["gzip"]:
         urlconf = import_module(settings.ROOT_URLCONF)
         urlconf.urlpatterns = staticfiles_urlpatterns() + urlconf.urlpatterns
     
     # Use gzip middleware to compress staticfiles?
     if self.options["gzip"]:
         if "django.middleware.gzip.GZipMiddleware" not in settings.MIDDLEWARE_CLASSES:
             settings.MIDDLEWARE_CLASSES = (
                 "django.middleware.gzip.GZipMiddleware",
             ) + settings.MIDDLEWARE_CLASSES
     
     # Force runserver to run with the "--nostatic" option so that the
     # middleware gets run for staticfiles requests?
     if self.options["gzip"]:
         self.options["use_static_handler"] = False
     
     # Use compiled JavaScript and CSS in the templates?
     settings.GRUNT_JS = self.options["grunt_js"]
     settings.GRUNT_CSS = self.options["grunt_css"]
Exemple #2
0
def local_serve_urlpatterns():
    re = r"^%s(?P<path>.*)$" % settings.MEDIA_URL.lstrip('/')
    options = {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}

    return patterns('django.views.static',
        url(re, 'serve', options),
    ) + staticfiles_urlpatterns()
 def get_urls():
     from django.conf import settings
     from django.contrib.staticfiles.urls import staticfiles_urlpatterns
     if settings.DEBUG:
         return original() + staticfiles_urlpatterns()
     else:
         return original()
Exemple #4
0
def augment_urlpatterns(urlpatterns):

    urlpatterns += urls.patterns(
        '',
        urls.url(r'^$', RedirectView.as_view(url='/demo', permanent=True)),
        urls.url(
            r'^accounts/login/$',
            'django.contrib.auth.views.login',
            {'template_name': 'otree/login.html'},
            name='login_url',
        ),
        urls.url(
            r'^accounts/logout/$',
            'django.contrib.auth.views.logout',
            {'next_page': 'DemoIndex'},
            name='logout',
        ),
    )

    rest_api_urlpatterns = (
        urls.url(r'^ping/$', Ping.as_view(), name="ping"),
        urls.url(
            r'^sessions/(?P<session_code>[a-z0-9]+)/participants/$',
            SessionParticipantsList.as_view(),
            name="session_participants_list")
    )
    urlpatterns += rest_api_urlpatterns

    urlpatterns += staticfiles_urlpatterns()

    used_names_in_url = set()
    for app_name in settings.INSTALLED_OTREE_APPS:
        models_module = get_models_module(app_name)
        name_in_url = models_module.Constants.name_in_url
        if name_in_url in used_names_in_url:
            msg = (
                "App {} has name_in_url='{}', "
                "which is already used by another app"
            ).format(app_name, name_in_url)
            raise ValueError(msg)

        used_names_in_url.add(name_in_url)
        views_module_name = '{}.views'.format(app_name)
        urlpatterns += url_patterns_from_game_module(
            views_module_name, name_in_url)

    urlpatterns += url_patterns_from_module('otree.views.participant')
    urlpatterns += url_patterns_from_module('otree.views.demo')
    urlpatterns += url_patterns_from_module('otree.views.admin')
    urlpatterns += url_patterns_from_module('otree.views.room')
    urlpatterns += url_patterns_from_module('otree.views.mturk')
    urlpatterns += url_patterns_from_module('otree.views.export')

    urlpatterns += extensions_urlpatterns()
    urlpatterns += extensions_export_urlpatterns()

    return urlpatterns
Exemple #5
0
    def setup_urlconf(self, router):
        # url
        from django.conf.urls import url, include
        from django.contrib.staticfiles.urls import staticfiles_urlpatterns

        urlpatterns = [
            url(r'^', include(router.urls))
        ]
        urlpatterns += staticfiles_urlpatterns()
        return urlpatterns
Exemple #6
0
 def get_urls():
     from django.conf.urls import patterns, include, url
     from django.conf import settings
     from django.contrib.staticfiles.urls import staticfiles_urlpatterns
     if settings.DEBUG:
         return staticfiles_urlpatterns() + patterns('',
             url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {
                 'document_root': settings.MEDIA_ROOT,
             }),
         ) + original()
     else:
         return original()
Exemple #7
0
def debugmode_urlpatterns():
    # Staticfiles url patterns.
    patterns = staticfiles_urlpatterns()
    # User-uploaded media patterns. Used to be arranged by django-staticfiles.
    prefix = settings.MEDIA_URL
    root = settings.MEDIA_ROOT
    if prefix and root:
        patterns += static(prefix, document_root=root)
    else:
        logger.warn("Can't find MEDIA_URL (%s) and/or MEDIA_ROOT (%s).",
                    prefix, root)
    return patterns
Exemple #8
0
 def get_urls():
     from django.conf.urls import url
     from django.conf import settings
     from django.contrib.staticfiles.urls import staticfiles_urlpatterns
     from django.views.static import serve
     if settings.DEBUG:
         return staticfiles_urlpatterns() + [
             url(r'^media/(?P<path>.*)$', serve, {
                 'document_root': settings.MEDIA_ROOT,
             }),
         ] + original()
     else:
         return original()
Exemple #9
0
def augment_urlpatterns(urlpatterns):

    urlpatterns += patterns('',
                            url(r'^$', RedirectView.as_view(url='/admin')),
                            url(r'^admin/', include(admin.site.urls)),
                            url(r'^exports/', include('data_exports.urls', namespace='data_exports')),
                            )
    urlpatterns += staticfiles_urlpatterns()
    for app_name in settings.INSTALLED_PTREE_APPS:
        views_module_name = '{}.views'.format(app_name)
        urlpatterns += url_patterns_from_module(views_module_name)
    urlpatterns += url_patterns_from_module('ptree.views.concrete')

    return urlpatterns
Exemple #10
0
def get_url_patterns():
    res = _init_url_patterns()
    for appname in settings.INSTALLED_APPS:
        appmodule = import_module(appname)
        is_lucterios_ext = False
        for _, modname, ispkg in pkgutil.iter_modules(appmodule.__path__):
            if (modname[:5] == 'views') and not ispkg:
                view = import_module(appname + '.' + modname)
                for obj in inspect.getmembers(view):
                    try:
                        if obj[1].url_text != '':
                            if inspect.isclass(obj[1]):
                                is_lucterios_ext = True
                                as_view_meth = getattr(obj[1], "as_view")
                                res.append(
                                    url(r"^%s$" % obj[1].url_text, as_view_meth()))
                    except AttributeError:
                        pass
            elif settings.APPLIS_MODULE == appmodule:
                is_lucterios_ext = True
        if not is_lucterios_ext:
            try:
                patterns = getattr(
                    import_module('%s.urls' % appname), 'urlpatterns', None)
                if isinstance(patterns, (list, tuple)):
                    for url_pattern in patterns:
                        module_items = appname.split('.')
                        if module_items[0] == 'django':
                            res.append(url_pattern)
                        else:
                            res.append(url(r"^%s/%s" % (module_items[-1], url_pattern._regex[1:]),
                                           url_pattern.callback,
                                           url_pattern.default_args, url_pattern.name))
            except ImportError:
                pass
    try:
        from django.contrib.admin.sites import site
        res.append(url(r'^accounts/login/$', site.login))
    except ImportError:
        pass
    res.extend(staticfiles_urlpatterns())
    logging.getLogger('lucterios.core.init').debug(
        "Urls:" + '\n'.join(str(res_item) for res_item in res))
    return res
Exemple #11
0
    def _configure_django(self, **kw):
        import inspect, os

        self.APP_DIR = os.path.dirname(os.path.realpath(inspect.stack()[2][1]))
        if "regexers" in kw:
            self.update_regexers(kw.pop("regexers"))
        if "no_atexit" in kw:
            self.no_atexit = kw.pop("no_atexit")
        from django.conf import settings

        self.settings = settings
        if not kw.get("dont_configure", False):
            kw["ROOT_URLCONF"] = "importd.d"
            if "TEMPLATE_DIRS" not in kw:
                kw["TEMPLATE_DIRS"] = (self.dotslash("templates"),)
            if "STATIC_URL" not in kw:
                kw["STATIC_URL"] = "static/"
            if "STATICFILES_DIRS" not in kw:
                kw["STATICFILES_DIRS"] = (self.dotslash("static"),)
            if "DATABASES" not in kw:
                kw["DATABASES"] = {
                    "default": {"ENGINE": "django.db.backends.sqlite3", "NAME": self.dotslash("db.sqlite")}
                }
            if "DEBUG" not in kw:
                kw["DEBUG"] = True
            settings.configure(**kw)
            # import .views and .forms for each installed app
            for app in settings.INSTALLED_APPS:
                try:
                    __import__("%s.views" % app)
                except ImportError, e:
                    pass
                try:
                    __import__("%s.forms" % app)
                except ImportError:
                    pass
                try:
                    __import__("%s.signals" % app)
                except ImportError:
                    pass
            from django.contrib.staticfiles.urls import staticfiles_urlpatterns

            self.urlpatterns += staticfiles_urlpatterns()
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    # Examples:
    # url(r'^robocon_iitm/', include('robocon_iitm.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    url(r'^admin/', include(admin.site.urls)),
    
    url(r'^$', 'home.views.home', name='home'),
    url(r'^blur$', 'home.views.blur', name='blur'),
    url(r'^template$', 'home.views.template', name='template'),
    
    url(r'^blog/new$', 'blog.views.newblog', name='newblog'),
    url(r'^blog$', 'blog.views.blog', name='blog'),
    url(r'^blog/(\d+)$', 'blog.views.blogpost', name='blogpost'),

    (r'^comments', include('django.contrib.comments.urls')),

    (r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), # for media urls
                 
    url(dajaxice_config.dajaxice_url, include('misc.dajaxice.urls')), # For dajaxice to function corrently
)

urlpatterns += staticfiles_urlpatterns() # To enable serving static files
Exemple #13
0
from django.conf import settings
from django.conf.urls import patterns, include, url
from django.conf.urls.static import static
from django.contrib.staticfiles.urls import staticfiles_urlpatterns

from django.views.generic.simple import direct_to_template

from django.contrib import admin
admin.autodiscover()


urlpatterns = patterns("",
    url(r"^$", direct_to_template, {"template": "homepage.html"}, name="home"),
    url(r"^admin/", include(admin.site.urls)),
    url(r"^account/", include("account.urls")),

    url(r'^forum/', include('forum.urls')),
)

urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += staticfiles_urlpatterns()    # to link static files path in Apache
Exemple #14
0
from django.contrib import admin
from django.conf.urls import url
from . import views
from django.contrib.staticfiles.urls import staticfiles_urlpatterns

urlpatterns = [
    url(r'', views.render_page),
    url(r'^mydata$', views.google),
]

urlpatterns += staticfiles_urlpatterns()
Exemple #15
0
from django.conf.urls import patterns, include, url
from django.contrib import admin
from django.contrib.auth.decorators import login_required
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.views.generic import TemplateView
from tastypie.api import Api

from apps.api.res import BuildingResource, EdgeResource, NodeResource, RouteResource

v1_api = Api(api_name='v1')
v1_api.register(BuildingResource())
v1_api.register(EdgeResource());
v1_api.register(NodeResource());
v1_api.register(RouteResource())

admin.autodiscover()

urlpatterns = patterns('',
    url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^api/', include(v1_api.urls)),
    url(r'^accounts/login/', 'apps.account.views.login_view'),
    url(r'^accounts/logout/', 'apps.account.views.logout_view'),
    url(r'^visualizations/', TemplateView.as_view(template_name='visualizations.html')),
    url(r'^contact/', TemplateView.as_view(template_name='contact.html')),
    url(r'^edit/', login_required(TemplateView.as_view(template_name='edit.html'))),
    url(r'^$', TemplateView.as_view(template_name='home.html')),
) + staticfiles_urlpatterns()
Exemple #16
0

urlpatterns = patterns('',
    url(r'^django-admin/', include(admin.site.urls)),

    url(r'^admin/', include(wagtailadmin_urls)),
    url(r'^search/', include(wagtailsearch_frontend_urls)),

    url(r'^documents/', include(wagtaildocs_urls)),

    url(r'^test404/$', TemplateView.as_view(template_name="404.html")),
    url(r'^test500/$', TemplateView.as_view(template_name="500.html")),

    url(r'', include(torchbox_urls)),
    # For anything not caught by a more specific rule above, hand over to
    # Wagtail's serving mechanism
    url(r'', include(wagtail_urls)),
)


if settings.DEBUG:
    from django.contrib.staticfiles.urls import staticfiles_urlpatterns

    urlpatterns += staticfiles_urlpatterns()  # tell gunicorn where static files are in dev mode
    urlpatterns += static(settings.MEDIA_URL + 'images/', document_root=os.path.join(settings.MEDIA_ROOT, 'images'))
    urlpatterns += patterns('',
        (r'^favicon\.ico$', RedirectView.as_view(url=settings.STATIC_URL + 'torchbox.com/images/favicon.ico'))
    )

handler404 = 'torchbox.views.error404'
Exemple #17
0
    url(r'^plantoftheday/', include('gobotany.plantoftheday.urls')),
    url(r'^plantshare/', include('gobotany.plantshare.urls')),
    url(r'^tinymce/', include('tinymce.urls')),
    url(r'^', include('gobotany.search.urls')),
    url(r'^', include('gobotany.site.urls')),
    url(r'^', include('gobotany.taxa.urls')),
    url(r'^', include('gobotany.simplekey.urls')),
])

# Serve uploaded media files as static files in development
if settings.DEBUG:
    urlpatterns.extend([
        url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {
            'document_root': settings.MEDIA_ROOT,
        }),
    ])
# For now, always have staticfiles turned on, even in production.

class FakeSettings():
    DEBUG = True

def fix_staticfiles():
    import django.contrib.staticfiles.views
    import django.conf.urls.static

    django.conf.urls.static.settings = FakeSettings()
    django.contrib.staticfiles.views.settings = FakeSettings()

fix_staticfiles()
urlpatterns.extend(staticfiles_urlpatterns())
from django.conf.urls import patterns, include, url
from django.contrib import admin
urlpatterns = patterns('',
	url(r'^admin/', 					include(admin.site.urls)),
	url(r'^users/', 					'api.views.getUsers'),
	url(r'^tasks/', 					'api.views.getTasks'),
	url(r'^events/', 					'api.views.getEvents'),
	url(r'^(?P<username>\w+)/profile/',	'api.views.getUser'),
	url(r'^(?P<username>\w+)/tasks/', 	'api.views.getUserTasks'),
	url(r'^(?P<username>\w+)/events/',	'api.views.getUserEvents'),
	
	url(r'^add/user/', 					'api.views.addUser'),
	url(r'^add/task/', 					'api.views.addTask'),
	url(r'^add/event/', 				'api.views.addEvent'),
	url(r'^challenge/', 				'api.views.challenge'),
	url(r'^accept/', 					'api.views.decline'),
	url(r'^decline/', 					'api.views.decline'),
	url(r'^like/', 						'api.views.like'),
	url(r'^join/', 						'api.views.join'),
)
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns += staticfiles_urlpatterns()
Exemple #19
0
from django.conf import settings
from django.views.defaults import page_not_found


from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from wheelcms_axle.urls import handler500, handler404

from django.views.generic import RedirectView

admin.autodiscover()

## basepatterns are usually not localized,
## wheelpatterns are.

basepatterns = staticfiles_urlpatterns()
wheelpatterns = patterns('')

## or import static_urls; urlpatterns = static_urls.urlpatterns

if not settings.ALLOW_SIGNUP:
    wheelpatterns += patterns('',
        ('^accounts/signup', page_not_found),
    )

basepatterns += patterns('',
    (r'^admin/', include(admin.site.urls)),
    (r'^favicon.ico$', RedirectView.as_view(url='/static/images/favicon.ico')),
    (r'^tinymce/', include('tinymce.urls')),
)
wheelpatterns += patterns('',
from django.conf.urls.defaults import patterns, url, include
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns

admin.autodiscover()

urlpatterns = patterns(
    "",
    (r"^testapp/", include("testapp.urls")),
    (r"^admin/doc/", include("django.contrib.admindocs.urls")),
    (r"^admin/", include(admin.site.urls)),
)

urlpatterns += staticfiles_urlpatterns()  # only when settings.DEBUG == True
Exemple #21
0
from django.conf import settings
from django.conf.urls.static import static
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.views.generic.base import RedirectView
import debug_toolbar.urls

autodiscover(admin_site)

# Override error pages
handler404 = 'esp.web.util.main.error404'
handler500 = 'esp.web.util.main.error500'

# Static media
urlpatterns = static(
    settings.MEDIA_URL,
    document_root=settings.MEDIA_ROOT) + staticfiles_urlpatterns()

# Admin stuff
urlpatterns += patterns(
    '',
    (r'^admin/doc/', include('django.contrib.admindocs.urls')),
    (r'^admin/ajax_qsd/?', 'esp.qsd.views.ajax_qsd'),
    (r'^admin/ajax_autocomplete/?', 'esp.db.views.ajax_autocomplete'),
    (r'^admin/', include(admin_site.urls)),
    (
        r'^accounts/login/$',
        'esp.users.views.login_checked',
    ),
    #(r'^learn/Junction/2007_Spring/catalog/?$',RedirectView.as_view(url='/learn/Junction/2007_Summer/catalog/')),
    (r'^(?P<subsection>(learn|teach|program|help|manage|onsite))/?$',
     RedirectView.as_view(url='/%(subsection)s/index.html')),
Exemple #22
0
# mysite/urls.py
from django.conf.urls import include
from django.urls import path
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.conf.urls.static import static
from django.conf import settings
from django.contrib import admin
from django.conf.urls.static import static
urlpatterns = [
    path('chat/', include('chat.urls')),
    path('admin/', admin.site.urls),
]
urlpatterns += staticfiles_urlpatterns()  # for js/css/sass files

urlpatterns += static(settings.MEDIA_URL,
                      document_root=settings.MEDIA_ROOT)  #images
Exemple #23
0
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import include, path
from django.conf import settings
from django.conf.urls.static import static
from django.contrib.staticfiles.urls import staticfiles_urlpatterns

urlpatterns = [
    path('', include(
        'mt.urls')),  #TODO: This redirects to simple/ can we do it directly?
    path('simple/', include('mtsimple.urls')),
    path('para/', include('mtpara.urls')),
    # path('gpt/', include('gpt.urls')),
    path('admin/', admin.site.urls),
    path('accounts/', include('django.contrib.auth.urls')),

    # REST FRAMEWORK URLS
    path('api/simple/', include('mtsimple.api.urls')),
] + static(settings.STATIC_URL,
           document_root=settings.STATIC_ROOT) + staticfiles_urlpatterns()
Exemple #24
0
    path('services/',       services,           name='services_url'),
    path('building/',       building,           name='building_url'),
    path('design/',         design,             name='design_url'),
    path('feedback/',       make_Contact.as_view(), name='feedback_url'), 
    path('done_projects/',  done_projects,      name='done_projects_url'),
    path('houses/',         houses,             name='houses_url'),
    path('complexes/',      complexes,          name='complexes_url'),
    path('hotels/',         hotels,             name='hotels_url'),
    path('ets/',            ets,                name='ets_url'),
    path('expertise/',      expertise,          name='expertise_url'),
    path('create/',         project_create.as_view(),     name='create_project_url'),
    path(r'<str:type>/filter/',    filtrate,           name='filtrate_url'),
    path(r'<str:type>/<str:article>/',   project_page,    name='project_page_url'),
    path(r'<str:type>/<str:article>/update/',   project_update.as_view(), name='update_project_url'),
    path(r'<str:type>/<str:article>/delete/',   project_delete.as_view(), name='delete_project_url'),
    
]  

if settings.DEBUG:
    urlpatterns += staticfiles_urlpatterns() + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
    urlpatterns += staticfiles_urlpatterns() + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

    #urlpatterns = [
    #    url(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
    #    url(r'', include('django.contrib.staticfiles.urls')),
    #
    #    # --- error pages ---
    #    url(r'^403$', handler403),
    #    url(r'^404$', handler404),
    #    url(r'^500$', handler500),
    #] + urlpatterns
Exemple #25
0
    ('^render/?', include('graphite.render.urls')),
    ('^composer/?', include('graphite.composer.urls')),
    ('^metrics/?', include('graphite.metrics.urls')),
    ('^browser/?', include('graphite.browser.urls')),
    ('^account/', include('graphite.account.urls')),
    ('^dashboard/?', include('graphite.dashboard.urls')),
    ('^whitelist/?', include('graphite.whitelist.urls')),
    ('^graphlot/', include('graphite.graphlot.urls')),
    ('^version/', include('graphite.version.urls')),
    ('^events/', include('graphite.events.urls')),
    url('^s/(?P<path>.*)',
        'graphite.url_shortener.views.shorten',
        name='shorten'),
    url('^S/(?P<link_id>[a-zA-Z0-9]+)/?$',
        'graphite.url_shortener.views.follow',
        name='follow'),
    url('^$', 'graphite.browser.views.browser', name='browser'),
)
graphite_urls += staticfiles_urlpatterns()

url_prefix = ''
if settings.URL_PREFIX.strip('/'):
    url_prefix = '{0}/'.format(settings.URL_PREFIX.strip('/'))

urlpatterns = patterns(
    '',
    (r'^{0}'.format(url_prefix), include(graphite_urls)),
)

handler500 = 'graphite.views.server_error'
Exemple #26
0
    # url(r'^blog/', include('blog.urls')),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^i18n/', include('django.conf.urls.i18n')),
    url(r'^$', 'share_ads.views.home_page', name='home'),
    url(r'^advertiser/', include('advertiser.urls')),
    url(r'^publisher/', include('publisher.urls')),
    url(r'^payment_system/', include('payment_system.urls')),
    url(r'^accounts/login/$', 'django.contrib.auth.views.login',
        {'template_name': 'login.html'}),
    url(r'^accounts/logout/$', 'django.contrib.auth.views.logout',
        {'next_page': '/'}),
    url(r'^accounts/password/$', 'django.contrib.auth.views.password_change'),
    url(r'^accounts/change-password-done/$',
        'django.contrib.auth.views.password_change_done'),
    url(r'', include('registration.backends.default.urls')),
    url(r'', include('django.contrib.auth.urls')),
    url(r'^user_activation/(.+)$', 'share_ads.views.user_activation'),
    url(r'^terms/$', 'share_ads.views.campaign_pool'),
    url(r'^campaign_pool/$', 'share_ads.views.campaign_pool'),
    url(r'^public_advertiser_profile/(.+)$',
        'share_ads.views.public_advertiser_profile'),
    url(r'^campaign_detail/(.+)$', 'share_ads.views.campaign_detail'),
    url(r'^joined_publisher_to_a_campaign/(.+)$',
        'share_ads.views.joined_publisher_to_a_campaign'),
    url(r'^contact_us/$', 'share_ads.views.contact_us'),
    url(r'^sorry/$', 'share_ads.views.sorry'),
    url(r'^forgotten_password/$', 'share_ads.views.forgotten_password'),
    url(r'^facebook/', include('django_facebook.urls')),
) + staticfiles_urlpatterns() + static(settings.MEDIA_URL,
                                       document_root=settings.MEDIA_ROOT)
Exemple #27
0
admin.autodiscover()

urlpatterns = patterns('',

    url('^$',
        direct_to_template, #function to call
        {'template': 'home.html'}, #args for direct_to_template
        name="home" #hame for url template
    ),
    #home page 

    url('^about/$',
        TemplateView.as_view,
        {'template_name': 'about.html'},
        "about"
    ),
    #static page, simple generic view

    url(r'^polls/', include('polls.urls')),
    #mounts all the admin urls defined in admin.site.urls on top of admin/

    url(r'^admin/', include(admin.site.urls)),

    #<userena
    url(r'^accounts/', include('userena.urls')),
    #</userena
)

urlpatterns += staticfiles_urlpatterns() #to serve static files
Exemple #28
0
from django.conf.urls import *  # NOQA
from django.conf.urls.i18n import i18n_patterns
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.contrib import admin
from django.conf import settings
from cms.sitemaps import CMSSitemap

admin.autodiscover()

urlpatterns = i18n_patterns('',
                            url(r'^admin/', include(admin.site.urls)),  # NOQA
                            url(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap',
                                {'sitemaps': {'cmspages': CMSSitemap}}),
                            url(r'^taggit_autosuggest/', include('taggit_autosuggest.urls')),
                            url(r'^', include('cms.urls')),
                            )

# This is only needed when using runserver.
if settings.DEBUG:
    urlpatterns = patterns('',
                           url(r'^media/(?P<path>.*)$', 'django.views.static.serve',  # NOQA
                               {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
                           ) + staticfiles_urlpatterns() + urlpatterns  # NOQA
Exemple #29
0
        auth_views.password_reset_complete,
        name='password_reset_complete'),
    url(r'^accounts/password/reset/confirm/(?P<uidb64>[0-9A-Za-z]+)-'
        '(?P<token>.+)/$',
        auth_views.password_reset_confirm,
        name='password_reset_confirm'),

    url(r'^accounts/username/change/$', username_change,
        name='accounts_edit_username'),

    url(r'^accounts/username/change/done/$',
        TemplateView.as_view(template_name='accounts/edit_username_done.html')
        ),
    url('', include('social_django.urls', namespace='social')),
    url(r'^login_error/', login_error),
    url(r'^new_users/', new_social_user),
    url(r'^accounts/', include('registration.backends.simple.urls')),
    url(r'^listmanager/', listmanager),
    url(r'^supporter/', TemplateView.as_view(template_name='support.html')),
    url(r'^wordwalls/', include('wordwalls.urls')),
    url(r'^flashcards/', include('whitleyCards.urls')),
    url(r'^cards/', include('flashcards.urls')),
    url(r'^base/', include('base.urls')),
    url(r'^js_errors/', js_error),
    url(r'^500tester/', test_500),
    url(r'^healthz/', healthz)
]

urlpatterns += staticfiles_urlpatterns()    # for static serving, only works
                                            # if DEBUG is true
Exemple #30
0
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url, include
from django.contrib import admin
from . import views
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.conf.urls.static import static  # Media folder setup
from django.conf import settings  # Media folder setup
from articles import views as article_views  # Can't reuse "import views" because we already have "views" above.

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^accounts/', include('accounts.urls')),
    url(r'^articles/', include('articles.urls')),
    url(r'^about/$', views.about),
    # url(r'^$', views.homepage), # This was commented because we didn't want the ugly homepage we did at the beginning of the tutorial.
    url(r'^$', article_views.article_list, name="home"),
]

urlpatterns += staticfiles_urlpatterns()  # This was for static files setup
urlpatterns += static(
    settings.MEDIA_URL,
    document_root=settings.MEDIA_ROOT)  # This was for media files setup
Exemple #31
0
    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
    # Uncomment the next line to enable the admin:
    url(r"^admin/", include(admin.site.urls)),
    (r"^$", "wet.main.views.index"),
    (r"^weterynarze/$", "wet.main.views.vets"),
    (r"^weterynarze/(?P<vet_id>\d+)/$", "wet.main.views.vet_details"),
    (r"^klienci/(?P<client_id>\d+)/$", "wet.main.views.client_details"),
    (r"^zwierzaki/(?P<animal_id>\d+)/$", "wet.main.views.animal_details"),
    (
        r"^login/$",
        login,
        {
            "template_name": "main/login.html",
            "extra_context": {"STATIC_URL": settings.STATIC_URL, "date": getDate(), "logged": txt},
        },
    ),
    (
        r"^logout/$",
        logout,
        {
            "template_name": "main/logout.html",
            "extra_context": {"STATIC_URL": settings.STATIC_URL, "date": getDate(), "logged": txt},
        },
    ),
    (r"^nowy_klient/$", "wet.main.views.new_client"),
    (r"^nowy_pupil/$", "wet.main.views.new_animal"),
)

urlpatterns += staticfiles_urlpatterns()  # development
Exemple #32
0
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Add an import:  from blog import urls as blog_urls
    2. Add a URL to urlpatterns:  url(r'^blog/', include(blog_urls))
"""
from django.conf.urls import include, url
from django.contrib import admin
from django.conf import settings
from django.conf.urls.static import static
from django.contrib.staticfiles.urls import staticfiles_urlpatterns

from interface import views

urlpatterns = [
    url(r"^admin/", include(admin.site.urls)),
    url(r"^xml/", views.xml, name="xml"),
    url(r"^thanks/", views.thanks, name="thanks"),
] + static(
    settings.STATIC_URL, document_root=settings.STATIC_ROOT
)  # modify in development

urlpatterns += staticfiles_urlpatterns()  # and that

# todo serve the goddam static files
Exemple #33
0
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url, include, patterns
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.views.generic.base import TemplateView

from branch_office.urls import router as branch_office_router

urlpatterns = patterns(
    '',
    url(r'^admin/', admin.site.urls),
    url(r'^api/', include(branch_office_router.urls)),
    url(
        r'^api-auth/',
        include('rest_framework.urls', namespace='rest_framework')
    ),
    url(
        r'^',
        TemplateView.as_view(template_name='home.html'),
        name='index'
    ),

)

urlpatterns = staticfiles_urlpatterns() + urlpatterns
Exemple #34
0
    include,
    patterns,
    url,
    )
from django.contrib.staticfiles.urls import staticfiles_urlpatterns


urlpatterns = patterns(
    '',
    url(r'^', include('maasserver.urls')),
    url(r'^metadata/', include('metadataserver.urls')),
)

if settings.STATIC_LOCAL_SERVE:
    urlpatterns += patterns(
        '',
        (r'^media/(?P<path>.*)$', 'django.views.static.serve',
         {'document_root': settings.MEDIA_ROOT}),
    )

    urlpatterns += staticfiles_urlpatterns(settings.STATIC_URL_PATTERN)

if settings.DEBUG:
    from django.contrib import admin
    admin.autodiscover()

    urlpatterns += patterns(
        '',
        (r'^admin/', include(admin.site.urls)),
    )
Exemple #35
0
    def _configure_django(self, **kw):
        """Auto-Configure Django using arguments."""
        from django.conf import settings, global_settings
        self.settings = settings
        if settings.configured:
            return

        self.APP_DIR, app_filename = os.path.split(
            os.path.realpath(inspect.stack()[2][1])
        )

        DEBUG = kw.get("DEBUG", False)
        ENVDIR = kw.get("ENVDIR", env("ENVDIR", ""))
        if ENVDIR:
            envdir.open(ENVDIR)
            if env("PYTHONPATH"):
                sys.path.extend(env("PYTHONPATH").split(os.pathsep))

        md = {}
        dp = {}

        for k, v in kw.items():
            if isinstance(v, E):
                md[k] = v.value
                setattr(global_esettings, k, v.value)
            if isinstance(v, DSetting):
                dp[k] = v

        for k, v in md.items():
            kw[k] = v

        for k, v in dp.items():
            if DEBUG:
                if v.dvalue is not NotSet:
                    kw[k] = v.dvalue
            else:
                if v.pvalue is not NotSet:
                    kw[k] = v.pvalue

        del md
        del dp

        def do_dp(key):
            if key not in kw:
                return
            old = kw[key]
            kw[key] = []
            for value in old:
                if DEBUG:
                    if value.startswith("prod:"):
                        continue
                    kw[key].append(value.replace("debug:", ""))
                else:
                    if value.startswith("debug:"):
                        continue
                    kw[key].append(value.replace("prod:", ""))

        do_dp("MIDDLEWARE_CLASSES")
        do_dp("INSTALLED_APPS")
        do_dp("TEMPLATE_CONTEXT_PROCESSORS")

        if "debug" in kw:
            db = kw.pop("debug")
            if DEBUG:
                kw.update(db)

        if "regexers" in kw:
            self.update_regexers(kw.pop("regexers"))

        self.mounts = kw.pop("mounts", {})

        if not kw.get("dont_configure", False):
            kw["ROOT_URLCONF"] = kw.get("ROOT_URLCONF", "importd.urlconf")
            if "TEMPLATE_DIRS" not in kw:
                kw["TEMPLATE_DIRS"] = (self.dotslash("templates"), )
            if "STATIC_URL" not in kw:
                kw["STATIC_URL"] = "/static/"
            if "STATIC_ROOT" not in kw:
                kw["STATIC_ROOT"] = self.dotslash("staticfiles")
            if "STATICFILES_DIRS" not in kw:
                kw["STATICFILES_DIRS"] = [self.dotslash("static")]
            if "MEDIA_URL" not in kw:
                kw["MEDIA_URL"] = "/static/media/"
            if "lr" in kw:
                self.lr = kw.pop("lr")
            if "db" in kw:
                if isinstance(kw["db"], basestring):
                    kw["DATABASES"] = {
                        "default": dj_database_url.parse(kw.pop("db"))
                    }
                else:
                    db = kw.pop("db")
                    default = dj_database_url.parse(db[0])
                    default.update(db[1])
                    kw["DATABASES"] = dict(default=default)
            if "DATABASES" not in kw:
                kw["DATABASES"] = {
                    "default": {
                        'ENGINE': "django.db.backends.sqlite3",
                        'NAME': self.dotslash("db.sqlite")
                    }
                }

            self.smart_return = False
            if kw.pop("SMART_RETURN", True):
                self.smart_return = True
                if "MIDDLEWARE_CLASSES" not in kw:
                    kw["MIDDLEWARE_CLASSES"] = (
                        global_settings.MIDDLEWARE_CLASSES
                    )
                kw["MIDDLEWARE_CLASSES"] = list(kw["MIDDLEWARE_CLASSES"])
                kw["MIDDLEWARE_CLASSES"].append(
                    "importd.SmartReturnMiddleware"
                )

            installed = list(kw.setdefault("INSTALLED_APPS", []))

            admin_url = kw.pop("admin", "^admin/")

            if admin_url:
                if "django.contrib.auth" not in installed:
                    installed.append("django.contrib.auth")
                if "django.contrib.contenttypes" not in installed:
                    installed.append("django.contrib.contenttypes")
                if "django.contrib.auth" not in installed:
                    installed.append("django.contrib.auth")
                if "django.contrib.messages" not in installed:
                    installed.append("django.contrib.messages")
                if "django.contrib.sessions" not in installed:
                    installed.append("django.contrib.sessions")
                    # check session middleware installed
                    # https://docs.djangoproject.com/en/1.7/topics/http/sessions/#enabling-sessions
                    last_position = len(kw["MIDDLEWARE_CLASSES"])
                    kw["MIDDLEWARE_CLASSES"] = list(kw["MIDDLEWARE_CLASSES"])
                    kw["MIDDLEWARE_CLASSES"].insert(
                        last_position,
                        "django.contrib.sessions.middleware.SessionMiddleware"
                    )
                if "django.contrib.admin" not in installed:
                    installed.append("django.contrib.admin")
                    kw["MIDDLEWARE_CLASSES"].append(
                        "django.contrib.auth.middleware"
                        ".AuthenticationMiddleware"
                    )
                if "django.contrib.humanize" not in installed:
                    installed.append("django.contrib.humanize")
                if "django.contrib.staticfiles" not in installed:
                    installed.append("django.contrib.staticfiles")
                if "debug_toolbar" not in installed and debug_toolbar:
                    installed.append("debug_toolbar")
                    if 'INTERNAL_IPS' not in kw:
                        kw['INTERNAL_IPS'] = ('127.0.0.1', '0.0.0.0')
                    kw['MIDDLEWARE_CLASSES'].insert(
                        1,
                        'debug_toolbar.middleware.DebugToolbarMiddleware')
                    kw['DEBUG_TOOLBAR_PANELS'] = (
                        'debug_toolbar.panels.versions.VersionsPanel',
                        'debug_toolbar.panels.timer.TimerPanel',
                        'debug_toolbar.panels.settings.SettingsPanel',
                        'debug_toolbar.panels.headers.HeadersPanel',
                        'debug_toolbar.panels.request.RequestPanel',
                        'debug_toolbar.panels.sql.SQLPanel',
                        'debug_toolbar.panels.staticfiles.StaticFilesPanel',
                        'debug_toolbar.panels.templates.TemplatesPanel',
                        'debug_toolbar.panels.cache.CachePanel',
                        'debug_toolbar.panels.signals.SignalsPanel',
                        'debug_toolbar.panels.logging.LoggingPanel',
                        'debug_toolbar.panels.redirects.RedirectsPanel',
                    )
                    # This one gives 500 if its Enabled without previous syncdb
                    # 'debug_toolbar.panels.request_vars.RequestVarsDebugPanel',

            if django_extensions and werkzeug:
                installed.append('django_extensions')

            # django-jinja 1.0.4 support
            if DJANGO_JINJA:
                installed.append("django_jinja")
                kw['TEMPLATE_LOADERS'] = list(kw.get('TEMPLATE_LOADERS', []))
                kw['TEMPLATE_LOADERS'] += (
                    'django_jinja.loaders.AppLoader',
                    'django_jinja.loaders.FileSystemLoader',
                )
            # coffin 0.3.8 support
            if COFFIN:
                installed.append('coffin')
                kw['TEMPLATE_LOADERS'] = list(kw.get('TEMPLATE_LOADERS', []))
                kw['TEMPLATE_LOADERS'] += (
                    'coffin.contrib.loader.AppLoader',
                    'coffin.contrib.loader.FileSystemLoader',
                )

            kw['INSTALLED_APPS'] = installed

            if "DEBUG" not in kw:
                kw["DEBUG"] = kw["TEMPLATE_DEBUG"] = True
            if "APP_DIR" not in kw:
                kw["APP_DIR"] = self.APP_DIR
            if "SECRET_KEY" not in kw:
                kw["SECRET_KEY"] = self.get_secret_key()
            # admins and managers
            if "ADMINS" not in kw:
                kw["ADMINS"] = kw["MANAGERS"] = ((getuser(), ""), )
            autoimport = kw.pop("autoimport", True)

            kw["SETTINGS_MODULE"] = kw.get("SETTINGS_MODULE", "importd")

            # self._fix_coffin_pre()
            settings.configure(**kw)
            if hasattr(django, "setup"):
                django.setup()

            self._import_django()
            # self._fix_coffin_post()

            from django.contrib.staticfiles.urls import staticfiles_urlpatterns
            urlpatterns = self.get_urlpatterns()
            urlpatterns += staticfiles_urlpatterns()

            if autoimport:
                # django depends on INSTALLED_APPS's model
                for app in settings.INSTALLED_APPS:
                    self._import_app_module("{}.admin", app)
                    self._import_app_module("{}.models", app)

            if admin_url:
                from django.contrib import admin
                try:
                    from django.conf.urls import include
                except ImportError:
                    from django.conf.urls.defaults import include  # lint:ok
                admin.autodiscover()
                self.add_view(admin_url, include(admin.site.urls))

            if autoimport:
                # import .views and .forms for each installed app
                for app in settings.INSTALLED_APPS:
                    self._import_app_module("{}.forms", app)
                    self._import_app_module("{}.views", app)
                    self._import_app_module("{}.signals", app)

        # import blueprints from config
        self.blueprints = kw.pop("blueprints", {})
        for namespace, meta in self.blueprints.items():
            if isinstance(meta, basestring):
                meta = {"blueprint": meta}

            mod_path, bp_name = meta["blueprint"].rsplit(".", 1)
            mod = importlib.import_module(mod_path)
            bp = getattr(mod, bp_name)

            self.register_blueprint(
                bp, url_prefix=meta.get("url_prefix", namespace + "/"),
                namespace=namespace, app_name=meta.get("app_name", ""))

        self._configured = True
Exemple #36
0
from django.conf import settings
from django.conf.urls import patterns, include, url
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.contrib import admin
from django.views.generic.base import RedirectView

from . import views


urlpatterns = [
    url(r'^/?$', views.CrontabView.as_view(), name='home'),
    url(r'^crontab/new/?$', views.CreateCrontabView.as_view(), name='job_create'),
    url(r'^crontab/(?P<pk>\d+)/edit/?$', views.UpdateCrontabView.as_view(), name='job_update'),
    url(r'^crontab/(?P<pk>\d+)/delete/?$', views.DeleteCrontabView.as_view(), name='job_delete'),
    url(r'^accounts/login/?$', 'django.contrib.auth.views.login', name='login'),
    url(r'^accounts/logout/?$', 'django.contrib.auth.views.logout_then_login', name='logout'),
    url(r'^admin/?', include(admin.site.urls)),
]

urlpatterns += staticfiles_urlpatterns(prefix="/static/")

#handler500 = "djcron.base.api.views.api_server_error"
Exemple #37
0
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.conf import settings
from django.conf.urls.defaults import patterns, include, url
from django.conf.urls.static import static
from django.contrib import admin
from django.views.generic import TemplateView


admin.autodiscover()


urlpatterns = patterns('',
    url(r'^$', TemplateView.as_view(template_name='homepage.html'), name='home'),
    url(r'^realworldlike/', include('realworldlike.urls')),
    url(r'^admin/', include(admin.site.urls)),
)

urlpatterns += staticfiles_urlpatterns() + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Exemple #38
0
admin.autodiscover()

urlpatterns = [
    path('sitemap.xml', sitemap, {'sitemaps': {
        'cmspages': CMSSitemap
    }}),
    path(
        "robots.txt",
        TemplateView.as_view(template_name="robots.txt",
                             content_type="text/plain")),
    path('login', auth_views.LoginView.as_view(), name='login'),
    path('logout', views.logout_user, name='logout'),
]

urlpatterns += (  #i18n_patterns(
    url(r'^admin/', admin.site.urls),  # NOQA
    url(r'^', include('cms.urls')),
    path('forms/', include('core_forms.urls', namespace='forms')),
    path('app/', include('core_app.urls', namespace='app')),
)

# This is only needed when using runserver.
if settings.DEBUG:
    urlpatterns = [
        url(r'^media/(?P<path>.*)$', serve, {
            'document_root': settings.MEDIA_ROOT,
            'show_indexes': True
        }),
    ] + staticfiles_urlpatterns() + urlpatterns
Exemple #39
0
from django.conf.urls.defaults import *
from django.conf import settings
from website.models import *
from django.contrib.sitemaps import GenericSitemap
from django.views.generic import TemplateView
from django.conf.urls.static import static
from django.contrib.staticfiles.urls import staticfiles_urlpatterns


from django.contrib import admin
admin.autodiscover()


urlpatterns = patterns('',
    (r'^', include('website.urls')),
    (r'^admin/', include(admin.site.urls)),
    (r'^robots\.txt$', TemplateView.as_view(template_name="robots.txt")),
    url(r'^zh/', TemplateView.as_view(template_name="index_zh.html")),
)+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

urlpatterns += staticfiles_urlpatterns()


Exemple #40
0
    url(r'^test/page$', test_page),
    url(r'^wx/page/scan/fhcode$',
        weixin_scan_fhcode),  # 已经绑定微信的华校任意学校的用户,扫烽火二维码登陆
    url(r'^wx/page/scan/schoolcode$',
        weixin_homepage),  # 扫学校码进入的页面,如果绑定了,则跳转到微信首页,如果没有绑定,则跳转到家长绑定页面。
    url(r'^wx/page/scan/parentcode$',
        weixin_homepage),  # 扫家长邀请码进入的页面,如果绑定了,则跳转到微信首页,如果没有绑定,则跳转到家长邀请绑定页面。
    url(r'^wx/page/add/role$', weixin_homepage),  # 用户到个人中心添加身份时,跳转页面。
]

# urlpatterns += patterns('',
#     url(r'^login/$', cas_views.login, name='cas_ng_login'),
#     url(r'^logout/$', cas_views.logout, name='cas_ng_logout'),
# )

# Development
from django.conf import settings
if settings.DEBUG:
    from django.conf.urls.static import static
    from django.contrib.staticfiles.urls import staticfiles_urlpatterns
    media = static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

    urlpatterns = media + staticfiles_urlpatterns() + urlpatterns

# 初始化数据库数据
from user_center.apps.service import agents as service_agents
service_agents.init_service()

from user_center.apps.school import school_agents
school_agents.init_school_db()