RelatedPost: mapping['thread'] now manage relation between thread and parent of related object
This commit is contained in:
@ -385,50 +385,3 @@ class Sections:
|
||||
return context
|
||||
|
||||
|
||||
class ViewSet:
|
||||
"""
|
||||
A ViewSet is a class helper that groups detail and list views that can be
|
||||
used to generate views and routes given a model and a name used for the
|
||||
routing.
|
||||
"""
|
||||
model = None
|
||||
list_view = PostListView
|
||||
list_routes = []
|
||||
|
||||
detail_view = PostDetailView
|
||||
detail_sections = [
|
||||
Sections.PostContent(),
|
||||
Sections.PostImage(),
|
||||
]
|
||||
|
||||
|
||||
def get_list_name (self):
|
||||
"""
|
||||
Return a string with the name to use in the route for the lists
|
||||
"""
|
||||
return self.model._meta.verbose_name_plural.lower()
|
||||
|
||||
@classmethod
|
||||
def get_detail_name (cl):
|
||||
"""
|
||||
Return a string with the name to use in the route for the details
|
||||
"""
|
||||
return cl.model._meta.verbose_name.lower()
|
||||
|
||||
def connect (self, website = None):
|
||||
self.detail_view = self.detail_view.as_view(
|
||||
model = self.model,
|
||||
sections = self.detail_sections,
|
||||
website = website,
|
||||
)
|
||||
self.list_view = self.list_view.as_view(
|
||||
model = self.model,
|
||||
website = website,
|
||||
)
|
||||
|
||||
self.urls = [ route.as_url(self.model, self.get_list_name(),
|
||||
self.list_view) for route in self.list_routes ] + \
|
||||
[ routes.DetailRoute.as_url(self.model,
|
||||
self.get_detail_name(), self.detail_view ) ]
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user