mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 04:23:46 +00:00
python: Reformat with Black, except quotes.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
5028c081cb
commit
11741543da
@@ -11,8 +11,10 @@ def user_attachments(user_profile: UserProfile) -> List[Dict[str, Any]]:
|
||||
attachments = Attachment.objects.filter(owner=user_profile).prefetch_related('messages')
|
||||
return [a.to_dict() for a in attachments]
|
||||
|
||||
def access_attachment_by_id(user_profile: UserProfile, attachment_id: int,
|
||||
needs_owner: bool=False) -> Attachment:
|
||||
|
||||
def access_attachment_by_id(
|
||||
user_profile: UserProfile, attachment_id: int, needs_owner: bool = False
|
||||
) -> Attachment:
|
||||
query = Attachment.objects.filter(id=attachment_id)
|
||||
if needs_owner:
|
||||
query = query.filter(owner=user_profile)
|
||||
@@ -22,9 +24,12 @@ def access_attachment_by_id(user_profile: UserProfile, attachment_id: int,
|
||||
raise JsonableError(_("Invalid attachment"))
|
||||
return attachment
|
||||
|
||||
|
||||
def remove_attachment(user_profile: UserProfile, attachment: Attachment) -> None:
|
||||
try:
|
||||
delete_message_image(attachment.path_id)
|
||||
except Exception:
|
||||
raise JsonableError(_("An error occurred while deleting the attachment. Please try again later."))
|
||||
raise JsonableError(
|
||||
_("An error occurred while deleting the attachment. Please try again later.")
|
||||
)
|
||||
attachment.delete()
|
||||
|
||||
Reference in New Issue
Block a user