Skip to content

Commit

Permalink
Further refactoring (mostly class-based views)
Browse files Browse the repository at this point in the history
  • Loading branch information
kallewesterling committed Sep 26, 2024
1 parent 684ef0e commit 4ee14d9
Show file tree
Hide file tree
Showing 7 changed files with 399 additions and 321 deletions.
8 changes: 8 additions & 0 deletions seshat/apps/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,14 @@ def _wrap(label, simple=False):
"note": "No_Actual_note",
"no_value": "The value is not available.",
"nothing": "NOTHING",
"private_comments": "NO_Private_COMMENTS_TO_SHOW",
"titles": "NO_TITLES_PROVIDED",
"ref_no_title": "REFERENCE_WITH_NO_TITLE",
"ref_no_long_name": "REFERENCE_WITH_NO_LONG_NAME",
"bad_reference": "BADBADREFERENCE",
"comment_parts": " Nothing ",
"descriptions": "No descriptions.",
"comment": "EMPTY_COMMENT",
}
)

Expand Down
38 changes: 38 additions & 0 deletions seshat/apps/core/mixins.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from django.urls import reverse
from ..utils import deprecated


class ZoteroMixIn:
@property
def __no_zotero_link__(self) -> str:
return reverse("citation-update", args=[self.id])

@property
def has_zotero(self) -> bool:
return self.ref.has_zotero

@property
def zotero_link(self) -> str:
"""
Returns the Zotero link for the citation.
Returns:
str: The Zotero link for the citation.
"""
if self.has_zotero:
return self.ref.full_zotero_link

return self.__no_zotero_link__

@deprecated
def zoteroer(self) -> str:
"""
For backward compatibility, this method returns the Zotero link for the citation.
Returns:
str: The Zotero link for the citation.
Deprecated:
Use the `zotero_link` property instead.
"""
return self.zotero_link
Loading

0 comments on commit 4ee14d9

Please sign in to comment.