Fixed client handling of is_archived
This commit is contained in:
parent
c7ccecf61d
commit
9fff7b972f
|
@ -228,7 +228,7 @@ class FavroClient:
|
|||
'name': card_contents.name,
|
||||
'detailedDescription': card_contents.description,
|
||||
'descriptionFormat': 'markdown',
|
||||
'archived': card_contents.archived,
|
||||
'archived': card_contents.is_archived,
|
||||
}
|
||||
|
||||
url = URL_UPDATE_CARD.format(card_id=card_id.raw_id)
|
||||
|
|
|
@ -227,7 +227,6 @@ class Card:
|
|||
due_date: datetime.date | None
|
||||
attachments: list[dict]
|
||||
detailed_description: str | None
|
||||
archived: bool
|
||||
|
||||
@staticmethod
|
||||
def from_json(json: dict[str, Any]) -> 'Card':
|
||||
|
@ -256,7 +255,6 @@ class Card:
|
|||
custom_fields=[
|
||||
CustomField.from_json(field) for field in json['customFields']
|
||||
],
|
||||
archived=json['archived'],
|
||||
attachments=json['attachments'], # TODO
|
||||
)
|
||||
|
||||
|
|
|
@ -58,6 +58,37 @@ class CardFileSystemItem(FileSystemItem):
|
|||
seq_id: SeqId
|
||||
|
||||
|
||||
def to_card_contents(card: Card, favro_client: FavroClient) -> str:
|
||||
tags = [favro_client.get_tag(tag_id).name for tag_id in card.tags]
|
||||
assignments = [
|
||||
favro_client.get_user(assignment.user).name
|
||||
for assignment in card.assignments
|
||||
]
|
||||
dependencies = [
|
||||
CARD_FILENAME_FORMAT.format(
|
||||
seq_id=favro_client.get_card_by_card_id(dep.card_id).seq_id.raw_id,
|
||||
)
|
||||
for dep in card.dependencies
|
||||
if dep.is_before
|
||||
]
|
||||
return CardContents(
|
||||
CARD_IDENTIFIER_FORMAT.format(seq_id=card.seq_id.raw_id),
|
||||
card.name,
|
||||
card.detailed_description,
|
||||
tags,
|
||||
assignments,
|
||||
dependencies,
|
||||
url=OFFICIAL_URL.format(
|
||||
org_id=card.organization_id.raw_id,
|
||||
seq_id=card.seq_id.raw_id,
|
||||
),
|
||||
todo_list_completed=card.todo_list_completed,
|
||||
is_archived=card.is_archived,
|
||||
start_date=card.start_date,
|
||||
due_date=card.due_date,
|
||||
)
|
||||
|
||||
|
||||
class FavroFuse(fuse.Fuse):
|
||||
"""Favro FileSystem in Userspace."""
|
||||
|
||||
|
@ -176,35 +207,7 @@ class FavroFuse(fuse.Fuse):
|
|||
def _format_card_file(self, card: Card) -> str:
|
||||
if card.seq_id in self.wiped_cards:
|
||||
return ''
|
||||
|
||||
tags = [self.favro_client.get_tag(tag_id).name for tag_id in card.tags]
|
||||
assignments = [
|
||||
self.favro_client.get_user(assignment.user).name
|
||||
for assignment in card.assignments
|
||||
]
|
||||
dependencies = [
|
||||
CARD_FILENAME_FORMAT.format(
|
||||
seq_id=self.favro_client.get_card_by_card_id(dep.card_id).seq_id.raw_id,
|
||||
)
|
||||
for dep in card.dependencies
|
||||
if dep.is_before
|
||||
]
|
||||
card_contents = CardContents(
|
||||
CARD_IDENTIFIER_FORMAT.format(seq_id=card.seq_id.raw_id),
|
||||
card.name,
|
||||
card.detailed_description,
|
||||
tags,
|
||||
assignments,
|
||||
dependencies,
|
||||
url=OFFICIAL_URL.format(
|
||||
org_id=card.organization_id.raw_id,
|
||||
seq_id=card.seq_id.raw_id,
|
||||
),
|
||||
todo_list_completed=card.todo_list_completed,
|
||||
archived=card.archived,
|
||||
start_date=card.start_date,
|
||||
due_date=card.due_date,
|
||||
)
|
||||
card_contents = to_card_contents(card, self.favro_client)
|
||||
return self.formatter.format_card_contents(card_contents)
|
||||
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class CardContents:
|
|||
card_dependencies: list[str]
|
||||
url: str
|
||||
todo_list_completed: bool | None
|
||||
archived: bool
|
||||
is_archived: bool
|
||||
start_date: datetime.date | None
|
||||
due_date: datetime.date | None
|
||||
|
||||
|
@ -95,8 +95,8 @@ class CardFileFormatter:
|
|||
]
|
||||
if card.todo_list_completed is not None:
|
||||
frontmatter_data[FM_KEY_TODO_LIST_COMPLETED] = card.todo_list_completed
|
||||
if card.archived is not None:
|
||||
frontmatter_data[FM_KEY_ARCHIVED] = card.archived
|
||||
if card.is_archived is not None:
|
||||
frontmatter_data[FM_KEY_ARCHIVED] = card.is_archived
|
||||
if card.due_date is not None:
|
||||
frontmatter_data[FM_KEY_DUE_DATE] = card.due_date
|
||||
if card.start_date is not None:
|
||||
|
@ -152,7 +152,7 @@ class CardFileFormatter:
|
|||
|
||||
url: list[str] = fm.metadata.get(FM_KEY_URL)
|
||||
todo_list_completed: bool | None = fm.metadata.get(FM_KEY_TODO_LIST_COMPLETED)
|
||||
archived: bool = fm.metadata.get(FM_KEY_ARCHIVED)
|
||||
is_archived: bool = fm.metadata.get(FM_KEY_ARCHIVED)
|
||||
|
||||
start_date: datetime.date = fm.metadata.get(FM_KEY_START_DATE)
|
||||
due_date: datetime.date = fm.metadata.get(FM_KEY_DUE_DATE)
|
||||
|
@ -167,7 +167,7 @@ class CardFileFormatter:
|
|||
card_dependencies=card_dependencies,
|
||||
url=url,
|
||||
todo_list_completed=todo_list_completed,
|
||||
archived=archived,
|
||||
is_archived=is_archived,
|
||||
start_date=start_date,
|
||||
due_date=due_date,
|
||||
)
|
||||
|
|
|
@ -29,6 +29,13 @@ def test_get_card():
|
|||
assert len(card.custom_fields) == 2
|
||||
|
||||
|
||||
@needs_secrets
|
||||
def test_get_archived_card():
|
||||
client = create_client()
|
||||
card = client.get_card(SeqId(8723))
|
||||
assert card.is_archived
|
||||
|
||||
|
||||
@needs_secrets
|
||||
def test_get_cards():
|
||||
client = create_client()
|
||||
|
@ -48,3 +55,4 @@ def create_client():
|
|||
def assert_valid_card(card):
|
||||
assert card is not None
|
||||
assert card.name is not None
|
||||
assert card.is_archived is not None
|
||||
|
|
Loading…
Reference in New Issue
Block a user