fix: show attachment log in activity
This commit is contained in:
parent
3a750494b9
commit
3c7ba5e079
@ -1,5 +1,6 @@
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.utils.caching import redis_cache
|
from frappe.utils.caching import redis_cache
|
||||||
@ -132,6 +133,17 @@ def get_deal_activities(name):
|
|||||||
}
|
}
|
||||||
activities.append(activity)
|
activities.append(activity)
|
||||||
|
|
||||||
|
for attachment_log in docinfo.attachment_logs:
|
||||||
|
activity = {
|
||||||
|
"name": attachment_log.name,
|
||||||
|
"activity_type": "attachment_log",
|
||||||
|
"creation": attachment_log.creation,
|
||||||
|
"owner": attachment_log.owner,
|
||||||
|
"data": parse_attachment_log(attachment_log.content, attachment_log.comment_type),
|
||||||
|
"is_lead": False,
|
||||||
|
}
|
||||||
|
activities.append(activity)
|
||||||
|
|
||||||
calls = calls + get_linked_calls(name)
|
calls = calls + get_linked_calls(name)
|
||||||
notes = notes + get_linked_notes(name)
|
notes = notes + get_linked_notes(name)
|
||||||
tasks = tasks + get_linked_tasks(name)
|
tasks = tasks + get_linked_tasks(name)
|
||||||
@ -247,6 +259,17 @@ def get_lead_activities(name):
|
|||||||
}
|
}
|
||||||
activities.append(activity)
|
activities.append(activity)
|
||||||
|
|
||||||
|
for attachment_log in docinfo.attachment_logs:
|
||||||
|
activity = {
|
||||||
|
"name": attachment_log.name,
|
||||||
|
"activity_type": "attachment_log",
|
||||||
|
"creation": attachment_log.creation,
|
||||||
|
"owner": attachment_log.owner,
|
||||||
|
"data": parse_attachment_log(attachment_log.content, attachment_log.comment_type),
|
||||||
|
"is_lead": True,
|
||||||
|
}
|
||||||
|
activities.append(activity)
|
||||||
|
|
||||||
calls = get_linked_calls(name)
|
calls = get_linked_calls(name)
|
||||||
notes = get_linked_notes(name)
|
notes = get_linked_notes(name)
|
||||||
tasks = get_linked_tasks(name)
|
tasks = get_linked_tasks(name)
|
||||||
@ -345,3 +368,26 @@ def get_linked_tasks(name):
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
return tasks or []
|
return tasks or []
|
||||||
|
|
||||||
|
def parse_attachment_log(html, type):
|
||||||
|
soup = BeautifulSoup(html, "html.parser")
|
||||||
|
a_tag = soup.find("a")
|
||||||
|
type = "added" if type == "Attachment" else "removed"
|
||||||
|
if not a_tag:
|
||||||
|
return {
|
||||||
|
"type": type,
|
||||||
|
"file_name": html.replace("Removed ", ""),
|
||||||
|
"file_url": "",
|
||||||
|
"is_private": False,
|
||||||
|
}
|
||||||
|
|
||||||
|
is_private = False
|
||||||
|
if "private/files" in a_tag["href"]:
|
||||||
|
is_private = True
|
||||||
|
|
||||||
|
return {
|
||||||
|
"type": type,
|
||||||
|
"file_name": a_tag.text,
|
||||||
|
"file_url": a_tag["href"],
|
||||||
|
"is_private": is_private,
|
||||||
|
}
|
||||||
@ -192,6 +192,40 @@
|
|||||||
>
|
>
|
||||||
<CommentArea :activity="activity" />
|
<CommentArea :activity="activity" />
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
|
class="mb-4 flex flex-col gap-2 py-1.5"
|
||||||
|
:id="activity.name"
|
||||||
|
v-else-if="activity.activity_type == 'attachment_log'"
|
||||||
|
>
|
||||||
|
<div class="flex items-center justify-stretch gap-2 text-base">
|
||||||
|
<div
|
||||||
|
class="inline-flex items-center flex-wrap gap-1.5 text-gray-800 font-medium"
|
||||||
|
>
|
||||||
|
<span class="font-medium">{{ activity.owner_name }}</span>
|
||||||
|
<span class="text-gray-600">{{ __(activity.data.type) }}</span>
|
||||||
|
<a
|
||||||
|
v-if="activity.data.file_url"
|
||||||
|
:href="activity.data.file_url"
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
|
<span>{{ activity.data.file_name }}</span>
|
||||||
|
</a>
|
||||||
|
<span v-else>{{ activity.data.file_name }}</span>
|
||||||
|
<FeatherIcon
|
||||||
|
v-if="activity.data.is_private"
|
||||||
|
name="lock"
|
||||||
|
class="size-3"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="ml-auto whitespace-nowrap">
|
||||||
|
<Tooltip :text="dateFormat(activity.creation, dateTooltipFormat)">
|
||||||
|
<div class="text-sm text-gray-600">
|
||||||
|
{{ __(timeAgo(activity.creation)) }}
|
||||||
|
</div>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div
|
<div
|
||||||
v-else-if="
|
v-else-if="
|
||||||
activity.activity_type == 'incoming_call' ||
|
activity.activity_type == 'incoming_call' ||
|
||||||
@ -747,6 +781,9 @@ function timelineIcon(activity_type, is_lead) {
|
|||||||
case 'outgoing_call':
|
case 'outgoing_call':
|
||||||
icon = OutboundCallIcon
|
icon = OutboundCallIcon
|
||||||
break
|
break
|
||||||
|
case 'attachment_log':
|
||||||
|
icon = AttachmentIcon
|
||||||
|
break
|
||||||
default:
|
default:
|
||||||
icon = DotIcon
|
icon = DotIcon
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user