mirror of https://github.com/interlegis/sapl.git
Marcio Mazza
9 years ago
committed by
LeandroRoberto
6 changed files with 94 additions and 9 deletions
@ -0,0 +1,35 @@ |
|||
from .base import (Crud, CrudCreateView, CrudDeleteView, CrudDetailView, |
|||
CrudListView, CrudUpdateView) |
|||
|
|||
|
|||
class MasterDetailCrud(Crud): |
|||
|
|||
class ListView(CrudListView): |
|||
|
|||
@classmethod |
|||
def get_url_regex(cls): |
|||
return r'^(?P<pk>\d+)/%s$' % cls.model._meta.model_name |
|||
|
|||
class CreateView(CrudCreateView): |
|||
|
|||
@classmethod |
|||
def get_url_regex(cls): |
|||
return r'^(?P<pk>\d+)/%s/create$' % cls.model._meta.model_name |
|||
|
|||
class DetailView(CrudDetailView): |
|||
|
|||
@classmethod |
|||
def get_url_regex(cls): |
|||
return r'^%s/(?P<pk>\d+)$' % cls.model._meta.model_name |
|||
|
|||
class UpdateView(CrudUpdateView): |
|||
|
|||
@classmethod |
|||
def get_url_regex(cls): |
|||
return r'^%s/(?P<pk>\d+)/edit$' % cls.model._meta.model_name |
|||
|
|||
class DeleteView(CrudDeleteView): |
|||
|
|||
@classmethod |
|||
def get_url_regex(cls): |
|||
return r'^%s/(?P<pk>\d+)/delete$' % cls.model._meta.model_name |
@ -1,7 +1,8 @@ |
|||
from django.conf.urls import include, url |
|||
|
|||
from .views import CountryCrud |
|||
from .views import CityCrud, CountryCrud |
|||
|
|||
urlpatterns = [ |
|||
url(r'^country/', include(CountryCrud.get_urls(), 'stub_app')), |
|||
url(r'^country/', include( |
|||
CountryCrud.get_urls() + CityCrud.get_urls(), 'stub_app')), |
|||
] |
|||
|
@ -0,0 +1,14 @@ |
|||
import pytest |
|||
from django.core.urlresolvers import reverse |
|||
|
|||
|
|||
@pytest.mark.parametrize('path_name', [ |
|||
'/country/1/city stub_app:city_list', |
|||
'/country/1/city/create stub_app:city_create', |
|||
'/country/city/1 stub_app:city_detail', |
|||
'/country/city/1/edit stub_app:city_update', |
|||
'/country/city/1/delete stub_app:city_delete', |
|||
]) |
|||
def test_reverse(path_name): |
|||
path, name = path_name.split() |
|||
assert path == reverse(name, args=(1,)) |
Loading…
Reference in new issue