Skip to content

Commit

Permalink
made code more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
Nishim12 committed Aug 23, 2024
1 parent ec34994 commit 34e22cb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions article/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,7 @@ def format_author(article_author):
seen_authors = set()
unique_authors = []

# Ensuring duplicate authors are not added to the author list
for article_author in authors_list:
author_name = article_author.author.id
if author_name not in seen_authors:
Expand Down Expand Up @@ -1085,7 +1086,7 @@ def get_authors_in_order(self):
return authors_list
authors_in_order = property(fget=get_authors_in_order)

def get_authors_in_order_for_cards(self):
def get_authors_in_order_for_author_cards(self):
AUTHOR_TYPES = ["org_role", "author", "photographer", "illustrator", "videographer"]
authors = self.article_authors.all()

Expand All @@ -1098,7 +1099,7 @@ def get_authors_in_order_for_cards(self):

if author_role == author_type:
if author_id not in authors_dict:
# Create the author dictionary container author and authors multiple roles
# Create the author dictionary containing author object and authors multiple roles
authors_dict[author_id] = {
'author': author,
'roles': [author_role]
Expand All @@ -1110,7 +1111,7 @@ def get_authors_in_order_for_cards(self):

return authors_dict

authors_in_order_for_cards = property(fget=get_authors_in_order_for_cards)
authors_in_order_for_cards = property(fget=get_authors_in_order_for_author_cards)

def get_authors_with_roles(self) -> str:
"""Returns list of authors as a comma-separated string
Expand Down

0 comments on commit 34e22cb

Please sign in to comment.