kopia lustrzana https://github.com/jedie/PyInventory
commit
d1bf6f25d6
|
@ -8,6 +8,10 @@
|
|||
!/.style.yapf
|
||||
!.coveralls.yml
|
||||
|
||||
# for django-dbbackup
|
||||
/backups/
|
||||
!/backups/.gitkeep
|
||||
|
||||
# from test projects:
|
||||
/static/
|
||||
/media/
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
FROM python:3.7-slim-buster
|
||||
FROM python:3.9-slim-buster
|
||||
# https://hub.docker.com/_/python
|
||||
|
||||
# Install deps
|
||||
RUN apt-get update \
|
||||
&& apt-mark auto $(apt-mark showinstall) \
|
||||
&& apt-get install -y python3-pip \
|
||||
&& apt-get install -y postgresql-client-11 python3-pip \
|
||||
&& apt autoremove \
|
||||
&& apt -y full-upgrade \
|
||||
&& rm -rf /var/lib/apt \
|
||||
|
|
28
Makefile
28
Makefile
|
@ -1,15 +1,13 @@
|
|||
SHELL := /bin/bash
|
||||
MAX_LINE_LENGTH := 119
|
||||
POETRY_VERSION := $(shell poetry --version 2>/dev/null)
|
||||
COMPOSE_VERSION := $(shell poetry run docker-compose --version 2>/dev/null)
|
||||
|
||||
help: ## List all commands
|
||||
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9 -]+:.*?## / {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
|
||||
|
||||
check-poetry:
|
||||
@if [[ "${POETRY_VERSION}" == *"Poetry"* ]] ; \
|
||||
@if [[ "$(shell poetry --version 2>/dev/null)" == *"Poetry"* ]] ; \
|
||||
then \
|
||||
echo "Found ${POETRY_VERSION}, ok." ; \
|
||||
echo "Poetry found, ok." ; \
|
||||
else \
|
||||
echo 'Please install poetry first, with e.g.:' ; \
|
||||
echo 'make install-poetry' ; \
|
||||
|
@ -17,9 +15,9 @@ check-poetry:
|
|||
fi
|
||||
|
||||
install-poetry: ## install or update poetry
|
||||
@if [[ "${POETRY_VERSION}" == *"Poetry"* ]] ; \
|
||||
@if [[ "$(shell poetry --version 2>/dev/null)" == *"Poetry"* ]] ; \
|
||||
then \
|
||||
echo 'Update poetry v$(POETRY_VERSION)' ; \
|
||||
echo 'Update poetry' ; \
|
||||
poetry self update ; \
|
||||
else \
|
||||
echo 'Install poetry' ; \
|
||||
|
@ -96,9 +94,9 @@ create-starter: ## Create starter file.
|
|||
|
||||
|
||||
check-compose:
|
||||
@if [[ "${COMPOSE_VERSION}" == *"docker-compose version"* ]] ; \
|
||||
@if [[ "$(shell poetry run docker-compose --version 2>/dev/null)" = *"docker-compose version"* ]] ; \
|
||||
then \
|
||||
echo "Found ${COMPOSE_VERSION}, ok." ; \
|
||||
echo "docker-compose found, ok." ; \
|
||||
else \
|
||||
echo 'Please install extras first, with e.g.:' ; \
|
||||
echo 'make install-compose' ; \
|
||||
|
@ -148,6 +146,20 @@ logs_inventory: ## Display docker logs from postgres container
|
|||
|
||||
##############################################################################
|
||||
|
||||
dbbackup: ## Backup database
|
||||
./manage.sh dbbackup
|
||||
|
||||
docker_dbbackup: ## Backup database (Docker usage)
|
||||
./compose.sh exec inventory ./manage.sh dbbackup
|
||||
|
||||
dbrestore: ## Restore a database backup
|
||||
./manage.sh dbrestore
|
||||
|
||||
docker_dbrestore: ## Restore a database backup (Docker usage)
|
||||
./compose.sh exec inventory ./manage.sh dbrestore
|
||||
|
||||
##############################################################################
|
||||
|
||||
restart: down up ## Restart all containers
|
||||
|
||||
upgrade_inventory: ## Upgrade "inventory" container and restart it
|
||||
|
|
|
@ -75,6 +75,9 @@ up Start containers via docker-compose
|
|||
down Stop all containers
|
||||
prune Cleanup docker
|
||||
build Update docker container build
|
||||
logs Display docker logs from all containers
|
||||
dbbackup Backup database
|
||||
dbrestore Restore a database backup
|
||||
restart Restart all containers
|
||||
}}}
|
||||
|
||||
|
@ -108,6 +111,8 @@ ENABLE_DJDT=1
|
|||
~/PyInventory$ make run-dev-server
|
||||
}}}
|
||||
|
||||
The web page is available via: {{{http://127.0.0.1:8000/}}}
|
||||
|
||||
|
||||
=== docker-compose usage
|
||||
|
||||
|
|
|
@ -112,6 +112,9 @@ prepare
|
|||
down Stop all containers
|
||||
prune Cleanup docker
|
||||
build Update docker container build
|
||||
logs Display docker logs from all containers
|
||||
dbbackup Backup database
|
||||
dbrestore Restore a database backup
|
||||
restart Restart all containers
|
||||
|
||||
.env
|
||||
|
@ -145,6 +148,8 @@ local install without docker
|
|||
# start local dev. web server:
|
||||
~/PyInventory$ make run-dev-server
|
||||
|
||||
The web page is available via: ``http://127.0.0.1:8000/``
|
||||
|
||||
docker-compose usage
|
||||
====================
|
||||
|
||||
|
@ -241,4 +246,4 @@ donation
|
|||
|
||||
------------
|
||||
|
||||
``Note: this file is generated from README.creole 2020-10-24 14:14:38 with "python-creole"``
|
||||
``Note: this file is generated from README.creole 2020-10-24 16:39:24 with "python-creole"``
|
|
@ -25,7 +25,7 @@ services:
|
|||
|
||||
postgres:
|
||||
# https://hub.docker.com/_/postgres
|
||||
image: postgres:13-alpine
|
||||
image: postgres:11-alpine
|
||||
restart: "no"
|
||||
hostname: postgres
|
||||
ports:
|
||||
|
|
|
@ -21,6 +21,8 @@ echo "$(date +%c) - ${0}"
|
|||
(
|
||||
set -x
|
||||
|
||||
poetry install --extras "postgres"
|
||||
|
||||
./manage.sh collectstatic --noinput --link
|
||||
./manage.sh makemigrations
|
||||
./manage.sh migrate
|
||||
|
|
|
@ -2,6 +2,8 @@ import tagulous
|
|||
from adminsortable2.admin import SortableInlineAdminMixin
|
||||
from django.contrib import admin
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from import_export.admin import ImportExportMixin
|
||||
from import_export.resources import ModelResource
|
||||
|
||||
from inventory.admin.base import BaseUserAdmin
|
||||
from inventory.models import ItemLinkModel, ItemModel
|
||||
|
@ -12,8 +14,14 @@ class ItemLinkModelInline(SortableInlineAdminMixin, admin.TabularInline):
|
|||
extra = 1
|
||||
|
||||
|
||||
class ItemModelResource(ModelResource):
|
||||
|
||||
class Meta:
|
||||
model = ItemModel
|
||||
|
||||
|
||||
@admin.register(ItemModel)
|
||||
class ItemModelAdmin(BaseUserAdmin):
|
||||
class ItemModelAdmin(ImportExportMixin, BaseUserAdmin):
|
||||
date_hierarchy = 'create_dt'
|
||||
list_display = (
|
||||
'kind', 'producer',
|
||||
|
|
|
@ -1,9 +1,17 @@
|
|||
from django.contrib import admin
|
||||
from import_export.admin import ImportExportMixin
|
||||
from import_export.resources import ModelResource
|
||||
|
||||
from inventory.admin.base import BaseUserAdmin
|
||||
from inventory.models import LocationModel
|
||||
|
||||
|
||||
class LocationModelResource(ModelResource):
|
||||
|
||||
class Meta:
|
||||
model = LocationModel
|
||||
|
||||
|
||||
@admin.register(LocationModel)
|
||||
class LocationModelAdmin(BaseUserAdmin):
|
||||
class LocationModelAdmin(ImportExportMixin, BaseUserAdmin):
|
||||
pass
|
||||
|
|
|
@ -39,6 +39,7 @@ INSTALLED_APPS = [
|
|||
|
||||
'bx_py_utils', # https://github.com/boxine/bx_py_utils
|
||||
'import_export', # https://github.com/django-import-export/django-import-export
|
||||
'dbbackup', # https://github.com/django-dbbackup/django-dbbackup
|
||||
'ckeditor', # https://github.com/django-ckeditor/django-ckeditor
|
||||
'reversion', # https://github.com/etianen/django-reversion
|
||||
'reversion_compare', # https://github.com/jedie/django-reversion-compare
|
||||
|
@ -142,6 +143,12 @@ STATIC_ROOT = str(__Path(BASE_PATH, 'static'))
|
|||
MEDIA_URL = '/media/'
|
||||
MEDIA_ROOT = str(__Path(BASE_PATH, 'media'))
|
||||
|
||||
# _____________________________________________________________________________
|
||||
# Django-dbbackup
|
||||
|
||||
DBBACKUP_STORAGE = 'django.core.files.storage.FileSystemStorage'
|
||||
DBBACKUP_STORAGE_OPTIONS = {'location': str(__Path(BASE_PATH, 'backups'))}
|
||||
|
||||
# _____________________________________________________________________________
|
||||
# Django-Debug-Toolbar
|
||||
|
||||
|
|
|
@ -258,6 +258,19 @@ python-versions = "*"
|
|||
[package.dependencies]
|
||||
django-js-asset = ">=1.2.2"
|
||||
|
||||
[[package]]
|
||||
name = "django-dbbackup"
|
||||
version = "3.3.0"
|
||||
description = "Management commands to help backup and restore a project database and media"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
|
||||
[package.dependencies]
|
||||
Django = ">=1.5"
|
||||
pytz = "*"
|
||||
six = "*"
|
||||
|
||||
[[package]]
|
||||
name = "django-debug-toolbar"
|
||||
version = "3.1.1"
|
||||
|
@ -1178,7 +1191,7 @@ postgres = ["psycopg2-binary"]
|
|||
[metadata]
|
||||
lock-version = "1.1"
|
||||
python-versions = ">=3.7,<4.0.0"
|
||||
content-hash = "4ad32caba18b4f973eee3d59a129b1ccd5750289a60c07939e1ab2f973fb4940"
|
||||
content-hash = "d07f05b3cb200bb30974923869838af5e96a1935fdcbaa2e536f03f046583d90"
|
||||
|
||||
[metadata.files]
|
||||
appdirs = [
|
||||
|
@ -1365,6 +1378,9 @@ django-ckeditor = [
|
|||
{file = "django-ckeditor-6.0.0.tar.gz", hash = "sha256:29fd1a333cb9741ac2c3fd4e427a5c00115ed33a2389716a09af7656022dcdde"},
|
||||
{file = "django_ckeditor-6.0.0-py2.py3-none-any.whl", hash = "sha256:cc2d377f1bdcd4ca1540caeebe85f7e2cd006198d57328ef6c718d3eaa5a0846"},
|
||||
]
|
||||
django-dbbackup = [
|
||||
{file = "django-dbbackup-3.3.0.tar.gz", hash = "sha256:bb109735cae98b64ad084e5b461b7aca2d7b39992f10c9ed9435e3ebb6fb76c8"},
|
||||
]
|
||||
django-debug-toolbar = [
|
||||
{file = "django-debug-toolbar-3.1.1.tar.gz", hash = "sha256:c97921a9cd421d392e7860dc4b464db8e06c8628df4dc58fedab012888c293c6"},
|
||||
{file = "django_debug_toolbar-3.1.1-py3-none-any.whl", hash = "sha256:a1ce0665f7ef47d27b8df4b5d1058748e1f08500a01421a30d35164f38aaaf4c"},
|
||||
|
|
|
@ -45,6 +45,7 @@ gunicorn = "*" # https://gunicorn.org/
|
|||
django = "2.2.*"
|
||||
django-debug-toolbar = "*" # http://django-debug-toolbar.readthedocs.io/en/stable/changes.html
|
||||
django-import-export = "*" # https://github.com/django-import-export/django-import-export
|
||||
django-dbbackup = "*" # https://github.com/django-dbbackup/django-dbbackup
|
||||
django-tools = "*" # https://github.com/jedie/django-tools/
|
||||
django-reversion-compare = "*" # https://github.com/jedie/django-reversion-compare/
|
||||
django-ckeditor = "*" # https://github.com/django-ckeditor/django-ckeditor
|
||||
|
|
Ładowanie…
Reference in New Issue