def to_html(self, verbose: bool = False, **kwargs) -> str: """ Returns the HTML representation of this instance. If the *verbose* keyword argument is passed as *True*, returns the entire header as JSON. Otherwise, returns an HTML link to this instance in the admin site. Parameters ---------- verbose : bool, optional Whether to return all of the header information or just a link, by default False Returns ------- str HTML text containing either JSON encoded header information or a link to the admin site """ if verbose: return Html.json(self.value) text = f"Csa Header #{self.id}" return Html.admin_link("DataElementValue", self.id, text)
def to_html(self, verbose: bool = False, **kwargs) -> str: value = [ subheader.to_html(verbose=verbose) for subheader in self.header_set.all() ] sep = Html.horizontal_line() if verbose else Html.BREAK return mark_safe(sep.join(value))
def test_to_html(self): """ Tests that the instance's :meth:`~django_dicom.models.values.PersonName.to_html` method returns the required pattern. """ expected = Html.json(TEST_PERSON_NAME["value"]) result = self.person.to_html() self.assertEqual(result, expected)
def to_html(self, **kwargs) -> str: """ Returns the HTML representation of this instance. Returns ------- str HTML representation of this instance """ return Html.json(self.value)
def to_html(self, verbose: bool = False, **kwargs) -> str: """ Returns an HTML representation of this instance. Parameters ---------- verbose : bool, optional Whether to return a JSON with all of the header information or just a link to this instance's admin page, by default False. Returns ------- str HTML representaion of this instance """ if verbose: return Html.json(self.to_verbose_list()) text = f"Header #{self.id}" return Html.admin_link("Header", self.id, text)
def admin_link(self) -> str: """ Returns an HTML tag linking to this instance in the admin site. Returns ------- str HTML link to this instance """ model_name = self.__class__.__name__ return Html.admin_link(model_name, self.id)
def admin_link(self) -> str: """ Creates an HTML tag to link to this instance within the admin site. Returns ------- str Link to this instance in the admin site """ model_name = self.__class__.__name__ return Html.admin_link(model_name, self.id)
def get_admin_link(self, text: str = None) -> str: """ Returns an HTML link to this instance's page in the admin site. Parameters ---------- text : str, optional Text to display, by default None Returns ------- str HTML element """ model_name: str = self.__class__.__name__ return Html.admin_link(model_name, self.id, text=text)
def id_link(self, series: Series) -> str: return Html.admin_link("Series", series.id)
def value_instances(self, data_element: DataElement): values = data_element._values.all() links = [value.admin_link for value in values] return Html.break_html(links)