def testViewView(self): v = views.ViewView() self.assertFalse(v.isbound) self.assertEqual(v.parent_view,None) self.assertEqual(v.parent,None) self.assertEqual(v.route,v.rel_route) self.assertEqual(v.path,'/<id>/')
class AdminApplicationSimple(views.Application): pagination = html.Pagination(('__str__',)) has_plugins = False search = views.SearchView() delete_all = views.DeleteAllView() view = views.ViewView() delete = views.DeleteView()
class GroupApplication(views.Application): '''An application group. NOT YET READ NOR TESTED''' home = views.View() search = views.SearchView('<group>') add = views.AddView() view = views.ViewView() change = views.ChangeView() delete = views.DeleteView()
class DesignApplication(views.Application): pagination = html.Pagination(('id', 'timestamp')) home = views.SearchView() add = views.AddView(form=AddThemeHtml, has_plugins=True, name='Add theme') view = views.ViewView() forms_view = views.View('/forms') def render_instance_default(self, request, instance, **kwargs): return get_form(request, ThemeInputsHtml)
class UserApplication(UserAppBase): '''This is a special Application since it deals with users and therefore is everywhere. No assumption has been taken over which model is used for storing user data.''' in_nav = 0 view = views.ViewView('<username>/') change = views.ChangeView(form=HtmlUserChangeForm) change_password = views.ChangeView('change-password', linkname=lambda r: 'change password', icon='icon-key', has_plugins=True, form=HtmlChangePassword)
class Application(views.Application): form = search.search_form(placeholder='Type a geographical place', choices=search.Search(autocomplete=True, search=True, model=Geo)) main = views.View() view = views.ViewView() tsp = TspView('/tsp', has_plugins=True) def render(self, request, query=None, **context): # Render the main view by rendering the search form return self.get_form(request, **context).render(request) def post_response(self, request): # the default post response return self.get_form(request).render(request) def render_instance_default(self, request, instance, **kwargs): # render the default instance view maker = GeoEntry() return maker(instance=instance, appmodel=self)
class SiteMapApplication(views.Application): '''Application to use for admin sitemaps''' has_plugins = False form = HtmlPageForm description = 'Site-map' pagination = Pagination( ('url', 'view', 'layout', 'inner_template', 'in_navigation', table_header('doc_type', attrname='doctype'), 'soft_root'), bulk_actions=[views.bulk_delete]) list_display_links = ('id', 'url', 'page') home = SiteMapView() pages = views.SearchView('pages/', icon='th-list', title=lambda r: 'Pages', linkname=lambda r: 'pages') add = views.AddView(force_redirect=True, linkname=lambda r: 'add page') view = views.ViewView() change = PageChangeView(force_redirect=True, title=lambda djp: 'editing', linkname=lambda djp: 'edit page', body_class='editable') delete = views.DeleteView() def on_bound(self): self.root.internals['Page'] = self.mapper def view_for_instance(self, request, instance): return self.views['change'] def instance_field_value(self, request, page, field_name, val=''): if field_name == 'view': node = request.tree.get(page.url) view = node.view if not isinstance(view, pageview): return view.code else: return '' else: return escape(val)
class ContentApplication(views.Application): '''AJAX enabled :class:`djpcms.views.Application` for changing content in a content block.''' form = ContentBlockHtmlForm has_plugins = False pop_up = False url_bits_mapping = {'contentblock': 'id'} search = views.SearchView() view = views.ViewView('<int:contentblock>/') change = ChangeContentView() delete = DeleteContentView() def on_bound(self): self.root.internals['BlockContent'] = self.mapper def submit(self, *args, **kwargs): return [html.Widget('input:submit', value="save", name='_save')] def remove_instance(self, instance): bid = instance.htmlid() instance.delete() return bid
class Application(views.Application): search = views.SearchView() add = views.AddView() view = views.ViewView() change = views.ChangeView() delete = views.DeleteView()