mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-19 18:29:23 +00:00
deleted files notice (#5426)
* batch delete files notice * frontend page
This commit is contained in:
@@ -20,6 +20,7 @@ const MSG_TYPE_DRAFT_COMMENT = 'draft_comment';
|
|||||||
const MSG_TYPE_DRAFT_REVIEWER = 'draft_reviewer';
|
const MSG_TYPE_DRAFT_REVIEWER = 'draft_reviewer';
|
||||||
const MSG_TYPE_GUEST_INVITATION_ACCEPTED = 'guest_invitation_accepted';
|
const MSG_TYPE_GUEST_INVITATION_ACCEPTED = 'guest_invitation_accepted';
|
||||||
const MSG_TYPE_REPO_MONITOR = 'repo_monitor';
|
const MSG_TYPE_REPO_MONITOR = 'repo_monitor';
|
||||||
|
const MSG_TYPE_DELETED_FILES = 'deleted_files';
|
||||||
|
|
||||||
class NoticeItem extends React.Component {
|
class NoticeItem extends React.Component {
|
||||||
|
|
||||||
@@ -307,6 +308,21 @@ class NoticeItem extends React.Component {
|
|||||||
return { avatar_url, notice };
|
return { avatar_url, notice };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (noticeType === MSG_TYPE_DELETED_FILES) {
|
||||||
|
const {
|
||||||
|
repo_id,
|
||||||
|
repo_name,
|
||||||
|
} = detail;
|
||||||
|
|
||||||
|
const repoURL = `${siteRoot}library/${repo_id}/${encodeURIComponent(repo_name)}/`;
|
||||||
|
const repoLink = `<a href=${repoURL} target="_blank">${Utils.HTMLescape(repo_name)}</a>`;
|
||||||
|
|
||||||
|
let notice = gettext('Your library {libraryName} has recently deleted a large number of files.');
|
||||||
|
notice = notice.replace('{libraryName}', repoLink);
|
||||||
|
|
||||||
|
return { avatar_url : null, notice };
|
||||||
|
}
|
||||||
|
|
||||||
// if (noticeType === MSG_TYPE_GUEST_INVITATION_ACCEPTED) {
|
// if (noticeType === MSG_TYPE_GUEST_INVITATION_ACCEPTED) {
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
@@ -75,6 +75,7 @@ MSG_TYPE_DRAFT_REVIEWER = 'draft_reviewer'
|
|||||||
MSG_TYPE_GUEST_INVITATION_ACCEPTED = 'guest_invitation_accepted'
|
MSG_TYPE_GUEST_INVITATION_ACCEPTED = 'guest_invitation_accepted'
|
||||||
MSG_TYPE_REPO_TRANSFER = 'repo_transfer'
|
MSG_TYPE_REPO_TRANSFER = 'repo_transfer'
|
||||||
MSG_TYPE_REPO_MINOTOR = 'repo_monitor'
|
MSG_TYPE_REPO_MINOTOR = 'repo_monitor'
|
||||||
|
MSG_TYPE_DELETED_FILES = 'deleted_files'
|
||||||
|
|
||||||
USER_NOTIFICATION_COUNT_CACHE_PREFIX = 'USER_NOTIFICATION_COUNT_'
|
USER_NOTIFICATION_COUNT_CACHE_PREFIX = 'USER_NOTIFICATION_COUNT_'
|
||||||
|
|
||||||
@@ -407,6 +408,9 @@ class UserNotification(models.Model):
|
|||||||
def is_repo_monitor_msg(self):
|
def is_repo_monitor_msg(self):
|
||||||
return self.msg_type == MSG_TYPE_REPO_MINOTOR
|
return self.msg_type == MSG_TYPE_REPO_MINOTOR
|
||||||
|
|
||||||
|
def is_deleted_files_msg(self):
|
||||||
|
return self.msg_type == MSG_TYPE_DELETED_FILES
|
||||||
|
|
||||||
def user_message_detail_to_dict(self):
|
def user_message_detail_to_dict(self):
|
||||||
"""Parse user message detail, returns dict contains ``message`` and
|
"""Parse user message detail, returns dict contains ``message`` and
|
||||||
``msg_from``.
|
``msg_from``.
|
||||||
|
@@ -247,4 +247,22 @@ def update_notice_detail(request, notices):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
|
|
||||||
|
elif notice.is_deleted_files_msg():
|
||||||
|
try:
|
||||||
|
d = json.loads(notice.detail)
|
||||||
|
repo_id = d['repo_id']
|
||||||
|
if repo_id in repo_dict:
|
||||||
|
repo = repo_dict[repo_id]
|
||||||
|
else:
|
||||||
|
repo = seafile_api.get_repo(repo_id)
|
||||||
|
repo_dict[repo_id] = repo
|
||||||
|
|
||||||
|
if repo:
|
||||||
|
d['repo_name'] = repo.name
|
||||||
|
notice.detail = d
|
||||||
|
else:
|
||||||
|
notice.detail = None
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(e)
|
||||||
|
|
||||||
return notices
|
return notices
|
||||||
|
Reference in New Issue
Block a user