def get_context_data(self, **kwargs): context = super(GroupDescriptionDetailView, self).get_context_data(**kwargs) workgroup = context['workgroup'] # First be sure that the home Wiki article already exists try: home_article = Article.get_for_object(workgroup) except ArticleForObject.DoesNotExist: return redirect('workgroup-detail', slug=workgroup.slug) # now check that the description article exists try: desc_article = Article.get_for_object(home_article) except ArticleForObject.DoesNotExist: desc_article = Article.objects.create() desc_article.add_object_relation(home_article) revision = ArticleRevision(title="description of %s" % workgroup.name, content='') desc_article.add_revision(revision) context.update({ 'wiki_article': desc_article, }) return context
def dispatch(self, request, workgroup_slug, *args, **kwargs): self.workgroup = get_object_or_404(WorkGroup, slug=workgroup_slug) article = Article.get_for_object(Article.get_for_object(self.workgroup)) self.sidebar_plugins = plugin_registry.get_sidebar() self.sidebar = [] return super(WikiEdit, self).dispatch(request, article, *args, **kwargs)
def dispatch(self, request, workgroup_slug, *args, **kwargs): self.workgroup = get_object_or_404(WorkGroup, slug=workgroup_slug) article = Article.get_for_object(Article.get_for_object( self.workgroup)) self.sidebar_plugins = plugin_registry.get_sidebar() self.sidebar = [] return super(WikiEdit, self).dispatch(request, article, *args, **kwargs)
def full_dehydrate(self, bundle, for_list=False): bundle = ModelResource.full_dehydrate(self, bundle, for_list) if bundle.obj.picture: thumbnailer = get_thumbnailer(bundle.obj.picture) thumbnail_options = { 'size': (ResizeThumbApi.width, ResizeThumbApi.height) } bundle.data["thumb"] = thumbnailer.get_thumbnail( thumbnail_options).url else: bundle.data["thumb"] = None if for_list is False: bundle.data["tags"] = [ tag.name for tag in Tag.objects.get_for_object(bundle.obj) ] if (bundle.obj.picture): thumbnail_options = { 'size': (ResizeDisplay.width, ResizeDisplay.width) } bundle.data["image"] = thumbnailer.get_thumbnail( thumbnail_options).url else: bundle.data["image"] = None try: bundle.data["article"] = Article.get_for_object( bundle.obj).render() except ArticleForObject.DoesNotExist: bundle.data["article"] = None return bundle
def get_context_data(self, **kwargs): """ Adds the member of the associated ML if there's one """ context = super(GroupDetailView, self).get_context_data(**kwargs) workgroup = context['workgroup'] # Look up mailing list members context.update(lookup_ml_membership(workgroup)) # Wiki try: article = Article.get_for_object(workgroup) except ArticleForObject.DoesNotExist: article = Article.objects.create() article.add_object_relation(workgroup) revision = ArticleRevision(title=workgroup.name, content='') article.add_revision(revision) context['wiki_article'] = article context['group_projects'] = workgroup.projects.all() return context
def get_context_data(self, **kwargs): """ Adds the member of the associated ML if there's one """ context = super(GroupDetailView, self).get_context_data(**kwargs) workgroup = context['workgroup'] # Look up mailing list members context.update(lookup_ml_membership(workgroup)) # Wiki try: article = Article.get_for_object(workgroup) except ArticleForObject.DoesNotExist: article = Article.objects.create() article.add_object_relation(workgroup) revision = ArticleRevision(title=workgroup.name, content='') article.add_revision(revision) context['wiki_article'] = article context['group_projects'] = workgroup.projects.prefetch_related( 'locations').all().order_by('?') return context
def get_context_data(self, **kwargs): context = super(GroupDescriptionDetailView, self).get_context_data(**kwargs) workgroup = context['workgroup'] # First be sure that the home Wiki article already exists try: home_article = Article.get_for_object(workgroup) except ArticleForObject.DoesNotExist: return redirect('workgroup-detail', slug=workgroup.slug) # now check that the description article exists try: desc_article = Article.get_for_object(home_article) except ArticleForObject.DoesNotExist: desc_article = Article.objects.create() desc_article.add_object_relation(home_article) revision = ArticleRevision(title="description of %s" %workgroup.name, content='') desc_article.add_revision(revision) context.update({ 'wiki_article' : desc_article, }) return context
def full_dehydrate(self, bundle, for_list=False): bundle = ModelResource.full_dehydrate(self, bundle, for_list) if bundle.obj.picture: thumbnailer = get_thumbnailer(bundle.obj.picture) thumbnail_options = {'size': (ResizeThumbApi.width, ResizeThumbApi.height)} bundle.data["thumb"] = thumbnailer.get_thumbnail(thumbnail_options).url else: bundle.data["thumb"] = None if for_list is False: bundle.data["tags"] = [tag.name for tag in Tag.objects.get_for_object(bundle.obj)] if(bundle.obj.picture): thumbnail_options = {'size': (ResizeDisplay.width, ResizeDisplay.width)} bundle.data["image"] = thumbnailer.get_thumbnail(thumbnail_options).url else: bundle.data["image"] = None try: bundle.data["article"] = Article.get_for_object(bundle.obj).render() except ArticleForObject.DoesNotExist: bundle.data["article"] = None return bundle