dockerize project
parent
03f7bb86f5
commit
9baedb322d
|
|
@ -1,12 +1,19 @@
|
||||||
version: "2"
|
version: "2"
|
||||||
|
|
||||||
services:
|
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:
|
db:
|
||||||
image: postgres:10-alpine
|
image: postgres:10-alpine
|
||||||
volumes:
|
volumes:
|
||||||
- ./pgdata/:/var/lib/postgresql/data/
|
- ./pgdata/:/var/lib/postgresql/data/
|
||||||
environment:
|
env_file: postgres.env
|
||||||
- POSTGRES_PASSWORD=secret
|
|
||||||
- POSTGRES_USER=partdoc
|
|
||||||
ports:
|
|
||||||
- "127.0.0.1:5432:5432"
|
|
||||||
|
|
@ -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.sessions',
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
'django_extensions',
|
#'django_extensions',
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
|
|
@ -75,11 +75,11 @@ WSGI_APPLICATION = 'partdoc.wsgi.application'
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.postgresql',
|
'ENGINE': 'django.db.backends.postgresql',
|
||||||
'NAME': 'partdoc',
|
'NAME': os.environ.get('POSTGRES_USER',os.environ.get('POSTGRES_DB','postgres')),
|
||||||
'USER': 'partdoc',
|
'USER': os.environ.get('POSTGRES_USER','postgres'),
|
||||||
'PASSWORD': 'secret',
|
'PASSWORD': os.environ.get('POSTGRES_PASSWORD',''),
|
||||||
'HOST': '127.0.0.1',
|
'HOST': os.environ.get('DB_HOST','db'),
|
||||||
'PORT': '5432',
|
'PORT': os.environ.get('DB_PORT','5432'),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -121,3 +121,19 @@ STATIC_URL = '/static/'
|
||||||
STATIC_ROOT = 'static/'
|
STATIC_ROOT = 'static/'
|
||||||
|
|
||||||
DATA_UPLOAD_MAX_NUMBER_FIELDS = 10000
|
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'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,23 @@ class Version(PartModel):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "Version: " + self.name + " (" + str(self.product) + ")"
|
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):
|
class Part(PartModel):
|
||||||
name = models.CharField(max_length=256, db_index=True)
|
name = models.CharField(max_length=256, db_index=True)
|
||||||
|
|
@ -129,8 +146,8 @@ class ProductUsage(PartModel):
|
||||||
quantity = models.IntegerField(null=True)
|
quantity = models.IntegerField(null=True)
|
||||||
on_demand = models.BooleanField(default=False)
|
on_demand = models.BooleanField(default=False)
|
||||||
obsolete = 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_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)
|
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.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)
|
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)
|
# 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):
|
if len(note):
|
||||||
prod.note = note
|
prod.note = note
|
||||||
if len(replaced):
|
if len(replaced):
|
||||||
# replacement, _ = ProductUsage.objects.get_or_create(product=product, usage__part__number=replaced)
|
prod.replaced_by = replaced
|
||||||
# prod.replaced_by = replacement
|
|
||||||
prod.note += "{REP:" + str(replaced) + "}" # TODO
|
prod.note += "{REP:" + str(replaced) + "}" # TODO
|
||||||
internal = request.POST.getlist('internal')[i]
|
internal = request.POST.getlist('internal')[i]
|
||||||
if len(internal):
|
if len(internal):
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,2 @@
|
||||||
django==2.0.1
|
django==2.0.1
|
||||||
psycopg2==2.7.3.2
|
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