|
@ -55,12 +55,12 @@ def make_pagination(index, num_pages): |
|
|
|
|
|
|
|
|
class BaseMixin(CrispyLayoutFormMixin): |
|
|
class BaseMixin(CrispyLayoutFormMixin): |
|
|
|
|
|
|
|
|
@classmethod |
|
|
@property |
|
|
def url_name(cls, suffix): |
|
|
def namespace(self): |
|
|
return '%s_%s' % (cls.model._meta.model_name, suffix) |
|
|
return self.model._meta.model_name |
|
|
|
|
|
|
|
|
def resolve_url(self, suffix, args=None): |
|
|
def resolve_url(self, url_name, args=None): |
|
|
return reverse(self.url_name(suffix), args=args) |
|
|
return reverse('%s:%s' % (self.namespace, url_name), args=args) |
|
|
|
|
|
|
|
|
@property |
|
|
@property |
|
|
def list_url(self): |
|
|
def list_url(self): |
|
@ -195,13 +195,17 @@ class Crud: |
|
|
CrudUpdateView = _add_base(cls.UpdateView) |
|
|
CrudUpdateView = _add_base(cls.UpdateView) |
|
|
CrudDeleteView = _add_base(cls.DeleteView) |
|
|
CrudDeleteView = _add_base(cls.DeleteView) |
|
|
|
|
|
|
|
|
return [url(regex, view.as_view(), name=view.url_name(suffix)) |
|
|
urlpatterns = [ |
|
|
for regex, view, suffix in [ |
|
|
url(r'^$', CrudListView.as_view(), name='list'), |
|
|
(r'^$', CrudListView, 'list'), |
|
|
url(r'^create$', CrudCreateView.as_view(), name='create'), |
|
|
(r'^create$', CrudCreateView, 'create'), |
|
|
url(r'^(?P<pk>\d+)$', CrudDetailView.as_view(), name='detail'), |
|
|
(r'^(?P<pk>\d+)$', CrudDetailView, 'detail'), |
|
|
url(r'^(?P<pk>\d+)/edit$', |
|
|
(r'^(?P<pk>\d+)/edit$', CrudUpdateView, 'update'), |
|
|
CrudUpdateView.as_view(), name='update'), |
|
|
(r'^(?P<pk>\d+)/delete$', CrudDeleteView, 'delete'), ]] |
|
|
url(r'^(?P<pk>\d+)/delete$', |
|
|
|
|
|
CrudDeleteView.as_view(), name='delete'), |
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
return urlpatterns, _add_base(object)().namespace |
|
|
|
|
|
|
|
|
@classonlymethod |
|
|
@classonlymethod |
|
|
def build(cls, _model, _help_path): |
|
|
def build(cls, _model, _help_path): |
|
|