Return context about matching datasets.
182066
def generate_additional_context(self, matching_datasets):
        """"""
        related_tags = Tag.objects.filter(
            dataset__in=matching_datasets
        ).distinct().annotate(
            Count('word')
        ).order_by('-word__count')[:5]

        return {
            'related_tags': related_tags
        }
1312182
def get_contextualize_items_by_step(self, default=None):
        """"""
        if self.items:
            res = {}
            for elem in self.items.values():
                if elem.num in res:
                    res[elem.num].append(elem)
                else:
                    res[elem.num] = [elem]
            return res
        else:
            return default
595762
def contexts(self):
        
        if not hasattr(self, "_contexts"):
            cs = {}
            for cr in self.doc["contexts"]:
                cs[cr["name"]] = copy.deepcopy(cr["context"])
            self._contexts = cs
        return self._contexts
152897
def get(self, request, slug):
        
        matching_datasets = self.generate_matching_datasets(slug)

        if matching_datasets is None:
            raise Http404("Datasets meeting these criteria do not exist.")

        base_context = {
            'datasets': matching_datasets,
            'num_datasets': matching_datasets.count(),
            'page_title': self.generate_page_title(slug),
        }

        additional_context = self.generate_additional_context(
            matching_datasets
        )

        base_context.update(additional_context)
        context = base_context

        return render(
            request,
            self.template_path,
            context
        )
163709
def as_dataset(self):
        """"""

        on = self.on.dataset

        on.revision = self.on.revision

        name = Name(**self.name.dict)

        return Identity(name, on)
1080449
def get_context_data(self, **kwargs):
        """"""
        context = super().get_context_data(**kwargs)
        context.update({
            'title': self.title,
            'submit_value': self.submit_value,
            'cancel_url': self.get_cancel_url(),
            'model_verbose_name': self.get_model_class()._meta.verbose_name
        })

        return context
313142
def get_context(self, name, value, attrs):
        """"""
        context = super().get_context(
            name, value, attrs)
        context['widget']['attrs']['dp_config'] = json_dumps(self.config)
        return context
481955
def get_context_data(self, **kwargs):
        """"""
        data = super(GaugesView, self).get_context_data(**kwargs)
        data.update({'gauges': get_r().gauge_slugs()})
        return data
1076619
def get_context_data(self, **kwargs):
        """"""
        data = super(MetricDetailView, self).get_context_data(**kwargs)
        data['slug'] = kwargs['slug']
        data['granularities'] = list(get_r()._granularities())
        return data
964672
def complete_contexts(self):
        '''
        
        '''
        if self._complete_contexts:
            return self._complete_contexts
        self.context()
        return self._complete_contexts
1159092
def match(self, name, rdclass, rdtype, covers, deleting=None):
        """"""

        if not super(RRset, self).match(rdclass, rdtype, covers):
            return False
        if self.name != name or self.deleting != deleting:
            return False
        return True
180143
def get_context_files(data):
    
    ref_file = dd.get_ref_file(data)
    all_files = []
    for ext in [".bed.gz"]:
        all_files += sorted(glob.glob(os.path.normpath(os.path.join(os.path.dirname(ref_file), os.pardir,
                                                                    "coverage", "problem_regions", "*",
                                                                    "*%s" % ext))))
    return sorted(all_files)
1149699
def get_context_data(self, **kwargs):
        """"""
        context = super(TermsView, self).get_context_data(**kwargs)
        context['terms_base_template'] = getattr(settings, 'TERMS_BASE_TEMPLATE', DEFAULT_TERMS_BASE_TEMPLATE)
        return context
526985
def get_context_data(self, **kwargs):
        """"""
        
        strain = super(StrainDetail, self).get_object()
        context = super(StrainDetail, self).get_context_data(**kwargs)
        context['breeding_cages'] = Breeding.objects.filter(Strain=strain)
        context['animal_list'] = Animal.objects.filter(Strain=strain).order_by('Background','Genotype')
        context['cages'] = Animal.objects.filter(Strain=strain).values("Cage").distinct()
        context['active'] = False        
        return context
945300
def get_context_data(self, **kwargs):
        """"""
        data = super(MetricHistoryView, self).get_context_data(**kwargs)

        # Accept GET query params for ``since``
        since = self.request.GET.get('since', None)
        if since and len(since) == 10:  # yyyy-mm-dd
            since = datetime.strptime(since, "%Y-%m-%d")
        elif since and len(since) == 19:  # yyyy-mm-dd HH:MM:ss
            since = datetime.strptime(since, "%Y-%m-%d %H:%M:%S")

        data.update({
            'since': since,
            'slug': kwargs['slug'],
            'granularity': kwargs['granularity'],
            'granularities': list(get_r()._granularities()),
        })
        return data
429632
def get_context_data(self, **kwargs):
		""""""
		context = super().get_context_data(**kwargs)
		context.update(
			{
				"STRIPE_PUBLIC_KEY": djstripe_settings.STRIPE_PUBLIC_KEY,
				"plans": Plan.objects.all(),
			}
		)
		return context
855274
def get_context_data(self, **kwargs):
        """"""
        query = self.request.GET.get('q', '')
        context = super(BreedingSearch, self).get_context_data(**kwargs)
        context['breeding_type'] = "Search"
        context['query'] = query
        if query:
            context['results'] = Breeding.objects.filter(Cage__icontains=query).distinct()
        else:
            context['results'] = []        
        return context