Exemplo n.º 1
0
    def as_search_dict(self):
        """Create a dict that can be ingested by Solr"""
        # IDs
        out = {
            "id": self.pk,
            "docket_id": self.docket_id,
            "court_id": self.docket.court_id,
        }

        # Docket
        docket = {"docketNumber": self.docket.docket_number}
        if self.docket.date_argued is not None:
            docket["dateArgued"] = midnight_pst(self.docket.date_argued)
        if self.docket.date_reargued is not None:
            docket["dateReargued"] = midnight_pst(self.docket.date_reargued)
        if self.docket.date_reargument_denied is not None:
            docket["dateReargumentDenied"] = midnight_pst(
                self.docket.date_reargument_denied
            )
        out.update(docket)

        # Court
        out.update(
            {
                "court": self.docket.court.full_name,
                "court_citation_string": self.docket.court.citation_string,
                "court_exact": self.docket.court_id,  # For faceting
            }
        )

        # Audio File
        out.update(
            {
                "caseName": best_case_name(self),
                "panel_ids": [judge.pk for judge in self.panel.all()],
                "judge": self.judges,
                "file_size_mp3": deepgetattr(
                    self, "local_path_mp3.size", None
                ),
                "duration": self.duration,
                "source": self.source,
                "download_url": self.download_url,
                "local_path": str(getattr(self, "local_path_mp3", None)),
            }
        )
        try:
            out["absolute_url"] = self.get_absolute_url()
        except NoReverseMatch:
            raise InvalidDocumentError(
                "Unable to save to index due to missing absolute_url: %s"
                % self.pk
            )

        text_template = loader.get_template("indexes/audio_text.txt")
        out["text"] = text_template.render({"item": self}).translate(null_map)

        return normalize_search_dicts(out)
Exemplo n.º 2
0
    def as_search_dict(self):
        """Create a dict that can be ingested by Solr"""
        # IDs
        out = {
            'id': self.pk,
            'docket_id': self.docket_id,
            'court_id': self.docket.court_id,
        }

        # Docket
        docket = {'docketNumber': self.docket.docket_number}
        if self.docket.date_argued is not None:
            docket['dateArgued'] = midnight_pst(self.docket.date_argued)
        if self.docket.date_reargued is not None:
            docket['dateReargued'] = midnight_pst(self.docket.date_reargued)
        if self.docket.date_reargument_denied is not None:
            docket['dateReargumentDenied'] = midnight_pst(
                self.docket.date_reargument_denied)
        out.update(docket)

        # Court
        out.update({
            'court': self.docket.court.full_name,
            'court_citation_string': self.docket.court.citation_string,
            'court_exact': self.docket.court_id,  # For faceting
        })

        # Audio File
        out.update({
            'caseName':
            best_case_name(self),
            'panel_ids': [judge.pk for judge in self.panel.all()],
            'judge':
            self.judges,
            'file_size_mp3':
            deepgetattr(self, 'local_path_mp3.size', None),
            'duration':
            self.duration,
            'source':
            self.source,
            'download_url':
            self.download_url,
            'local_path':
            unicode(getattr(self, 'local_path_mp3', None))
        })
        try:
            out['absolute_url'] = self.get_absolute_url()
        except NoReverseMatch:
            raise InvalidDocumentError(
                "Unable to save to index due to missing absolute_url: %s" %
                self.pk)

        text_template = loader.get_template('indexes/audio_text.txt')
        out['text'] = text_template.render({'item': self}).translate(null_map)

        return normalize_search_dicts(out)
Exemplo n.º 3
0
    def as_search_dict(self):
        """Create a dict that can be ingested by Solr"""
        # IDs
        out = {
            'id': self.pk,
            'docket_id': self.docket_id,
            'court_id': self.docket.court_id,
        }

        # Docket
        docket = {'docketNumber': self.docket.docket_number}
        if self.docket.date_argued is not None:
            docket['dateArgued'] = midnight_pst(self.docket.date_argued)
        if self.docket.date_reargued is not None:
            docket['dateReargued'] = midnight_pst(self.docket.date_reargued)
        if self.docket.date_reargument_denied is not None:
            docket['dateReargumentDenied'] = midnight_pst(
                self.docket.date_reargument_denied)
        out.update(docket)

        # Court
        out.update({
            'court': self.docket.court.full_name,
            'court_citation_string': self.docket.court.citation_string,
            'court_exact': self.docket.court_id,  # For faceting
        })

        # Audio File
        out.update({
            'caseName': best_case_name(self),
            'panel_ids': [judge.pk for judge in self.panel.all()],
            'judge': self.judges,
            'file_size_mp3': deepgetattr(self, 'local_path_mp3.size', None),
            'duration': self.duration,
            'source': self.source,
            'download_url': self.download_url,
            'local_path': unicode(getattr(self, 'local_path_mp3', None))
        })
        try:
            out['absolute_url'] = self.get_absolute_url()
        except NoReverseMatch:
            raise InvalidDocumentError(
                "Unable to save to index due to missing absolute_url: %s"
                % self.pk
            )

        text_template = loader.get_template('indexes/audio_text.txt')
        out['text'] = text_template.render({'item': self}).translate(null_map)

        return normalize_search_dicts(out)
Exemplo n.º 4
0
def solr_list(m2m_list, field):
    new_list = []
    for obj in m2m_list:
        obj = getattr(obj, field)
        if obj is None:
            continue
        if isinstance(obj, date):
            obj = midnight_pst(obj)
        new_list.append(obj)
    return new_list
def solr_list(m2m_list, field):
    new_list = []
    for obj in m2m_list:
        obj = getattr(obj, field)
        if obj is None:
            continue
        if isinstance(obj, date):
            obj = midnight_pst(obj)
        new_list.append(obj)
    return new_list
Exemplo n.º 6
0
 def item_pubdate(self, item):
     return midnight_pst(get_item(item)['dateFiled'])
Exemplo n.º 7
0
 def item_pubdate(self, item: DocketEntry) -> datetime:
     return midnight_pst(item.date_filed)