mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-15 19:45:46 +00:00
Optionally exclude session information when exporting data (#9763)
* Optionally exclude session information when exporting data * Add sessions.session table
This commit is contained in:
10
tasks.py
10
tasks.py
@ -274,6 +274,7 @@ def content_excludes(
|
|||||||
allow_tokens: bool = True,
|
allow_tokens: bool = True,
|
||||||
allow_plugins: bool = True,
|
allow_plugins: bool = True,
|
||||||
allow_sso: bool = True,
|
allow_sso: bool = True,
|
||||||
|
allow_session: bool = True,
|
||||||
):
|
):
|
||||||
"""Returns a list of content types to exclude from import / export.
|
"""Returns a list of content types to exclude from import / export.
|
||||||
|
|
||||||
@ -282,6 +283,7 @@ def content_excludes(
|
|||||||
allow_tokens (bool): Allow tokens to be exported / imported
|
allow_tokens (bool): Allow tokens to be exported / imported
|
||||||
allow_plugins (bool): Allow plugin information to be exported / imported
|
allow_plugins (bool): Allow plugin information to be exported / imported
|
||||||
allow_sso (bool): Allow SSO tokens to be exported / imported
|
allow_sso (bool): Allow SSO tokens to be exported / imported
|
||||||
|
allow_session (bool): Allow user session data to be exported / imported
|
||||||
"""
|
"""
|
||||||
excludes = [
|
excludes = [
|
||||||
'contenttypes',
|
'contenttypes',
|
||||||
@ -320,6 +322,11 @@ def content_excludes(
|
|||||||
excludes.append('socialaccount.socialapp')
|
excludes.append('socialaccount.socialapp')
|
||||||
excludes.append('socialaccount.socialtoken')
|
excludes.append('socialaccount.socialtoken')
|
||||||
|
|
||||||
|
# Optionally exclude user session information
|
||||||
|
if not allow_session:
|
||||||
|
excludes.append('sessions.session')
|
||||||
|
excludes.append('usersessions.usersession')
|
||||||
|
|
||||||
return ' '.join([f'--exclude {e}' for e in excludes])
|
return ' '.join([f'--exclude {e}' for e in excludes])
|
||||||
|
|
||||||
|
|
||||||
@ -829,6 +836,7 @@ def update(
|
|||||||
'include_tokens': 'Include API tokens in the output file (default = False)',
|
'include_tokens': 'Include API tokens in the output file (default = False)',
|
||||||
'exclude_plugins': 'Exclude plugin data from the output file (default = False)',
|
'exclude_plugins': 'Exclude plugin data from the output file (default = False)',
|
||||||
'include_sso': 'Include SSO token data in the output file (default = False)',
|
'include_sso': 'Include SSO token data in the output file (default = False)',
|
||||||
|
'include_session': 'Include user session data in the output file (default = False)',
|
||||||
'retain_temp': 'Retain temporary files (containing permissions) at end of process (default = False)',
|
'retain_temp': 'Retain temporary files (containing permissions) at end of process (default = False)',
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -840,6 +848,7 @@ def export_records(
|
|||||||
include_tokens=False,
|
include_tokens=False,
|
||||||
exclude_plugins=False,
|
exclude_plugins=False,
|
||||||
include_sso=False,
|
include_sso=False,
|
||||||
|
include_session=False,
|
||||||
retain_temp=False,
|
retain_temp=False,
|
||||||
):
|
):
|
||||||
"""Export all database records to a file.
|
"""Export all database records to a file.
|
||||||
@ -873,6 +882,7 @@ def export_records(
|
|||||||
excludes = content_excludes(
|
excludes = content_excludes(
|
||||||
allow_tokens=include_tokens,
|
allow_tokens=include_tokens,
|
||||||
allow_plugins=not exclude_plugins,
|
allow_plugins=not exclude_plugins,
|
||||||
|
allow_session=include_session,
|
||||||
allow_sso=include_sso,
|
allow_sso=include_sso,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user