dockerize project
parent
03f7bb86f5
commit
9baedb322d
|
|
@ -1,12 +1,19 @@
|
|||
version: "2"
|
||||
|
||||
services:
|
||||
web:
|
||||
image: docker.clkl.de/partdoc/web:0.1
|
||||
build: partdoc
|
||||
env_file: postgres.env
|
||||
volumes:
|
||||
- ./partdoc/:/app/
|
||||
- ./sketches/:/app/sketches/
|
||||
working_dir: /app
|
||||
command: python3 ./manage.py runserver 0.0.0.0:8000
|
||||
ports:
|
||||
- 8080:8000
|
||||
db:
|
||||
image: postgres:10-alpine
|
||||
volumes:
|
||||
- ./pgdata/:/var/lib/postgresql/data/
|
||||
environment:
|
||||
- POSTGRES_PASSWORD=secret
|
||||
- POSTGRES_USER=partdoc
|
||||
ports:
|
||||
- "127.0.0.1:5432:5432"
|
||||
env_file: postgres.env
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
FROM alpine:3.7
|
||||
|
||||
ADD requirements.txt /
|
||||
RUN apk add --update --no-cache python3 py3-psycopg2 && \
|
||||
sed -i 's/psycopg2/#psycopg2/' /requirements.txt && \
|
||||
pip3 install -r /requirements.txt && rm /requirements.txt
|
||||
|
|
@ -36,7 +36,7 @@ INSTALLED_APPS = [
|
|||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'django_extensions',
|
||||
#'django_extensions',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
|
@ -75,11 +75,11 @@ WSGI_APPLICATION = 'partdoc.wsgi.application'
|
|||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'NAME': 'partdoc',
|
||||
'USER': 'partdoc',
|
||||
'PASSWORD': 'secret',
|
||||
'HOST': '127.0.0.1',
|
||||
'PORT': '5432',
|
||||
'NAME': os.environ.get('POSTGRES_USER',os.environ.get('POSTGRES_DB','postgres')),
|
||||
'USER': os.environ.get('POSTGRES_USER','postgres'),
|
||||
'PASSWORD': os.environ.get('POSTGRES_PASSWORD',''),
|
||||
'HOST': os.environ.get('DB_HOST','db'),
|
||||
'PORT': os.environ.get('DB_PORT','5432'),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -121,3 +121,19 @@ STATIC_URL = '/static/'
|
|||
STATIC_ROOT = 'static/'
|
||||
|
||||
DATA_UPLOAD_MAX_NUMBER_FIELDS = 10000
|
||||
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': False,
|
||||
'handlers': {
|
||||
'console': {
|
||||
'class': 'logging.StreamHandler',
|
||||
},
|
||||
},
|
||||
'loggers': {
|
||||
'django': {
|
||||
'handlers': ['console'],
|
||||
'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,6 +59,23 @@ class Version(PartModel):
|
|||
|
||||
def __str__(self):
|
||||
return "Version: " + self.name + " (" + str(self.product) + ")"
|
||||
|
||||
@staticmethod
|
||||
@transaction.atomic
|
||||
def merge(target, rip):
|
||||
self = Version.objects.filter(name=target)
|
||||
other = Version.objects.filter(name=rip)
|
||||
if not (self and other):
|
||||
raise ValueError("invalid arguments! {} {}".format(self, other))
|
||||
self = self.first()
|
||||
other = other.first()
|
||||
for x in other.introduces.all():
|
||||
x.used_until = self
|
||||
x.save()
|
||||
for x in other.dissmisses.all():
|
||||
x.used_since = self
|
||||
x.save()
|
||||
other.delete()
|
||||
|
||||
|
||||
class Part(PartModel):
|
||||
|
|
@ -129,8 +146,8 @@ class ProductUsage(PartModel):
|
|||
quantity = models.IntegerField(null=True)
|
||||
on_demand = models.BooleanField(default=False)
|
||||
obsolete = models.BooleanField(default=False)
|
||||
used_until = models.ForeignKey(Version, null=True, blank=True, related_name='introduces', on_delete=models.SET_NULL)
|
||||
used_since = models.ForeignKey(Version, null=True, blank=True, related_name='dissmisses', on_delete=models.SET_NULL)
|
||||
used_until = models.ForeignKey(Version, null=True, blank=True, related_name='introduces', on_delete=models.SET_NULL) # TODO: switch 'introduces' and 'dismisses'
|
||||
used_since = models.ForeignKey(Version, null=True, blank=True, related_name='dissmisses', on_delete=models.SET_NULL) # TODO: switch 'introduces' and 'dismisses'
|
||||
# replaced_by = models.ForeignKey('self', null=True, blank=True, related_name='replaces', on_delete=models.SET_NULL)
|
||||
replaced_by = models.CharField(max_length=512, null=True, blank=True)
|
||||
# alternative = models.ForeignKey('self', null=True, blank=True, related_name='alternatives', on_delete=models.SET_NULL)
|
||||
|
|
|
|||
|
|
@ -111,8 +111,7 @@ def sketch_add(request, product_id, sketch_id=None):
|
|||
if len(note):
|
||||
prod.note = note
|
||||
if len(replaced):
|
||||
# replacement, _ = ProductUsage.objects.get_or_create(product=product, usage__part__number=replaced)
|
||||
# prod.replaced_by = replacement
|
||||
prod.replaced_by = replaced
|
||||
prod.note += "{REP:" + str(replaced) + "}" # TODO
|
||||
internal = request.POST.getlist('internal')[i]
|
||||
if len(internal):
|
||||
|
|
|
|||
|
|
@ -1,3 +1,2 @@
|
|||
django==2.0.1
|
||||
psycopg2==2.7.3.2
|
||||
django-extensions==1.9.9
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
POSTGRES_PASSWORD=secret
|
||||
POSTGRES_USER=partdoc
|
||||
|
||||
PYTHONUNBUFFERED=1
|
||||
Loading…
Reference in New Issue