Пример #1
0
 def test_site(self):
     '''
     Test registering, unregistering and urls
     
     '''
     
     site = SmarterSite()
     class TestModel(models.Model):
         test_field = models.TextField()
     
     urlpatterns = []
     
     def in_patterns(url):
         for pattern in urlpatterns:
             try:
                 if pattern.resolve(url):
                     return True
             except Resolver404:
                 pass
         return False
     
     site.register(TestModel)
     urlpatterns = patterns('', *site.urls)
     self.assertTrue(in_patterns('testmodel/')) #index
     self.assertTrue(in_patterns('testmodel/add/')) #add
     self.assertTrue(in_patterns('testmodel/1/edit/')) #edit
     self.assertTrue(in_patterns('testmodel/2/')) #details
     self.assertTrue(in_patterns('testmodel/2/remove/')) #remove
     #site.unregister(TestModel) #still unimplemented
     
     'final sanity check'
Пример #2
0
from django.conf.urls import patterns, include, url
from django.contrib import admin
from smarter import SmarterSite
from web.models import *
from web.views import *

admin.autodiscover()
site = SmarterSite()
site.register(MyCustomModel)

urlpatterns = patterns('',
    url(r'^', include(site.urls)),
    url(r'^$', 'web.views.home', name="home"),
    url(r'^welcome/$', 'web.views.welcome', name="welcome"),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^accounts/', include('social_auth.urls')),
    url(r'^messages/', include('accounts.contrib.umessages.urls')),
    url(r'^accounts/', include('accounts.urls')),
    url(r'^i18n/', include('django.conf.urls.i18n')),
 )
Пример #3
0
from django.conf.urls import patterns, include, url
from django.contrib import admin
from smarter import SmarterSite
from web.models import *
from web.views import *

admin.autodiscover()
site = SmarterSite()
site.register(Item)

urlpatterns = patterns(
    "",
    url(r"^", include(site.urls)),
    url(r"^$", "web.views.home", name="home"),
    url(r"^welcome/$", "web.views.welcome", name="welcome"),
    url(r"^admin/", include(admin.site.urls)),
    url(r"^accounts/", include("social_auth.urls")),
    url(r"^accounts/", include("userprofiles.urls")),
    url(r"^accounts/profile/(?P<username>[-\w]+)/$", "web.views.profile", name="public_profile"),
    url(r"^i18n/", include("django.conf.urls.i18n")),
    url(r"^activity/", include("actstream.urls")),
    url(r"^messages/", include("django_messages.urls")),
)