mirror of
https://github.com/inventree/InvenTree.git
synced 2026-10-14 22:20:59 +00:00
fix style nitpicks (#12995)
* disable restriction (for now) * reduce duplication * remove duplication in scim view * fix diff * fix reassign * remove statment that is always wrong * log with full context * allign order to anguage defaults * adress shelldre:S7688
This commit is contained in:
1 parent
600dc1a75b
commit
104adebbf4
13 files changed
+94
-111
No files matched your search
@@ -296,10 +296,6 @@ def main() -> bool:
|
|||||||
print('GITHUB_REF:', GITHUB_REF)
|
print('GITHUB_REF:', GITHUB_REF)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if docker_tags is None:
|
|
||||||
print('Docker tags could not be determined')
|
|
||||||
return False
|
|
||||||
|
|
||||||
print(f"Version check passed for '{inventree_version}'!")
|
print(f"Version check passed for '{inventree_version}'!")
|
||||||
print(f"Docker tags: '{docker_tags}'")
|
print(f"Docker tags: '{docker_tags}'")
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ if [[ ! -d "$INVENTREE_BACKUP_DIR" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if "config.yaml" has been copied into the correct location
|
# Check if "config.yaml" has been copied into the correct location
|
||||||
if test -f "$INVENTREE_CONFIG_FILE"; then
|
if [[ -f "$INVENTREE_CONFIG_FILE" ]]; then
|
||||||
echo "Loading config file : $INVENTREE_CONFIG_FILE"
|
echo "Loading config file : $INVENTREE_CONFIG_FILE"
|
||||||
else
|
else
|
||||||
echo "Copying config file from $INVENTREE_BACKEND_DIR/InvenTree/config_template.yml to $INVENTREE_CONFIG_FILE"
|
echo "Copying config file from $INVENTREE_BACKEND_DIR/InvenTree/config_template.yml to $INVENTREE_CONFIG_FILE"
|
||||||
@@ -37,7 +37,7 @@ fi
|
|||||||
# so that the installed modules persist!
|
# so that the installed modules persist!
|
||||||
if [[ -n "$INVENTREE_PY_ENV" ]]; then
|
if [[ -n "$INVENTREE_PY_ENV" ]]; then
|
||||||
|
|
||||||
if test -d "$INVENTREE_PY_ENV"; then
|
if [[ -d "$INVENTREE_PY_ENV" ]]; then
|
||||||
# venv already exists
|
# venv already exists
|
||||||
echo "Using Python virtual environment: ${INVENTREE_PY_ENV}"
|
echo "Using Python virtual environment: ${INVENTREE_PY_ENV}"
|
||||||
source ${INVENTREE_PY_ENV}/bin/activate
|
source ${INVENTREE_PY_ENV}/bin/activate
|
||||||
|
|||||||
+5
-5
@@ -26,23 +26,23 @@ root_command() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function get_distribution {
|
function get_distribution {
|
||||||
if [ -f /etc/os-release ]; then
|
if [[ -f /etc/os-release ]]; then
|
||||||
. /etc/os-release
|
. /etc/os-release
|
||||||
OS=$NAME
|
OS=$NAME
|
||||||
VER=$VERSION_ID
|
VER=$VERSION_ID
|
||||||
elif type lsb_release >/dev/null 2>&1; then
|
elif type lsb_release >/dev/null 2>&1; then
|
||||||
OS=$(lsb_release -si)
|
OS=$(lsb_release -si)
|
||||||
VER=$(lsb_release -sr)
|
VER=$(lsb_release -sr)
|
||||||
elif [ -f /etc/lsb-release ]; then
|
elif [[ -f /etc/lsb-release ]]; then
|
||||||
. /etc/lsb-release
|
. /etc/lsb-release
|
||||||
OS=$DISTRIB_ID
|
OS=$DISTRIB_ID
|
||||||
VER=$DISTRIB_RELEASE
|
VER=$DISTRIB_RELEASE
|
||||||
elif [ -f /etc/debian_version ]; then
|
elif [[ -f /etc/debian_version ]]; then
|
||||||
OS=Debian
|
OS=Debian
|
||||||
VER=$(cat /etc/debian_version)
|
VER=$(cat /etc/debian_version)
|
||||||
elif [ -f /etc/SuSe-release ]; then
|
elif [[ -f /etc/SuSe-release ]]; then
|
||||||
OS=SEL
|
OS=SEL
|
||||||
elif [ -f /etc/redhat-release ]; then
|
elif [[ -f /etc/redhat-release ]]; then
|
||||||
OS=RedHat
|
OS=RedHat
|
||||||
else
|
else
|
||||||
OS=$(uname -s)
|
OS=$(uname -s)
|
||||||
|
|||||||
@@ -16,23 +16,23 @@ function do_call() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function get_distribution {
|
function get_distribution {
|
||||||
if [ -f /etc/os-release ]; then
|
if [[ -f /etc/os-release ]]; then
|
||||||
. /etc/os-release
|
. /etc/os-release
|
||||||
OS=$NAME
|
OS=$NAME
|
||||||
VER=$VERSION_ID
|
VER=$VERSION_ID
|
||||||
elif type lsb_release >/dev/null 2>&1; then
|
elif type lsb_release >/dev/null 2>&1; then
|
||||||
OS=$(lsb_release -si)
|
OS=$(lsb_release -si)
|
||||||
VER=$(lsb_release -sr)
|
VER=$(lsb_release -sr)
|
||||||
elif [ -f /etc/lsb-release ]; then
|
elif [[ -f /etc/lsb-release ]]; then
|
||||||
. /etc/lsb-release
|
. /etc/lsb-release
|
||||||
OS=$DISTRIB_ID
|
OS=$DISTRIB_ID
|
||||||
VER=$DISTRIB_RELEASE
|
VER=$DISTRIB_RELEASE
|
||||||
elif [ -f /etc/debian_version ]; then
|
elif [[ -f /etc/debian_version ]]; then
|
||||||
OS=Debian
|
OS=Debian
|
||||||
VER=$(cat /etc/debian_version)
|
VER=$(cat /etc/debian_version)
|
||||||
elif [ -f /etc/SuSe-release ]; then
|
elif [[ -f /etc/SuSe-release ]]; then
|
||||||
OS=SEL
|
OS=SEL
|
||||||
elif [ -f /etc/redhat-release ]; then
|
elif [[ -f /etc/redhat-release ]]; then
|
||||||
OS=RedHat
|
OS=RedHat
|
||||||
else
|
else
|
||||||
OS=$(uname -s)
|
OS=$(uname -s)
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ echo "### VERSION ###"
|
|||||||
echo "INFO frontend | Trying to get frontend"
|
echo "INFO frontend | Trying to get frontend"
|
||||||
# Check if tag sha is the same as the commit sha
|
# Check if tag sha is the same as the commit sha
|
||||||
TAG_SHA=$(jq -r '.sha' tag.json)
|
TAG_SHA=$(jq -r '.sha' tag.json)
|
||||||
if [ "$TAG_SHA" != "$FULL_SHA" ]; then
|
if [[ "$TAG_SHA" != "$FULL_SHA" ]]; then
|
||||||
echo "INFO frontend | Tag sha '$TAG_SHA' is not the same as commit sha $FULL_SHA, can not download frontend"
|
echo "INFO frontend | Tag sha '$TAG_SHA' is not the same as commit sha $FULL_SHA, can not download frontend"
|
||||||
else
|
else
|
||||||
echo "INFO frontend | Getting frontend from github via tag"
|
echo "INFO frontend | Getting frontend from github via tag"
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ PYTHON_FROM=11
|
|||||||
PYTHON_TO=15
|
PYTHON_TO=15
|
||||||
|
|
||||||
function detect_docker() {
|
function detect_docker() {
|
||||||
if [ -n "$(grep docker </proc/1/cgroup)" ]; then
|
if [[ -n "$(grep docker </proc/1/cgroup)" ]]; then
|
||||||
DOCKER="yes"
|
DOCKER="yes"
|
||||||
else
|
else
|
||||||
DOCKER="no"
|
DOCKER="no"
|
||||||
@@ -17,9 +17,9 @@ function detect_docker() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function detect_initcmd() {
|
function detect_initcmd() {
|
||||||
if [ -n "$(which systemctl 2>/dev/null)" ]; then
|
if [[ -n "$(which systemctl 2>/dev/null)" ]]; then
|
||||||
INIT_CMD="systemctl"
|
INIT_CMD="systemctl"
|
||||||
elif [ -n "$(which initctl 2>/dev/null)" ]; then
|
elif [[ -n "$(which initctl 2>/dev/null)" ]]; then
|
||||||
INIT_CMD="initctl"
|
INIT_CMD="initctl"
|
||||||
else
|
else
|
||||||
function sysvinit() {
|
function sysvinit() {
|
||||||
@@ -28,7 +28,7 @@ function detect_initcmd() {
|
|||||||
INIT_CMD="sysvinit"
|
INIT_CMD="sysvinit"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${DOCKER}" == "yes" ]; then
|
if [[ "${DOCKER}" == "yes" ]]; then
|
||||||
INIT_CMD="initctl"
|
INIT_CMD="initctl"
|
||||||
fi
|
fi
|
||||||
echo "# POI05| Using init command: ${INIT_CMD}"
|
echo "# POI05| Using init command: ${INIT_CMD}"
|
||||||
@@ -37,7 +37,7 @@ function detect_initcmd() {
|
|||||||
function detect_ip() {
|
function detect_ip() {
|
||||||
# Get the IP address of the server
|
# Get the IP address of the server
|
||||||
|
|
||||||
if [ "${SETUP_NO_CALLS}" == "true" ]; then
|
if [[ "${SETUP_NO_CALLS}" == "true" ]]; then
|
||||||
# Use local IP address
|
# Use local IP address
|
||||||
echo "# POI06| Getting the IP address of the first local IP address"
|
echo "# POI06| Getting the IP address of the first local IP address"
|
||||||
export INVENTREE_IP=$(hostname -I | awk '{print $1}')
|
export INVENTREE_IP=$(hostname -I | awk '{print $1}')
|
||||||
@@ -52,7 +52,7 @@ function detect_ip() {
|
|||||||
|
|
||||||
function detect_python() {
|
function detect_python() {
|
||||||
# Detect if there is already a python version installed in /opt/inventree/env/lib
|
# Detect if there is already a python version installed in /opt/inventree/env/lib
|
||||||
if test -f "${APP_HOME}/env/bin/python"; then
|
if [[ -f "${APP_HOME}/env/bin/python" ]]; then
|
||||||
echo "# POI07| Python environment already present"
|
echo "# POI07| Python environment already present"
|
||||||
# Extract earliest python version initialised from /opt/inventree/env/lib
|
# Extract earliest python version initialised from /opt/inventree/env/lib
|
||||||
SETUP_PYTHON=$(ls -1 ${APP_HOME}/env/bin/python* | sort | head -n 1)
|
SETUP_PYTHON=$(ls -1 ${APP_HOME}/env/bin/python* | sort | head -n 1)
|
||||||
@@ -62,11 +62,11 @@ function detect_python() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Try to detect a python between lowest and highest supported in reverse order
|
# Try to detect a python between lowest and highest supported in reverse order
|
||||||
if [ -z "$(which ${SETUP_PYTHON})" ]; then
|
if [[ -z "$(which ${SETUP_PYTHON})" ]]; then
|
||||||
echo "# POI07| Trying to detecting python3.${PYTHON_FROM} to python3.${PYTHON_TO} - using newest version"
|
echo "# POI07| Trying to detecting python3.${PYTHON_FROM} to python3.${PYTHON_TO} - using newest version"
|
||||||
for i in $(seq $PYTHON_TO -1 $PYTHON_FROM); do
|
for i in $(seq $PYTHON_TO -1 $PYTHON_FROM); do
|
||||||
echo "# POI07| Checking for python3.${i}"
|
echo "# POI07| Checking for python3.${i}"
|
||||||
if [ -n "$(which python3.${i})" ]; then
|
if [[ -n "$(which python3.${i})" ]]; then
|
||||||
SETUP_PYTHON="python3.${i}"
|
SETUP_PYTHON="python3.${i}"
|
||||||
echo "# POI07| Found python3.${i} installed - using for setup ${SETUP_PYTHON}"
|
echo "# POI07| Found python3.${i} installed - using for setup ${SETUP_PYTHON}"
|
||||||
break
|
break
|
||||||
@@ -75,7 +75,7 @@ function detect_python() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Ensure python can be executed - abort if not
|
# Ensure python can be executed - abort if not
|
||||||
if [ -z "$(which ${SETUP_PYTHON})" ]; then
|
if [[ -z "$(which ${SETUP_PYTHON})" ]]; then
|
||||||
echo "${On_Red}"
|
echo "${On_Red}"
|
||||||
echo "# POI07| Python ${SETUP_PYTHON} not found - aborting!"
|
echo "# POI07| Python ${SETUP_PYTHON} not found - aborting!"
|
||||||
echo "# POI07| Please ensure python can be executed with the command '$SETUP_PYTHON' by the current user '$USER'."
|
echo "# POI07| Please ensure python can be executed with the command '$SETUP_PYTHON' by the current user '$USER'."
|
||||||
@@ -91,14 +91,14 @@ function get_env() {
|
|||||||
envname=$1
|
envname=$1
|
||||||
|
|
||||||
pid=$$
|
pid=$$
|
||||||
while [ -z "${!envname}" -a $pid != 1 ]; do
|
while [[ -z "${!envname}" && $pid != 1 ]]; do
|
||||||
ppid=`ps -oppid -p$pid|tail -1|awk '{print $1}'`
|
ppid=`ps -oppid -p$pid|tail -1|awk '{print $1}'`
|
||||||
env=`strings /proc/$ppid/environ`
|
env=`strings /proc/$ppid/environ`
|
||||||
export $envname=`echo "$env"|awk -F= '$1 == "'$envname'" { print $2; }'`
|
export $envname=`echo "$env"|awk -F= '$1 == "'$envname'" { print $2; }'`
|
||||||
pid=$ppid
|
pid=$ppid
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -n "${SETUP_DEBUG}" ]; then
|
if [[ -n "${SETUP_DEBUG}" ]]; then
|
||||||
echo "# POI02| Done getting env $envname: ${!envname}"
|
echo "# POI02| Done getting env $envname: ${!envname}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -106,7 +106,7 @@ function get_env() {
|
|||||||
function detect_local_env() {
|
function detect_local_env() {
|
||||||
# Get all possible envs for the install
|
# Get all possible envs for the install
|
||||||
|
|
||||||
if [ -n "${SETUP_DEBUG}" ]; then
|
if [[ -n "${SETUP_DEBUG}" ]]; then
|
||||||
echo "# POI02| Printing local envs - before #++#"
|
echo "# POI02| Printing local envs - before #++#"
|
||||||
printenv
|
printenv
|
||||||
fi
|
fi
|
||||||
@@ -116,13 +116,13 @@ function detect_local_env() {
|
|||||||
get_env $i
|
get_env $i
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -n "${SETUP_DEBUG}" ]; then
|
if [[ -n "${SETUP_DEBUG}" ]]; then
|
||||||
echo "# POI02| Printing local envs - after #++#"
|
echo "# POI02| Printing local envs - after #++#"
|
||||||
printenv
|
printenv
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Print branch and dir from VERSION file
|
# Print branch and dir from VERSION file
|
||||||
if [ -f "${APP_HOME}/VERSION" ]; then
|
if [[ -f "${APP_HOME}/VERSION" ]]; then
|
||||||
echo "# POI02| Loading environment variables from VERSION file"
|
echo "# POI02| Loading environment variables from VERSION file"
|
||||||
content=$(cat "${APP_HOME}/VERSION")
|
content=$(cat "${APP_HOME}/VERSION")
|
||||||
# use grep to get the branch and target
|
# use grep to get the branch and target
|
||||||
@@ -141,7 +141,7 @@ function detect_envs() {
|
|||||||
|
|
||||||
export INVENTREE_CONFIG_FILE=${INVENTREE_CONFIG_FILE:-${CONF_DIR}/config.yaml}
|
export INVENTREE_CONFIG_FILE=${INVENTREE_CONFIG_FILE:-${CONF_DIR}/config.yaml}
|
||||||
|
|
||||||
if test -f "${INVENTREE_CONFIG_FILE}"; then
|
if [[ -f "${INVENTREE_CONFIG_FILE}" ]]; then
|
||||||
echo "# POI03| Using existing config file: ${INVENTREE_CONFIG_FILE}"
|
echo "# POI03| Using existing config file: ${INVENTREE_CONFIG_FILE}"
|
||||||
|
|
||||||
# Install parser
|
# Install parser
|
||||||
@@ -168,9 +168,9 @@ function detect_envs() {
|
|||||||
export INVENTREE_DB_PORT=$(jq -r '.[].database.PORT' <<< ${INVENTREE_CONF_DATA})
|
export INVENTREE_DB_PORT=$(jq -r '.[].database.PORT' <<< ${INVENTREE_CONF_DATA})
|
||||||
|
|
||||||
# Parse site URL if not already set
|
# Parse site URL if not already set
|
||||||
if [ -z "${INVENTREE_SITE_URL}" ]; then
|
if [[ -z "${INVENTREE_SITE_URL}" ]]; then
|
||||||
# Try to read out the app config
|
# Try to read out the app config
|
||||||
if [ -n "$(inventree config:get INVENTREE_SITE_URL)" ]; then
|
if [[ -n "$(inventree config:get INVENTREE_SITE_URL)" ]]; then
|
||||||
echo "# POI03| Getting site URL from app config"
|
echo "# POI03| Getting site URL from app config"
|
||||||
export INVENTREE_SITE_URL=$(inventree config:get INVENTREE_SITE_URL)
|
export INVENTREE_SITE_URL=$(inventree config:get INVENTREE_SITE_URL)
|
||||||
else
|
else
|
||||||
@@ -181,7 +181,7 @@ function detect_envs() {
|
|||||||
else
|
else
|
||||||
echo "# POI03| No config file found: ${INVENTREE_CONFIG_FILE}, using envs or defaults"
|
echo "# POI03| No config file found: ${INVENTREE_CONFIG_FILE}, using envs or defaults"
|
||||||
|
|
||||||
if [ -n "${SETUP_DEBUG}" ]; then
|
if [[ -n "${SETUP_DEBUG}" ]]; then
|
||||||
echo "# POI03| Print current envs"
|
echo "# POI03| Print current envs"
|
||||||
printenv | grep INVENTREE_
|
printenv | grep INVENTREE_
|
||||||
printenv | grep SETUP_
|
printenv | grep SETUP_
|
||||||
@@ -218,7 +218,7 @@ function detect_envs() {
|
|||||||
echo "# POI03| INVENTREE_DB_ENGINE=${INVENTREE_DB_ENGINE}"
|
echo "# POI03| INVENTREE_DB_ENGINE=${INVENTREE_DB_ENGINE}"
|
||||||
echo "# POI03| INVENTREE_DB_NAME=${INVENTREE_DB_NAME}"
|
echo "# POI03| INVENTREE_DB_NAME=${INVENTREE_DB_NAME}"
|
||||||
echo "# POI03| INVENTREE_DB_USER=${INVENTREE_DB_USER}"
|
echo "# POI03| INVENTREE_DB_USER=${INVENTREE_DB_USER}"
|
||||||
if [ -n "${SETUP_DEBUG}" ]; then
|
if [[ -n "${SETUP_DEBUG}" ]]; then
|
||||||
echo "# POI03| INVENTREE_DB_PASSWORD=${INVENTREE_DB_PASSWORD}"
|
echo "# POI03| INVENTREE_DB_PASSWORD=${INVENTREE_DB_PASSWORD}"
|
||||||
fi
|
fi
|
||||||
echo "# POI03| INVENTREE_DB_HOST=${INVENTREE_DB_HOST}"
|
echo "# POI03| INVENTREE_DB_HOST=${INVENTREE_DB_HOST}"
|
||||||
@@ -229,7 +229,7 @@ function detect_envs() {
|
|||||||
function create_initscripts() {
|
function create_initscripts() {
|
||||||
|
|
||||||
# Make sure python env exists
|
# Make sure python env exists
|
||||||
if test -f "${APP_HOME}/env"; then
|
if [[ -f "${APP_HOME}/env" ]]; then
|
||||||
echo "# POI09| python environment already present - skipping"
|
echo "# POI09| python environment already present - skipping"
|
||||||
else
|
else
|
||||||
echo "# POI09| Setting up python environment"
|
echo "# POI09| Setting up python environment"
|
||||||
@@ -237,14 +237,14 @@ function create_initscripts() {
|
|||||||
sudo -u ${APP_USER} --preserve-env=$SETUP_ENVS bash -c "cd ${APP_HOME} && env/bin/pip install invoke wheel"
|
sudo -u ${APP_USER} --preserve-env=$SETUP_ENVS bash -c "cd ${APP_HOME} && env/bin/pip install invoke wheel"
|
||||||
|
|
||||||
# Check INSTALLER_EXTRA exists and load it
|
# Check INSTALLER_EXTRA exists and load it
|
||||||
if test -f "${APP_HOME}/INSTALLER_EXTRA"; then
|
if [[ -f "${APP_HOME}/INSTALLER_EXTRA" ]]; then
|
||||||
echo "# POI09| Loading extra packages from INSTALLER_EXTRA"
|
echo "# POI09| Loading extra packages from INSTALLER_EXTRA"
|
||||||
source ${APP_HOME}/INSTALLER_EXTRA
|
source ${APP_HOME}/INSTALLER_EXTRA
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "${SETUP_EXTRA_PIP}" ]; then
|
if [[ -n "${SETUP_EXTRA_PIP}" ]]; then
|
||||||
echo "# POI09| Installing extra pip packages"
|
echo "# POI09| Installing extra pip packages"
|
||||||
if [ -n "${SETUP_DEBUG}" ]; then
|
if [[ -n "${SETUP_DEBUG}" ]]; then
|
||||||
echo "# POI09| Extra pip packages: ${SETUP_EXTRA_PIP}"
|
echo "# POI09| Extra pip packages: ${SETUP_EXTRA_PIP}"
|
||||||
fi
|
fi
|
||||||
sudo -u ${APP_USER} --preserve-env=$SETUP_ENVS bash -c "cd ${APP_HOME} && env/bin/pip install ${SETUP_EXTRA_PIP}"
|
sudo -u ${APP_USER} --preserve-env=$SETUP_ENVS bash -c "cd ${APP_HOME} && env/bin/pip install ${SETUP_EXTRA_PIP}"
|
||||||
@@ -254,7 +254,7 @@ function create_initscripts() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Unlink default config if it exists
|
# Unlink default config if it exists
|
||||||
if test -f "/etc/nginx/sites-enabled/default"; then
|
if [[ -f "/etc/nginx/sites-enabled/default" ]]; then
|
||||||
echo "# POI09| Unlinking default nginx config\n# POI09| Old file still in /etc/nginx/sites-available/default"
|
echo "# POI09| Unlinking default nginx config\n# POI09| Old file still in /etc/nginx/sites-available/default"
|
||||||
sudo unlink /etc/nginx/sites-enabled/default
|
sudo unlink /etc/nginx/sites-enabled/default
|
||||||
echo "# POI09| Unlinked default nginx config"
|
echo "# POI09| Unlinked default nginx config"
|
||||||
@@ -285,12 +285,12 @@ function create_initscripts() {
|
|||||||
|
|
||||||
function create_admin() {
|
function create_admin() {
|
||||||
# Create data for admin users - stop with setting SETUP_ADMIN_NOCREATION to true
|
# Create data for admin users - stop with setting SETUP_ADMIN_NOCREATION to true
|
||||||
if [ "${SETUP_ADMIN_NOCREATION}" == "true" ]; then
|
if [[ "${SETUP_ADMIN_NOCREATION}" == "true" ]]; then
|
||||||
echo "# POI10| Admin creation is disabled - skipping"
|
echo "# POI10| Admin creation is disabled - skipping"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -f "${SETUP_ADMIN_PASSWORD_FILE}"; then
|
if [[ -f "${SETUP_ADMIN_PASSWORD_FILE}" ]]; then
|
||||||
echo "# POI10| Admin data already exists - skipping"
|
echo "# POI10| Admin data already exists - skipping"
|
||||||
else
|
else
|
||||||
echo "# POI10| Creating admin user data"
|
echo "# POI10| Creating admin user data"
|
||||||
@@ -300,7 +300,7 @@ function create_admin() {
|
|||||||
export INVENTREE_ADMIN_EMAIL=${INVENTREE_ADMIN_EMAIL:-admin@example.com}
|
export INVENTREE_ADMIN_EMAIL=${INVENTREE_ADMIN_EMAIL:-admin@example.com}
|
||||||
|
|
||||||
# Create password if not set
|
# Create password if not set
|
||||||
if [ -z "${INVENTREE_ADMIN_PASSWORD}" ]; then
|
if [[ -z "${INVENTREE_ADMIN_PASSWORD}" ]]; then
|
||||||
openssl rand -base64 32 >${SETUP_ADMIN_PASSWORD_FILE}
|
openssl rand -base64 32 >${SETUP_ADMIN_PASSWORD_FILE}
|
||||||
export INVENTREE_ADMIN_PASSWORD=$(cat ${SETUP_ADMIN_PASSWORD_FILE})
|
export INVENTREE_ADMIN_PASSWORD=$(cat ${SETUP_ADMIN_PASSWORD_FILE})
|
||||||
fi
|
fi
|
||||||
@@ -381,15 +381,15 @@ function set_env() {
|
|||||||
|
|
||||||
function set_site() {
|
function set_site() {
|
||||||
# Ensure IP is known
|
# Ensure IP is known
|
||||||
if [ -z "${INVENTREE_IP}" ]; then
|
if [[ -z "${INVENTREE_IP}" ]]; then
|
||||||
echo "# POI14| No IP address found - skipping"
|
echo "# POI14| No IP address found - skipping"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if INVENTREE_SITE_URL in inventree config
|
# Check if INVENTREE_SITE_URL in inventree config
|
||||||
if [ -z "$(inventree config:get INVENTREE_SITE_URL)" ]; then
|
if [[ -z "$(inventree config:get INVENTREE_SITE_URL)" ]]; then
|
||||||
# Prefer current INVENTREE_SITE_URL if set
|
# Prefer current INVENTREE_SITE_URL if set
|
||||||
if [ -n "${INVENTREE_SITE_URL}" ]; then
|
if [[ -n "${INVENTREE_SITE_URL}" ]]; then
|
||||||
inventree config:set INVENTREE_SITE_URL=${INVENTREE_SITE_URL}
|
inventree config:set INVENTREE_SITE_URL=${INVENTREE_SITE_URL}
|
||||||
else
|
else
|
||||||
echo "# POI14| Setting up InvenTree site URL"
|
echo "# POI14| Setting up InvenTree site URL"
|
||||||
@@ -407,7 +407,7 @@ function final_message() {
|
|||||||
echo -e "${SETUP_NGINX_FILE}"
|
echo -e "${SETUP_NGINX_FILE}"
|
||||||
echo -e "Try opening InvenTree with any of \n${INVENTREE_SITE_URL} , http://localhost/ or http://${INVENTREE_IP}/ \n"
|
echo -e "Try opening InvenTree with any of \n${INVENTREE_SITE_URL} , http://localhost/ or http://${INVENTREE_IP}/ \n"
|
||||||
# Print admin user data only if set
|
# Print admin user data only if set
|
||||||
if [ -n "${INVENTREE_ADMIN_USER}" ]; then
|
if [[ -n "${INVENTREE_ADMIN_USER}" ]]; then
|
||||||
echo -e "Admin user data:"
|
echo -e "Admin user data:"
|
||||||
echo -e " Email: ${INVENTREE_ADMIN_EMAIL}"
|
echo -e " Email: ${INVENTREE_ADMIN_EMAIL}"
|
||||||
echo -e " Username: ${INVENTREE_ADMIN_USER}"
|
echo -e " Username: ${INVENTREE_ADMIN_USER}"
|
||||||
@@ -434,10 +434,10 @@ function update_checks() {
|
|||||||
local name=$3
|
local name=$3
|
||||||
|
|
||||||
local value=$(inventree config:get ${env_key})
|
local value=$(inventree config:get ${env_key})
|
||||||
if [ -z "${value}" ] || [ "$value" == "null" ]; then
|
if [[ -z "${value}" ]] || [[ "$value" == "null" ]]; then
|
||||||
value=$(jq -r ".[].${config_key}" <<< ${INVENTREE_CONF_DATA})
|
value=$(jq -r ".[].${config_key}" <<< ${INVENTREE_CONF_DATA})
|
||||||
fi
|
fi
|
||||||
if [ -z "${value}" ] || [ "$value" == "null" ]; then
|
if [[ -z "${value}" ]] || [[ "$value" == "null" ]]; then
|
||||||
echo "# POI08| No setting for ${name} found - please set it manually either in ${INVENTREE_CONFIG_FILE} under '${config_key}' or with 'inventree config:set ${env_key}=value'"
|
echo "# POI08| No setting for ${name} found - please set it manually either in ${INVENTREE_CONFIG_FILE} under '${config_key}' or with 'inventree config:set ${env_key}=value'"
|
||||||
ABORT=true
|
ABORT=true
|
||||||
else
|
else
|
||||||
@@ -446,14 +446,14 @@ function update_checks() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Custom checks if old version is below 0.8.0
|
# Custom checks if old version is below 0.8.0
|
||||||
if [ "${old_version_rev}" -lt "9" ]; then
|
if [[ "${old_version_rev}" -lt "9" ]]; then
|
||||||
echo "# POI08| Old version is below 0.9.0 - You might be missing some configs"
|
echo "# POI08| Old version is below 0.9.0 - You might be missing some configs"
|
||||||
|
|
||||||
# Check for BACKUP_DIR and SITE_URL in INVENTREE_CONF_DATA and config
|
# Check for BACKUP_DIR and SITE_URL in INVENTREE_CONF_DATA and config
|
||||||
check_config_value "INVENTREE_SITE_URL" "site_url" "site URL"
|
check_config_value "INVENTREE_SITE_URL" "site_url" "site URL"
|
||||||
check_config_value "INVENTREE_BACKUP_DIR" "backup_dir" "backup dir"
|
check_config_value "INVENTREE_BACKUP_DIR" "backup_dir" "backup dir"
|
||||||
|
|
||||||
if [ "${ABORT}" = true ]; then
|
if [[ "${ABORT}" = true ]]; then
|
||||||
echo "# POI08| Aborting - please set the missing values and run the update again"
|
echo "# POI08| Aborting - please set the missing values and run the update again"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ detect_python
|
|||||||
|
|
||||||
# Check if we are updating and need to alert
|
# Check if we are updating and need to alert
|
||||||
echo "# POI08| Checking if update checks are needed"
|
echo "# POI08| Checking if update checks are needed"
|
||||||
if [ -z "$2" ]; then
|
if [[ -z "$2" ]]; then
|
||||||
echo "# POI08| Normal install - no need for checks"
|
echo "# POI08| Normal install - no need for checks"
|
||||||
else
|
else
|
||||||
update_checks $2
|
update_checks $2
|
||||||
@@ -56,7 +56,7 @@ create_admin
|
|||||||
stop_inventree
|
stop_inventree
|
||||||
update_or_install
|
update_or_install
|
||||||
# Write config file
|
# Write config file
|
||||||
if [ "${SETUP_CONF_LOADED}" = "true" ]; then
|
if [[ "${SETUP_CONF_LOADED}" = "true" ]]; then
|
||||||
set_env
|
set_env
|
||||||
fi
|
fi
|
||||||
set_site
|
set_site
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ PATH=${APP_HOME}/env/bin:${APP_HOME}/:/sbin:/bin:/usr/sbin:/usr/bin:
|
|||||||
# Envs that should be passed to setup commands
|
# Envs that should be passed to setup commands
|
||||||
export SETUP_ENVS=PATH,APP_HOME,INVENTREE_MEDIA_ROOT,INVENTREE_STATIC_ROOT,INVENTREE_BACKUP_DIR,INVENTREE_PLUGINS_ENABLED,INVENTREE_PLUGIN_FILE,INVENTREE_CONFIG_FILE,INVENTREE_SECRET_KEY_FILE,INVENTREE_DB_ENGINE,INVENTREE_DB_NAME,INVENTREE_DB_USER,INVENTREE_DB_PASSWORD,INVENTREE_DB_HOST,INVENTREE_DB_PORT,INVENTREE_ADMIN_USER,INVENTREE_ADMIN_EMAIL,INVENTREE_ADMIN_PASSWORD,INVENTREE_SITE_URL,SETUP_NGINX_FILE,SETUP_ADMIN_PASSWORD_FILE,SETUP_NO_CALLS,SETUP_DEBUG,SETUP_EXTRA_PIP,SETUP_PYTHON
|
export SETUP_ENVS=PATH,APP_HOME,INVENTREE_MEDIA_ROOT,INVENTREE_STATIC_ROOT,INVENTREE_BACKUP_DIR,INVENTREE_PLUGINS_ENABLED,INVENTREE_PLUGIN_FILE,INVENTREE_CONFIG_FILE,INVENTREE_SECRET_KEY_FILE,INVENTREE_DB_ENGINE,INVENTREE_DB_NAME,INVENTREE_DB_USER,INVENTREE_DB_PASSWORD,INVENTREE_DB_HOST,INVENTREE_DB_PORT,INVENTREE_ADMIN_USER,INVENTREE_ADMIN_EMAIL,INVENTREE_ADMIN_PASSWORD,INVENTREE_SITE_URL,SETUP_NGINX_FILE,SETUP_ADMIN_PASSWORD_FILE,SETUP_NO_CALLS,SETUP_DEBUG,SETUP_EXTRA_PIP,SETUP_PYTHON
|
||||||
|
|
||||||
if test -f "${APP_HOME}/env/bin/pip"; then
|
if [[ -f "${APP_HOME}/env/bin/pip" ]]; then
|
||||||
# Check if clear-generated is available
|
# Check if clear-generated is available
|
||||||
if sudo -u ${APP_USER} --preserve-env=$SETUP_ENVS bash -c "cd ${APP_HOME} && invoke int.clear-generated --help" > /dev/null 2>&1; then
|
if sudo -u ${APP_USER} --preserve-env=$SETUP_ENVS bash -c "cd ${APP_HOME} && invoke int.clear-generated --help" > /dev/null 2>&1; then
|
||||||
echo "# PRI02| Clearing precompiled files"
|
echo "# PRI02| Clearing precompiled files"
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ def load_config_data(set_cache: bool = False) -> map | None:
|
|||||||
try:
|
try:
|
||||||
data = yaml.safe_load(cfg)
|
data = yaml.safe_load(cfg)
|
||||||
except yaml.parser.ParserError as error:
|
except yaml.parser.ParserError as error:
|
||||||
logger.error(
|
logger.exception(
|
||||||
"INVE-E13: Error reading InvenTree configuration file '%s': %s",
|
"INVE-E13: Error reading InvenTree configuration file '%s': %s",
|
||||||
cfg_file,
|
cfg_file,
|
||||||
error,
|
error,
|
||||||
|
|||||||
@@ -2423,9 +2423,7 @@ class OrderCalendarExport(ICalFeed):
|
|||||||
whether or not to show completed orders. Defaults to false
|
whether or not to show completed orders. Defaults to false
|
||||||
"""
|
"""
|
||||||
|
|
||||||
instance_url = get_base_url()
|
instance_url = get_base_url().replace('http://', '').replace('https://', '')
|
||||||
|
|
||||||
instance_url = instance_url.replace('http://', '').replace('https://', '')
|
|
||||||
timezone = settings.TIME_ZONE
|
timezone = settings.TIME_ZONE
|
||||||
file_name = 'calendar.ics'
|
file_name = 'calendar.ics'
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ from plugin.base.supplier import helpers as supplier
|
|||||||
from plugin.mixins import SettingsMixin
|
from plugin.mixins import SettingsMixin
|
||||||
|
|
||||||
PartData = TypeVar('PartData')
|
PartData = TypeVar('PartData')
|
||||||
|
NOT_IMPLEMENTED_ERROR = 'This method needs to be overridden.'
|
||||||
|
|
||||||
|
|
||||||
class SupplierMixin(SettingsMixin, Generic[PartData]):
|
class SupplierMixin(SettingsMixin, Generic[PartData]):
|
||||||
@@ -50,25 +51,25 @@ class SupplierMixin(SettingsMixin, Generic[PartData]):
|
|||||||
# --- Methods to be overridden by plugins ---
|
# --- Methods to be overridden by plugins ---
|
||||||
def get_suppliers(self) -> list[supplier.Supplier]:
|
def get_suppliers(self) -> list[supplier.Supplier]:
|
||||||
"""Return a list of available suppliers."""
|
"""Return a list of available suppliers."""
|
||||||
raise NotImplementedError('This method needs to be overridden.')
|
raise NotImplementedError(NOT_IMPLEMENTED_ERROR)
|
||||||
|
|
||||||
def get_search_results(
|
def get_search_results(
|
||||||
self, supplier_slug: str, term: str
|
self, supplier_slug: str, term: str
|
||||||
) -> list[supplier.SearchResult]:
|
) -> list[supplier.SearchResult]:
|
||||||
"""Return a list of search results for the given search term."""
|
"""Return a list of search results for the given search term."""
|
||||||
raise NotImplementedError('This method needs to be overridden.')
|
raise NotImplementedError(NOT_IMPLEMENTED_ERROR)
|
||||||
|
|
||||||
def get_import_data(self, supplier_slug: str, part_id: str) -> PartData:
|
def get_import_data(self, supplier_slug: str, part_id: str) -> PartData:
|
||||||
"""Return the import data for the given part ID."""
|
"""Return the import data for the given part ID."""
|
||||||
raise NotImplementedError('This method needs to be overridden.')
|
raise NotImplementedError(NOT_IMPLEMENTED_ERROR)
|
||||||
|
|
||||||
def get_pricing_data(self, data: PartData) -> dict[int, tuple[float, str]]:
|
def get_pricing_data(self, data: PartData) -> dict[int, tuple[float, str]]:
|
||||||
"""Return a dictionary of pricing data for the given part data."""
|
"""Return a dictionary of pricing data for the given part data."""
|
||||||
raise NotImplementedError('This method needs to be overridden.')
|
raise NotImplementedError(NOT_IMPLEMENTED_ERROR)
|
||||||
|
|
||||||
def get_parameters(self, data: PartData) -> list[supplier.ImportParameter]:
|
def get_parameters(self, data: PartData) -> list[supplier.ImportParameter]:
|
||||||
"""Return a list of parameters for the given part data."""
|
"""Return a list of parameters for the given part data."""
|
||||||
raise NotImplementedError('This method needs to be overridden.')
|
raise NotImplementedError(NOT_IMPLEMENTED_ERROR)
|
||||||
|
|
||||||
def import_part(
|
def import_part(
|
||||||
self,
|
self,
|
||||||
@@ -86,7 +87,7 @@ class SupplierMixin(SettingsMixin, Generic[PartData]):
|
|||||||
- create related parts
|
- create related parts
|
||||||
- add attachments to the part
|
- add attachments to the part
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError('This method needs to be overridden.')
|
raise NotImplementedError(NOT_IMPLEMENTED_ERROR)
|
||||||
|
|
||||||
def import_manufacturer_part(
|
def import_manufacturer_part(
|
||||||
self, data: PartData, *, part: part_models.Part
|
self, data: PartData, *, part: part_models.Part
|
||||||
@@ -101,7 +102,7 @@ class SupplierMixin(SettingsMixin, Generic[PartData]):
|
|||||||
- Adding parameters to the manufacturer part
|
- Adding parameters to the manufacturer part
|
||||||
- Adding attachments to the manufacturer part
|
- Adding attachments to the manufacturer part
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError('This method needs to be overridden.')
|
raise NotImplementedError(NOT_IMPLEMENTED_ERROR)
|
||||||
|
|
||||||
def import_supplier_part(
|
def import_supplier_part(
|
||||||
self,
|
self,
|
||||||
@@ -116,7 +117,7 @@ class SupplierMixin(SettingsMixin, Generic[PartData]):
|
|||||||
- Creating a new supplier part
|
- Creating a new supplier part
|
||||||
- Creating supplier price breaks
|
- Creating supplier price breaks
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError('This method needs to be overridden.')
|
raise NotImplementedError(NOT_IMPLEMENTED_ERROR)
|
||||||
|
|
||||||
# --- Helper methods for importing parts ---
|
# --- Helper methods for importing parts ---
|
||||||
def download_image(self, img_url: str):
|
def download_image(self, img_url: str):
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from django.shortcuts import get_object_or_404
|
|||||||
|
|
||||||
import structlog
|
import structlog
|
||||||
from drf_spectacular.utils import extend_schema
|
from drf_spectacular.utils import extend_schema
|
||||||
from pydantic import ValidationError
|
from pydantic import BaseModel, ValidationError
|
||||||
from rest_framework.decorators import (
|
from rest_framework.decorators import (
|
||||||
api_view,
|
api_view,
|
||||||
authentication_classes,
|
authentication_classes,
|
||||||
@@ -70,9 +70,19 @@ class ScimParser(JSONParser):
|
|||||||
media_type = 'application/scim+json'
|
media_type = 'application/scim+json'
|
||||||
|
|
||||||
|
|
||||||
def scim_dump(obj) -> dict:
|
class ScimResponse(Response):
|
||||||
"""Serialize a scim2_models object to a plain (JSON-safe) dict."""
|
"""Custom Response class for SCIM protocol responses."""
|
||||||
return obj.model_dump(mode='json', exclude_none=True, by_alias=True)
|
|
||||||
|
def __init__(self, data, *args, **kwargs):
|
||||||
|
"""Like Response but with the scim suff auto-solved."""
|
||||||
|
if isinstance(data, DjangoUser):
|
||||||
|
data = user_to_scim(data)
|
||||||
|
elif isinstance(data, DjangoGroup):
|
||||||
|
data = group_to_scim(data)
|
||||||
|
|
||||||
|
if isinstance(data, BaseModel):
|
||||||
|
data = data.model_dump(mode='json', exclude_none=True, by_alias=True)
|
||||||
|
super().__init__(data, *args, content_type='application/scim+json', **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def scim_error(status: int, detail: str, scim_type: str | None = None) -> Response:
|
def scim_error(status: int, detail: str, scim_type: str | None = None) -> Response:
|
||||||
@@ -83,9 +93,7 @@ def scim_error(status: int, detail: str, scim_type: str | None = None) -> Respon
|
|||||||
scim_type=scim_type,
|
scim_type=scim_type,
|
||||||
detail=detail,
|
detail=detail,
|
||||||
)
|
)
|
||||||
return Response(
|
return ScimResponse(error, status=status)
|
||||||
scim_dump(error), status=status, content_type='application/scim+json'
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class ScimAPIView(APIView):
|
class ScimAPIView(APIView):
|
||||||
@@ -168,7 +176,7 @@ class ServiceProviderConfigView(ScimAPIView):
|
|||||||
)
|
)
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
return Response(scim_dump(config), content_type='application/scim+json')
|
return ScimResponse(config)
|
||||||
|
|
||||||
|
|
||||||
class ResourceTypesView(ScimAPIView):
|
class ResourceTypesView(ScimAPIView):
|
||||||
@@ -202,9 +210,7 @@ class ResourceTypesView(ScimAPIView):
|
|||||||
resource_type = self.resource_types.get(name)
|
resource_type = self.resource_types.get(name)
|
||||||
if not resource_type:
|
if not resource_type:
|
||||||
return scim_error(404, f"ResourceType '{name}' not found")
|
return scim_error(404, f"ResourceType '{name}' not found")
|
||||||
return Response(
|
return ScimResponse(resource_type)
|
||||||
scim_dump(resource_type), content_type='application/scim+json'
|
|
||||||
)
|
|
||||||
|
|
||||||
resources = list(self.resource_types.values())
|
resources = list(self.resource_types.values())
|
||||||
response = ListResponse[ResourceType](
|
response = ListResponse[ResourceType](
|
||||||
@@ -214,7 +220,7 @@ class ResourceTypesView(ScimAPIView):
|
|||||||
start_index=1,
|
start_index=1,
|
||||||
resources=resources,
|
resources=resources,
|
||||||
)
|
)
|
||||||
return Response(scim_dump(response), content_type='application/scim+json')
|
return ScimResponse(response)
|
||||||
|
|
||||||
|
|
||||||
class SchemasView(ScimAPIView):
|
class SchemasView(ScimAPIView):
|
||||||
@@ -233,7 +239,7 @@ class SchemasView(ScimAPIView):
|
|||||||
schema = schemas.get(schema_id)
|
schema = schemas.get(schema_id)
|
||||||
if not schema:
|
if not schema:
|
||||||
return scim_error(404, f"Schema '{schema_id}' not found")
|
return scim_error(404, f"Schema '{schema_id}' not found")
|
||||||
return Response(scim_dump(schema), content_type='application/scim+json')
|
return ScimResponse(schema)
|
||||||
|
|
||||||
resources = list(schemas.values())
|
resources = list(schemas.values())
|
||||||
response = ListResponse[Schema](
|
response = ListResponse[Schema](
|
||||||
@@ -243,7 +249,7 @@ class SchemasView(ScimAPIView):
|
|||||||
start_index=1,
|
start_index=1,
|
||||||
resources=resources,
|
resources=resources,
|
||||||
)
|
)
|
||||||
return Response(scim_dump(response), content_type='application/scim+json')
|
return ScimResponse(response)
|
||||||
|
|
||||||
|
|
||||||
class BaseResourceView(ScimAPIView):
|
class BaseResourceView(ScimAPIView):
|
||||||
@@ -291,7 +297,7 @@ class BaseResourceView(ScimAPIView):
|
|||||||
start_index=start_index,
|
start_index=start_index,
|
||||||
resources=resources,
|
resources=resources,
|
||||||
)
|
)
|
||||||
return Response(scim_dump(response), content_type='application/scim+json')
|
return ScimResponse(response)
|
||||||
|
|
||||||
|
|
||||||
class UsersView(BaseResourceView):
|
class UsersView(BaseResourceView):
|
||||||
@@ -325,11 +331,8 @@ class UsersView(BaseResourceView):
|
|||||||
|
|
||||||
logger.info('SCIM: provisioned new user', username=user.username)
|
logger.info('SCIM: provisioned new user', username=user.username)
|
||||||
|
|
||||||
return Response(
|
return ScimResponse(
|
||||||
scim_dump(user_to_scim(user)),
|
user, status=201, headers={'Location': user_location(user.pk)}
|
||||||
status=201,
|
|
||||||
content_type='application/scim+json',
|
|
||||||
headers={'Location': user_location(user.pk)},
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -343,9 +346,7 @@ class UserDetailView(ScimAPIView):
|
|||||||
def get(self, request, pk, *args, **kwargs):
|
def get(self, request, pk, *args, **kwargs):
|
||||||
"""Retrieve a single user."""
|
"""Retrieve a single user."""
|
||||||
user = self.get_object(pk)
|
user = self.get_object(pk)
|
||||||
return Response(
|
return ScimResponse(user)
|
||||||
scim_dump(user_to_scim(user)), content_type='application/scim+json'
|
|
||||||
)
|
|
||||||
|
|
||||||
def put(self, request, pk, *args, **kwargs):
|
def put(self, request, pk, *args, **kwargs):
|
||||||
"""Replace a user's attributes."""
|
"""Replace a user's attributes."""
|
||||||
@@ -353,9 +354,7 @@ class UserDetailView(ScimAPIView):
|
|||||||
scim_user = User.model_validate(request.data)
|
scim_user = User.model_validate(request.data)
|
||||||
apply_scim_to_user(scim_user, user)
|
apply_scim_to_user(scim_user, user)
|
||||||
user.save()
|
user.save()
|
||||||
return Response(
|
return ScimResponse(user)
|
||||||
scim_dump(user_to_scim(user)), content_type='application/scim+json'
|
|
||||||
)
|
|
||||||
|
|
||||||
def patch(self, request, pk, *args, **kwargs):
|
def patch(self, request, pk, *args, **kwargs):
|
||||||
"""Apply a SCIM PATCH operation set to a user."""
|
"""Apply a SCIM PATCH operation set to a user."""
|
||||||
@@ -368,9 +367,7 @@ class UserDetailView(ScimAPIView):
|
|||||||
apply_scim_to_user(scim_user, user)
|
apply_scim_to_user(scim_user, user)
|
||||||
user.save()
|
user.save()
|
||||||
|
|
||||||
return Response(
|
return ScimResponse(user)
|
||||||
scim_dump(user_to_scim(user)), content_type='application/scim+json'
|
|
||||||
)
|
|
||||||
|
|
||||||
def delete(self, request, pk, *args, **kwargs):
|
def delete(self, request, pk, *args, **kwargs):
|
||||||
"""Deactivate a user.
|
"""Deactivate a user.
|
||||||
@@ -414,11 +411,8 @@ class GroupsView(BaseResourceView):
|
|||||||
|
|
||||||
logger.info('SCIM: provisioned new group', name=group.name)
|
logger.info('SCIM: provisioned new group', name=group.name)
|
||||||
|
|
||||||
return Response(
|
return ScimResponse(
|
||||||
scim_dump(group_to_scim(group)),
|
group, status=201, headers={'Location': group_location(group.pk)}
|
||||||
status=201,
|
|
||||||
content_type='application/scim+json',
|
|
||||||
headers={'Location': group_location(group.pk)},
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -432,9 +426,7 @@ class GroupDetailView(ScimAPIView):
|
|||||||
def get(self, request, pk, *args, **kwargs):
|
def get(self, request, pk, *args, **kwargs):
|
||||||
"""Retrieve a single group."""
|
"""Retrieve a single group."""
|
||||||
group = self.get_object(pk)
|
group = self.get_object(pk)
|
||||||
return Response(
|
return ScimResponse(group)
|
||||||
scim_dump(group_to_scim(group)), content_type='application/scim+json'
|
|
||||||
)
|
|
||||||
|
|
||||||
def put(self, request, pk, *args, **kwargs):
|
def put(self, request, pk, *args, **kwargs):
|
||||||
"""Replace a group's attributes and membership."""
|
"""Replace a group's attributes and membership."""
|
||||||
@@ -443,9 +435,7 @@ class GroupDetailView(ScimAPIView):
|
|||||||
apply_scim_to_group(scim_group, group)
|
apply_scim_to_group(scim_group, group)
|
||||||
group.save()
|
group.save()
|
||||||
set_group_members(group, scim_group.members)
|
set_group_members(group, scim_group.members)
|
||||||
return Response(
|
return ScimResponse(group)
|
||||||
scim_dump(group_to_scim(group)), content_type='application/scim+json'
|
|
||||||
)
|
|
||||||
|
|
||||||
def patch(self, request, pk, *args, **kwargs):
|
def patch(self, request, pk, *args, **kwargs):
|
||||||
"""Apply a SCIM PATCH operation set to a group (used mainly for membership changes)."""
|
"""Apply a SCIM PATCH operation set to a group (used mainly for membership changes)."""
|
||||||
@@ -459,9 +449,7 @@ class GroupDetailView(ScimAPIView):
|
|||||||
group.save()
|
group.save()
|
||||||
set_group_members(group, scim_group.members)
|
set_group_members(group, scim_group.members)
|
||||||
|
|
||||||
return Response(
|
return ScimResponse(group)
|
||||||
scim_dump(group_to_scim(group)), content_type='application/scim+json'
|
|
||||||
)
|
|
||||||
|
|
||||||
def delete(self, request, pk, *args, **kwargs):
|
def delete(self, request, pk, *args, **kwargs):
|
||||||
"""Remove a group."""
|
"""Remove a group."""
|
||||||
|
|||||||
@@ -338,9 +338,9 @@ export function BomCompareDrawer({
|
|||||||
// Show only *common* parts
|
// Show only *common* parts
|
||||||
rows = rows.filter((row) => row.match);
|
rows = rows.filter((row) => row.match);
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
case 'all':
|
case 'all':
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return rows, sorted by part name
|
// Return rows, sorted by part name
|
||||||
|
|||||||
Reference in new issue
Block a user