def get_context_data(self, **kwargs): for name, posttype in posttypes.items(): # Annotate each posttype with an instance of the form that has # auto_id populated. form_class = posttype.get_form_class() posttype.form_instance = form_class(auto_id="id_%s_%%s" % name) posts = [] for base_post in BasePost.objects.all(): # Get the actual type-specific post object using the multi-table # child accessor posts.append(getattr(base_post, base_post.posttype)) context = super(HomeView, self).get_context_data(**kwargs) context.update({ 'NARCISSUS_STATIC_URL': STATIC_URL, 'LOGOUT_URL': settings.LOGOUT_URL, 'user': self.request.user, 'posttypes': posttypes, 'posts': posts, }) return context
def add_narcissus_urls(urls): urls += patterns('', url(r'^dashboard/', include('narcissus.dashboard.urls')), url(r'^api/user/(?P<pk>[^/]+)/$', InstanceModelView.as_view( resource=UserResource, permissions=(SameUserOrReadOnly,), ), name='narcissus-user-detail'), ) for name, posttype in posttypes.items(): urls += patterns('', url(r'^api/%s/$' % name, ListOrCreateModelView.as_view( resource=posttype.resource, permissions=(permissions.IsUserOrIsAnonReadOnly,), ), name='narcissus-api-%s' % name), url(r'^api/%s/(?P<pk>[^/]+)/$' % name, InstanceModelView.as_view( resource=posttype.resource, permissions=(SameUserOrReadOnly,), ), name='narcissus-api-%s-detail' % name), ) return urls