mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	data exports: Keep deleted export in UI table.
It makes sense to keep a deleted export in the table, along with the time of deletion, for auditing reasons.
This commit is contained in:
		@@ -29,28 +29,34 @@ exports.populate_exports_table = function (exports) {
 | 
			
		||||
        name: "admin_exports_list",
 | 
			
		||||
        modifier: function (data) {
 | 
			
		||||
            let failed_timestamp = data.failed_timestamp;
 | 
			
		||||
            let deleted_timestamp = data.deleted_timestamp;
 | 
			
		||||
 | 
			
		||||
            if (failed_timestamp !== null) {
 | 
			
		||||
                failed_timestamp = timerender.last_seen_status_from_date(
 | 
			
		||||
                    new XDate(failed_timestamp * 1000)
 | 
			
		||||
                );
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (data.deleted_timestamp === null) {
 | 
			
		||||
                return render_admin_export_list({
 | 
			
		||||
                    realm_export: {
 | 
			
		||||
                        id: data.id,
 | 
			
		||||
                        acting_user: people.get_full_name(data.acting_user_id),
 | 
			
		||||
                        // Convert seconds -> milliseconds
 | 
			
		||||
                        event_time: timerender.last_seen_status_from_date(
 | 
			
		||||
                            new XDate(data.export_time * 1000)
 | 
			
		||||
                        ),
 | 
			
		||||
                        url: data.export_url,
 | 
			
		||||
                        time_failed: failed_timestamp,
 | 
			
		||||
                        pending: data.pending,
 | 
			
		||||
                    },
 | 
			
		||||
                });
 | 
			
		||||
            if (deleted_timestamp !== null) {
 | 
			
		||||
                deleted_timestamp = timerender.last_seen_status_from_date(
 | 
			
		||||
                    new XDate(deleted_timestamp * 1000)
 | 
			
		||||
                );
 | 
			
		||||
            }
 | 
			
		||||
            return "";
 | 
			
		||||
 | 
			
		||||
            return render_admin_export_list({
 | 
			
		||||
                realm_export: {
 | 
			
		||||
                    id: data.id,
 | 
			
		||||
                    acting_user: people.get_full_name(data.acting_user_id),
 | 
			
		||||
                    // Convert seconds -> milliseconds
 | 
			
		||||
                    event_time: timerender.last_seen_status_from_date(
 | 
			
		||||
                        new XDate(data.export_time * 1000)
 | 
			
		||||
                    ),
 | 
			
		||||
                    url: data.export_url,
 | 
			
		||||
                    time_failed: failed_timestamp,
 | 
			
		||||
                    pending: data.pending,
 | 
			
		||||
                    time_deleted: deleted_timestamp,
 | 
			
		||||
                },
 | 
			
		||||
            });
 | 
			
		||||
        },
 | 
			
		||||
        filter: {
 | 
			
		||||
            element: exports_table.closest(".settings-section").find(".search"),
 | 
			
		||||
 
 | 
			
		||||
@@ -13,12 +13,16 @@
 | 
			
		||||
        <span class="export_status">{{t 'Failed' }}: {{time_failed}}</span>
 | 
			
		||||
        {{else if pending}}
 | 
			
		||||
        <div class="export_url_spinner"></div>
 | 
			
		||||
        {{else if time_deleted}}
 | 
			
		||||
        <span class="export_status">{{t 'Deleted' }}: {{time_deleted}}</span>
 | 
			
		||||
        {{/if}}
 | 
			
		||||
    </td>
 | 
			
		||||
    <td class="actions">
 | 
			
		||||
        {{#unless time_deleted}}
 | 
			
		||||
        <button class="button rounded small delete btn-danger" data-export-id="{{id}}">
 | 
			
		||||
            <i class="fa fa-trash-o" aria-hidden="true"></i>
 | 
			
		||||
        </button>
 | 
			
		||||
        {{/unless}}
 | 
			
		||||
    </td>
 | 
			
		||||
</tr>
 | 
			
		||||
{{/with}}
 | 
			
		||||
 
 | 
			
		||||
@@ -1776,7 +1776,7 @@ def get_realm_exports_serialized(user: UserProfile) -> List[Dict[str, Any]]:
 | 
			
		||||
            failed_timestamp = export_data.get('failed_timestamp')
 | 
			
		||||
            export_path = export_data.get('export_path')
 | 
			
		||||
 | 
			
		||||
            if export_path:
 | 
			
		||||
            if export_path and not deleted_timestamp:
 | 
			
		||||
                export_url = zerver.lib.upload.upload_backend.get_export_tarball_url(
 | 
			
		||||
                    user.realm, export_path)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2864,7 +2864,7 @@ class EventsRegisterTest(ZulipTestCase):
 | 
			
		||||
                ('id', check_int),
 | 
			
		||||
                ('export_time', check_float),
 | 
			
		||||
                ('acting_user_id', check_int),
 | 
			
		||||
                ('export_url', check_string),
 | 
			
		||||
                ('export_url', equals(None)),
 | 
			
		||||
                ('deleted_timestamp', check_float),
 | 
			
		||||
                ('failed_timestamp', equals(None)),
 | 
			
		||||
                ('pending', check_bool),
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user