26 Commits

Author SHA1 Message Date
390eaac396 Merge branch 'develop' into feature/csv-import 2024-11-17 21:44:53 +01:00
3d63357534 made the readme and example for the CSV import accessible from the form directly 2024-11-17 21:44:30 +01:00
1c08f433d4 Merge pull request 'Implement #11 mhu/11-add-docker-compose-setup: Add compose setup' (#12) from mhu/11-add-docker-compose-setup into develop
Reviewed-on: #12
Reviewed-by: Stefan Strobel <stefan.strobel@shimatta.net>
2024-11-17 20:19:28 +01:00
8a8f2cdea4 Fix typo in comment 2024-11-17 20:08:53 +01:00
20a83c7e91 added CSV upload to enable fast creation of similar components 2024-11-17 19:54:15 +01:00
66f4eea77d Update env file example to contain Volume mount point for DB folder 2024-11-17 19:36:27 +01:00
561b2aed27 Add the /healthcheck path which returns an HTTP200 OK response for checking the helath of the container after startup 2024-11-17 19:10:28 +01:00
a59fad4866 Add self hosted entrypoint file for easier debugging which will use the integrated django server to serve all files 2024-11-17 17:33:45 +01:00
144a65ee05 Fix typo in eample env file 2024-11-17 16:52:18 +01:00
fc5fa9f740 Fix startup issue with postgres on first start. Implement health check of postgres and delay django container until it's healthy. 2024-11-17 16:50:10 +01:00
d2ce635f05 Add compose setup
* Use a dedicated postgresql container as database
* Controlled via .env file
* Ecample script for interactive container startup
2024-11-17 16:37:23 +01:00
64d0a1bfb3 Make gunicorn listen to all incoming IPs on Port 8000. This is necessary to use a spearate net with the postgres container. 2024-11-17 16:36:36 +01:00
b057fedb5f Add optional env variable DJANGO_FORCE_DEV_MODE to force production settings to dev mode for debugging 2024-11-17 16:34:58 +01:00
254bf2bdf0 made the verbose storage name optional in form 2024-11-16 19:11:25 +01:00
6e01b1939d Merge pull request 'feature/sst_storage_verbose_name' (#10) from feature/sst_storage_verbose_name into develop
Reviewed-on: #10
Reviewed-by: Mario Hüttel <mario.huettel@linux.com>
2024-11-16 13:27:19 +01:00
a77f46d697 added verbose name to storages to be printed on labels etc. 2024-11-16 13:22:59 +01:00
50ecaa2cc0 Merge pull request 'sst/storage_templates' (#3) from sst/storage_templates into develop
Reviewed-on: #3
2024-11-15 22:58:18 +01:00
3e72cfe5d8 fixed usage of if instead of elif 2024-11-15 22:55:30 +01:00
5e478ba624 removed bullshit 2024-11-10 21:21:07 +01:00
8280fe7116 added option to change storages 2024-11-10 21:13:56 +01:00
2e295e4691 removed unneeded stuff 2024-11-10 20:47:21 +01:00
0b27e9f064 added templating mechanism for storages 2024-11-10 20:46:45 +01:00
6dd781021c Merge pull request 'sst/tinkeing' (#2) from sst/tinkeing into master
Reviewed-on: #2
2024-04-25 20:37:14 +02:00
7e0fc86b7f running migration without interaction in entrypoint script 2023-12-11 00:34:43 +01:00
7a1bf054f5 disabling django ssl redirection in order to run this in docker (without ssl obviously) 2023-12-11 00:23:36 +01:00
5b6f4e16ef tinkered around to get this app running inside a container using alpine and socket based psql 2023-12-10 23:09:33 +01:00
34 changed files with 609 additions and 148 deletions

1
.dockerignore Normal file
View File

@@ -0,0 +1 @@
start_server.sh

32
.env.example Normal file
View File

@@ -0,0 +1,32 @@
####################################################################################################
# Example configuration. Must be edited and copied to ".env" next to the compose.yaml
####################################################################################################
# Path to to mount as the directory for static data. Must be served by a webserver on the /static path
DJANGO_STATIC_VOL=/path/to/static/root
# Path to the media root. Must be served by a webserver on the media URL
DJANGO_MEDIA_VOL=/path/to/media/root
# folder for DB
PGDATA_VOL=/path/to/pgdata
# Port to serve the App
PORT=8000
# Secret Key. Must be edited before deployment
DJANGO_SECRET_KEY=534hj5jgh4365ghj35jgh245jgh24
# Allowed host to be accessed. Currently it is only possible to specify a single URL
DJANGO_ALLOWED_HOST=lab.example.com
# Media URL for images and other content
DJANGO_MEDIA_URL=media.lab.example.com/
# DO NOT SET DEBUG MODE IN PRODUCTION
# DJANGO_FORCE_DEV_MODE=True
# Set this password if you want to use a custom postgres password. The db should be confined inside the docker network.
# Using the standard PW is therefore not a problem
# DJANGO_POSTGRESQL_PW=myfancynewpassword123donotsharemewithanyone

3
.gitignore vendored
View File

@@ -125,3 +125,6 @@ dmypy.json
myenv/*
run/*
.env

6
Dockerfile Normal file
View File

@@ -0,0 +1,6 @@
FROM alpine:latest
RUN apk add --no-cache python3 py3-pip python3-dev py3-setuptools gcc python3-dev jpeg-dev zlib-dev musl-dev py3-gunicorn curl
COPY . /home/shimatta/kenkyusho
WORKDIR /home/shimatta/kenkyusho
RUN python3 -m venv /home/shimatta/kenkyusho/.venv && . /home/shimatta/kenkyusho/.venv/bin/activate && pip install -r requirements.txt
ENTRYPOINT ["/home/shimatta/kenkyusho/entrypoint.sh"]

48
compose.yaml Normal file
View File

@@ -0,0 +1,48 @@
services:
shimatta-kenkyusho-web:
build: .
volumes:
- "${DJANGO_STATIC_VOL:-./run/static}:/var/static"
- "${DJANGO_MEDIA_VOL:-./run/media}:/var/media"
environment:
DJANGO_POSTGRESQL_PW: "${DJANGO_POSTGRESQL_PW:-p4ssw0rd}"
DJANGO_POSTGRESQL_USER: "postgres"
DJANGO_SECRET_KEY: "${DJANGO_SECRET_KEY}"
DJANGO_ALLOWED_HOST: "${DJANGO_ALLOWED_HOST}"
DJANGO_STATIC_ROOT: "/var/static"
DJANGO_MEDIA_URL: "${DJANGO_MEDIA_URL}"
DJANGO_MEDIA_ROOT: "/var/media"
DJANGO_POSTGRESQL_SOCKET: "shimatta-kenkyusho-db"
DJANGO_POSTGRESQL_PORT: "5432"
DJANGO_FORCE_DEV_MODE: ${DJANGO_FORCE_DEV_MODE:-False}
ports:
- "${PORT}:8000"
networks:
- backendnet
depends_on:
shimatta-kenkyusho-db:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "curl -f localhost:8000/healthcheck"]
interval: 5s
timeout: 5s
retries: 5
start_period: 30s
shimatta-kenkyusho-db:
image: postgres:16.5-alpine
environment:
POSTGRES_PASSWORD: "${DJANGO_POSTGRESQL_PW:-p4ssw0rd}"
POSTGRES_DB: "shimatta_kenkyusho"
volumes:
- "${PGDATA_VOL:-./run/pgdata}:/var/lib/postgresql/data"
networks:
- backendnet
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 5s
retries: 5
networks:
backendnet:

6
entrypoint.sh Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/sh
source /home/shimatta/kenkyusho/.venv/bin/activate
cd /home/shimatta/kenkyusho/shimatta_kenkyusho
python manage.py migrate --settings shimatta_kenkyusho.settings_production
python manage.py collectstatic --settings shimatta_kenkyusho.settings_production --noinput
gunicorn -w 4 --bind 0.0.0.0:8000 shimatta_kenkyusho.wsgi:application

6
entrypoint_self_hosted.sh Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/sh
source /home/shimatta/kenkyusho/.venv/bin/activate
cd /home/shimatta/kenkyusho/shimatta_kenkyusho
python manage.py migrate --settings shimatta_kenkyusho.settings_production
python manage.py runserver 0.0.0.0:8000 --settings shimatta_kenkyusho.settings_production

View File

@@ -1,5 +1,7 @@
asgiref==3.4.1
astroid==2.6.5
certifi==2024.8.30
charset-normalizer==3.4.0
crispy-bootstrap5==0.6
Django==3.2.5
django-crispy-forms==1.13.0
@@ -8,18 +10,24 @@ django-qr-code==2.2.0
django-rest-framework==0.1.0
django-tex==1.1.9.post1
djangorestframework==3.12.4
gunicorn==21.2.0
idna==3.10
isort==5.9.3
Jinja2==3.0.1
lazy-object-proxy==1.6.0
MarkupSafe==2.0.1
mccabe==0.6.1
packaging==24.2
Pillow==8.3.1
psycopg2==2.9.1
psycopg2-binary==2.9.9
pylint==2.9.6
pytz==2021.1
qrcode==7.2
requests==2.32.3
segno==1.3.3
setuptools==75.3.0
six==1.16.0
sqlparse==0.4.1
toml==0.10.2
urllib3==2.2.3
wrapt==1.12.1

View File

@@ -1,11 +1,12 @@
from django.contrib.auth.models import User, Group
from django.contrib.auth.models import Group
from django.contrib.auth import get_user_model
from rest_framework import serializers
from parts import models as parts_models
class UserSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = User
fields = ['username', 'email', 'first_name', 'last_name', 'groups']
model = get_user_model()
fields = ['id', 'username', 'email', 'first_name', 'last_name', 'groups']
class GroupSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
@@ -28,7 +29,7 @@ class StorageSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = parts_models.Storage
fields = ['url', 'id', 'name', 'parent_storage', 'responsible', 'full_path']
fields = ['url', 'id', 'name', 'verbose_name', 'parent_storage', 'responsible', 'template', 'full_path']
class ComponentSerializer(serializers.HyperlinkedModelSerializer):
package_data = PackageSerializerNoLink(source='package', read_only=True)

View File

@@ -7,6 +7,7 @@ router = routers.DefaultRouter()
router.register(r'users', UserViewSet)
router.register(r'groups', GroupViewSet)
router.register(r'parts/storages', PartsStorageViewSet)
router.register(r'parts/storage_templates', PartsStorageTemplatesViewSet, basename='storage-template')
router.register(r'parts/components', PartsComponentViewSet)
router.register(r'parts/stocks', PartsStockViewSet)
router.register(r'parts/packages', PartsPackageViewSet)

View File

@@ -1,5 +1,6 @@
from django.shortcuts import render
from django.contrib.auth.models import User, Group
from django.contrib.auth.models import Group
from django.contrib.auth import get_user_model
from django.core.exceptions import ObjectDoesNotExist
from rest_framework import viewsets, status
from rest_framework import permissions
@@ -25,7 +26,7 @@ class UserViewSet(viewsets.ReadOnlyModelViewSet):
"""
API endpoint that allows users to be viewed or edited.
"""
queryset = User.objects.all()
queryset = get_user_model().objects.all()
serializer_class = UserSerializer
permission_classes = [permissions.IsAuthenticated]
filter_backends = [filters.SearchFilter]
@@ -44,8 +45,17 @@ class PartsStorageViewSet(viewsets.ModelViewSet):
serializer_class = StorageSerializer
permission_classes = [permissions.DjangoModelPermissions]
filter_backends = [django_filters.rest_framework.DjangoFilterBackend]
search_fields = ['id', 'name', 'parent_storage']
filterset_fields = ['id', 'name', 'parent_storage']
class PartsStorageTemplatesViewSet(viewsets.ReadOnlyModelViewSet):
queryset = parts_models.Storage.objects.filter(is_template=True)
serializer_class = StorageSerializer
permission_classes = [permissions.IsAuthenticated]
filter_backends = [filters.SearchFilter]
search_fields = ['id', 'name']
filterset_fields = ['id', 'name']
class PartsComponentViewSet(viewsets.ModelViewSet):
queryset = parts_models.Component.objects.all()
serializer_class = ComponentSerializer

View File

@@ -0,0 +1,110 @@
import io
import csv
import requests
from django.db import transaction
from django.core.files.images import ImageFile
from.models import ComponentParameter, ComponentType, Manufacturer, Component, \
DistributorNum, Stock, Storage, Distributor, Package, ComponentParameterType
def _stock_component(component, storage_uuid, substorage_path, amount, lot, watermark):
if not amount or not any([storage_uuid, substorage_path]):
return None
storage = Storage.from_path(substorage_path, storage_uuid)
stock = Stock.objects.create(component=component,
storage=storage,
amount=amount,
lot=lot,
watermark=watermark)
return stock
def _set_additional_parameters(component, type, value):
if type.startswith('param:'):
type = type[6:]
param_type = ComponentParameterType.objects.get(parameter_name=type)
param = ComponentParameter.objects.create(component=component,
parameter_type=param_type)
if param_type == 'F':
param.text_value = value
else:
param.value = float(value)
param.save()
return param
elif type.startswith('distri:'):
distri_name = type[7:]
distri = Distributor.objects.get(name=distri_name)
distri_num = DistributorNum.objects.create(component=component,
distributor=distri,
distributor_part_number=value)
return distri_num
def import_components_from_csv(csv_file):
"""
Imports components from a csv file containing the component model fields as
well as storage information in the heading.
Parameters can be set by param:<parameter name>, distri numbers by
distri:<distri name>.
"""
with transaction.atomic():
# simulate a text-file for the csv lib
with io.TextIOWrapper(csv_file, encoding='utf8') as csv_text_file:
rows = csv.DictReader(csv_text_file, delimiter=";")
for data in rows:
image = None
image_url = data.pop('image_url')
if image_url:
response = requests.get(image_url)
image_content = response.content
image_file = io.BytesIO(image_content)
image = ImageFile(image_file, 'downloaded_file')
manufacturer = None
manufacturer_name = data.pop('manufacturer')
if manufacturer_name:
manufacturer = Manufacturer.objects.get(name=manufacturer_name)
component_type = None
component_type_name = data.pop('component_type')
if component_type_name:
component_type = ComponentType.objects.get(class_name=component_type_name)
distributor = None
pref_distri = data.pop('pref_distri')
if pref_distri:
distributor = Distributor.objects.get(name=pref_distri)
package = None
package_name = data.pop('package')
if package_name:
package = Package.objects.get(name=package_name)
comp = Component.objects.create(name=data.pop('name'),
manufacturer=manufacturer,
component_type=component_type,
pref_distri=distributor,
description=data.pop('description'),
datasheet_link=data.pop('datasheet_link'),
package=package,
image=image)
_stock_component(comp,
data.pop('storage_uuid'),
data.pop('substorage_path'),
data.pop('amount'),
data.pop('lot'),
data.pop('watermark'))
for key, value in data.items():
_set_additional_parameters(comp, key, value)

View File

@@ -1,23 +1,26 @@
from django import forms
from django.forms import widgets
from django.contrib.auth import get_user_model
from django.core.exceptions import ValidationError
from django.forms import widgets
from parts import models as parts_models
from shimatta_modules.EngineeringNumberConverter import EngineeringNumberConverter
import uuid
from django.urls import reverse
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Fieldset, Row, Column
from crispy_forms.layout import Layout, Row, Column
class AutoCompleteWidget(widgets.Input):
template_name = 'widgets/autocomplete-foreign-key.html'
def __init__(self, api_search_url, image_field_name, foreign_model, name_field_name, *args, **kwargs):
def __init__(self, api_search_url, image_field_name, foreign_model, name_field_name, prepend=None, *args, **kwargs):
super().__init__(*args, **kwargs)
self.image_field_name = image_field_name
self.foreign_model = foreign_model
self.api_search_url = api_search_url
self.name_field_name = name_field_name
self.prepend = prepend
def get_context(self, name, value, attrs):
context = super().get_context(name, value, attrs)
@@ -47,14 +50,25 @@ class AutoCompleteWidget(widgets.Input):
'current_instance': instance,
'image': image,
'name_field_name': self.name_field_name,
'prepend': self.prepend,
'name': display_name,
}
return context
class AutocompleteForeingKeyField(forms.UUIDField):
def __init__(self, foreign_model=None, api_search_url=None, image_field_name='image', name_field_name='name', **kwargs):
def __init__(self,
foreign_model=None,
api_search_url=None,
image_field_name='image',
name_field_name='name',
prepend=None,
**kwargs):
super().__init__(**kwargs)
self.widget = AutoCompleteWidget(api_search_url, image_field_name, foreign_model, name_field_name)
self.widget = AutoCompleteWidget(api_search_url,
image_field_name,
foreign_model,
name_field_name,
prepend)
self.foreign_model = foreign_model
@@ -73,14 +87,26 @@ class AutocompleteForeingKeyField(forms.UUIDField):
except self.foreign_model.DoesNotExist:
raise ValidationError('Given element does not exist')
return obj
class MyTestForm(forms.Form):
pass
class AddSubStorageForm(forms.Form):
storage_name = forms.CharField(label="storage_name", initial='')
responsible = forms.CharField(label='responsible_user')
class ChangeStorageForm(forms.Form):
storage_name = forms.CharField(label="Name", initial='')
verbose_name = forms.CharField(label="Verbose Name", initial='', required=False)
responsible = AutocompleteForeingKeyField(api_search_url='user-list',
image_field_name=None,
name_field_name='username',
foreign_model=get_user_model(),
prepend='@')
is_template = forms.BooleanField(label='is_template', required=False)
class AddSubStorageForm(ChangeStorageForm):
template = AutocompleteForeingKeyField(api_search_url='storage-template-list',
image_field_name=None,
foreign_model=parts_models.Storage,
required=False)
class DeleteStockForm(forms.Form):
stock_uuid = forms.UUIDField()
@@ -187,7 +213,10 @@ class ComponentForm(forms.ModelForm):
class Meta:
model = parts_models.Component
fields = '__all__'
class ImportComponentForm(forms.Form):
csv_file = forms.FileField(label="CSV File")
class PackageForm(forms.ModelForm):
class Meta:
model = parts_models.Package

View File

@@ -0,0 +1,24 @@
# Generated by Django 3.2.5 on 2024-11-10 12:42
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('parts', '0010_auto_20220103_1606'),
]
operations = [
migrations.AddField(
model_name='storage',
name='is_template',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='storage',
name='template',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='template_of', to='parts.storage'),
),
]

View File

@@ -0,0 +1,18 @@
# Generated by Django 3.2.5 on 2024-11-16 11:37
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('parts', '0011_auto_20241110_1242'),
]
operations = [
migrations.AddField(
model_name='storage',
name='verbose_name',
field=models.CharField(blank=True, max_length=100, null=True),
),
]

View File

@@ -1,7 +1,7 @@
from django.db import models
from shimatta_modules import RandomFileName
from django.db.models import F, Sum
from django.contrib.auth.models import User as AuthUser
from django.contrib.auth import get_user_model
from django.core.exceptions import ValidationError
from django.core.validators import RegexValidator
from django.dispatch import receiver
@@ -62,8 +62,17 @@ class Storage(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, unique=True)
name = models.CharField(max_length=100, validators=[storage_name_validator])
verbose_name = models.CharField(max_length=100, null=True, blank=True)
parent_storage = models.ForeignKey('self', on_delete=models.CASCADE, blank=True, null=True)
responsible = models.ForeignKey(AuthUser, on_delete=models.SET_NULL, blank=True, null=True)
responsible = models.ForeignKey(get_user_model(), on_delete=models.SET_NULL, blank=True, null=True)
# allow storages to be templates which can be selected when adding new storages
is_template = models.BooleanField(default=False)
template = models.ForeignKey('self',
on_delete=models.SET_NULL,
blank=True,
null=True,
related_name='template_of')
def get_path_components(self):
chain = []
@@ -113,6 +122,29 @@ class Storage(models.Model):
sum = 0
return sum
@classmethod
def from_path(cls, path, root_storage=None):
'''
Get the storage object described by its complete path or the sub-path
from the passed root_storage uuid
'''
parts = path.split('/')
# assemble filter query
filter_dict = {}
layer = 0
for part in parts[::-1]:
filter_dict[f'{"parent_storage__" * layer}name'] = part
layer += 1
if root_storage:
filter_dict[f'{"parent_storage__" * layer}id'] = root_storage
else:
filter_dict[f'{"parent_storage__" * layer}isnull'] = True
obj = cls.objects.get(**filter_dict)
return obj
def save(self, *args, **kwargs):
self.validate_unique()
super(Storage, self).save(*args, **kwargs)
@@ -288,7 +320,7 @@ class DistributorNum(models.Model):
class QrPrintJob(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, unique=True)
user = models.ForeignKey(AuthUser, on_delete=models.CASCADE, null=False, blank=False)
user = models.ForeignKey(get_user_model(), on_delete=models.CASCADE, null=False, blank=False)
qrdata = models.CharField(max_length=256, blank=True, null=False)
text = models.TextField(max_length=512, blank=True, null=False)
print_count = models.PositiveIntegerField(default=1, validators=[MinValueValidator(0), MaxValueValidator(32)])
@@ -335,4 +367,20 @@ def auto_delete_file_on_change(sender, instance, **kwargs):
if not old_file:
return True
if os.path.isfile(old_file.path):
os.remove(old_file.path)
os.remove(old_file.path)
@receiver(models.signals.post_save, sender=Storage)
def auto_apply_template_structure(sender, instance, created, **kwargs):
"""
Add the sub-storages from the template.
If there are nested sub-storages these will be added when the sub-storages
are created automatically.
"""
if created:
if instance.template:
for sub_storage in instance.template.storage_set.all():
Storage.objects.create(name=sub_storage.name,
parent_storage=instance,
responsible=instance.responsible,
is_template=False,
template=sub_storage)

View File

@@ -16,4 +16,5 @@ urlpatterns = [
path('distributors/<slug:uuid>/', parts_views.DistributorDetailView.as_view(), name='parts-distributors-detail'),
path('manufacturers/', parts_views.ManufacturersViewSet.as_view(), name='parts-manufacturers'),
path("manufacturers/<slug:uuid>/", parts_views.ManufacturerDetailViewSet.as_view(), name='parts-manufacturers-detail'),
path("healthcheck/", parts_views.health_check_view, name='parts-health-check'),
]

View File

@@ -1,28 +1,28 @@
from django.shortcuts import render, redirect
from django.urls import resolve, reverse
from django.urls import reverse
from django.contrib.auth import logout, login
from django.contrib.auth.models import User
from django.http import HttpResponse
from .navbar import NavBar
from django.contrib.auth.forms import AuthenticationForm as AuthForm
from django.contrib.auth.forms import PasswordChangeForm
from django.contrib.auth import update_session_auth_hash
from django.views import View
import django.forms as forms
from django.views.generic import TemplateView, DetailView
from django.contrib.auth.mixins import LoginRequiredMixin, PermissionRequiredMixin
from .models import Storage, Stock, Component, Distributor, Manufacturer, Package, ComponentParameter, ComponentParameterType, DistributorNum
from django.contrib.auth.mixins import LoginRequiredMixin
from .models import Storage, Stock, Component, Distributor, Manufacturer, Package, ComponentParameter, DistributorNum
from .qr_parser import QrCodeValidator
from django.core.paginator import Paginator
from django.core.exceptions import ValidationError
from django.db import IntegrityError
from django.db.models import ProtectedError
from .forms import *
from .component_import import import_components_from_csv
from django.db.models import Q
from django.db.models.functions import Lower
from django.forms import formset_factory
from django.http import HttpResponse
import uuid
ParameterSearchFormSet = formset_factory(ComponentParameterSearchForm, extra=1)
class QrSearchForm(forms.Form):
@@ -208,6 +208,7 @@ class ComponentView(LoginRequiredMixin, BaseTemplateMixin, TemplateView):
context['components'] = comp_paginator.get_page(comp_page_num)
context['comp_form'] = ComponentForm()
context['import_comp_form'] = ImportComponentForm()
context['search_string'] = search
if not parameter_formset:
@@ -221,7 +222,6 @@ class ComponentView(LoginRequiredMixin, BaseTemplateMixin, TemplateView):
def get_context_data(self, **kwargs):
return self.get_context_data_int(advanced_search = None, parameter_formset=None, **kwargs)
def handle_new_component_post(self, request, open=False, **kwargs):
cform = ComponentForm(data=request.POST, files=request.FILES)
@@ -236,7 +236,21 @@ class ComponentView(LoginRequiredMixin, BaseTemplateMixin, TemplateView):
if open and new_component:
return redirect(reverse('parts-components-detail', kwargs={'uuid':new_component.id}))
return self.render_to_response(context)
def handle_import_components_post(self, request, open=False, **kwargs):
cform = ImportComponentForm(data=request.POST, files=request.FILES)
context = self.get_context_data(**kwargs)
if cform.is_valid():
try:
import_components_from_csv(cform.files['csv_file'].file)
except Exception as ex:
cform.add_error('csv_file', str(ex))
context['import_comp_form'] = cform
else:
context['import_comp_form'] = cform
return self.render_to_response(context)
def handle_advanced_search_post(self, request, **kwargs):
form = AdvancedComponentSearchForm(auto_id='adv_search_%s', data=request.POST)
@@ -257,6 +271,8 @@ class ComponentView(LoginRequiredMixin, BaseTemplateMixin, TemplateView):
return self.handle_new_component_post(request, open=False, **kwargs)
elif 'submit-edit-component-open' in request.POST:
return self.handle_new_component_post(request, open=True, **kwargs)
elif 'submit-import-components' in request.POST:
return self.handle_import_components_post(request, open=True, **kwargs)
elif 'submit-advanced-search' in request.POST:
return self.handle_advanced_search_post(request, **kwargs)
else:
@@ -400,44 +416,31 @@ class StockView(LoginRequiredMixin, BaseTemplateMixin, TemplateView):
context['low_stocks'] = low_stock_paginator.get_page(low_stock_page)
context['storages'] = storage_paginator.get_page(storage_page)
add_stor_form = AddSubStorageForm()
add_stor_form.fields['responsible'].initial = self.request.user.username
add_stor_form.fields['responsible'].initial = self.request.user.id
context['add_storage_form'] = add_stor_form
return context
def handle_add_storage(self, request, **kwargs):
return_invalid_form = False
f = AddSubStorageForm(data=request.POST)
if f.is_valid():
new_storage_name = f.cleaned_data['storage_name']
try:
resp_user = User.objects.get(username=f.cleaned_data['responsible'])
except Exception as _:
resp_user = None
f.add_error('responsible', 'Invalid Responsible User')
return_invalid_form = True
if resp_user is not None:
try:
Storage.objects.create(name=new_storage_name, responsible=resp_user, parent_storage=None)
except ValidationError as verr:
return_invalid_form = True
f.add_error('storage_name', ' .'.join(verr.messages))
else:
return_invalid_form = True
sub_name = f.cleaned_data['storage_name']
try:
Storage.objects.create(name=sub_name,
responsible=f.cleaned_data['responsible'],
is_template=f.cleaned_data['is_template'],
template=f.cleaned_data.get('template'))
except ValidationError as v_err:
f.add_error('storage_name', '. '.join(v_err.messages))
context = self.get_context_data(**kwargs)
if return_invalid_form:
context['add_storage_form'] = f
context['add_storage_form'] = f
return self.render_to_response(context)
def post(self, request, **kwargs):
if 'submit-add-storage' in request.POST:
return self.handle_add_storage(request, **kwargs)
return super().post(request, **kwargs)
class StockViewDetail(LoginRequiredMixin, BaseTemplateMixin, DetailView):
template_name = 'parts/stocks-detail.html'
model = Storage
@@ -496,8 +499,14 @@ class StockViewDetail(LoginRequiredMixin, BaseTemplateMixin, DetailView):
context['stocks'] = stocks
context['stock_search'] = stock_search_input
add_storage_form = AddSubStorageForm()
add_storage_form.fields['responsible'].initial = self.request.user.username
add_storage_form.fields['responsible'].initial = self.request.user.id
context['add_storage_form'] = add_storage_form
change_storage_form = ChangeStorageForm()
change_storage_form.fields['storage_name'].initial = self.object.name
change_storage_form.fields['verbose_name'].initial = self.object.verbose_name
change_storage_form.fields['responsible'].initial = self.object.responsible.id
change_storage_form.fields['is_template'].initial = self.object.is_template
context['change_storage_form'] = change_storage_form
context['delete_storage_error'] = None
context['add_stock_form'] = AddStockForm()
@@ -508,17 +517,34 @@ class StockViewDetail(LoginRequiredMixin, BaseTemplateMixin, DetailView):
if f.is_valid():
sub_name = f.cleaned_data['storage_name']
try:
user = User.objects.get(username=f.cleaned_data['responsible'])
try:
Storage.objects.create(name=sub_name, parent_storage=self.object, responsible=user)
except ValidationError as v_err:
f.add_error('storage_name', '. '.join(v_err.messages))
except:
f.add_error('responsible', 'Invalid user')
Storage.objects.create(name=sub_name,
verbose_name=f.cleaned_data.get('verbose_name'),
parent_storage=self.object,
responsible=f.cleaned_data['responsible'],
is_template=f.cleaned_data['is_template'],
template=f.cleaned_data.get('template'))
except ValidationError as v_err:
f.add_error('storage_name', '. '.join(v_err.messages))
context = self.get_context_data(**kwargs)
context['add_storage_form'] = f
return self.render_to_response(context)
def handle_change_storage_post(self, request, **kwargs):
f = ChangeStorageForm(data=request.POST)
if f.is_valid():
sub_name = f.cleaned_data['storage_name']
try:
self.object.name = f.cleaned_data['storage_name']
self.object.verbose_name = f.cleaned_data.get('verbose_name')
self.object.responsible = f.cleaned_data['responsible']
self.object.is_template = f.cleaned_data['is_template']
self.object.save()
except ValidationError as v_err:
f.add_error('storage_name', '. '.join(v_err.messages))
context = self.get_context_data(**kwargs)
context['change_storage_form'] = f
return self.render_to_response(context)
def handle_del_storage_post(self, request, **kwargs):
parent = self.object.parent_storage
try:
@@ -532,6 +558,7 @@ class StockViewDetail(LoginRequiredMixin, BaseTemplateMixin, DetailView):
return redirect('parts-stocks')
else:
return redirect(reverse('parts-stocks-detail', kwargs={'uuid':parent.id}))
def handle_del_stock_post(self, request, **kwargs):
del_error = None
if 'stock_uuid' in request.POST:
@@ -593,6 +620,8 @@ class StockViewDetail(LoginRequiredMixin, BaseTemplateMixin, DetailView):
if 'submit-add-storage' in request.POST:
return self.handle_add_storage_post(request, **kwargs)
elif 'submit-change-storage' in request.POST:
return self.handle_change_storage_post(request, **kwargs)
elif 'submit-delete-storage' in request.POST:
return self.handle_del_storage_post(request, **kwargs)
elif 'submit-delete-stock' in request.POST:
@@ -943,4 +972,12 @@ class ManufacturerDetailViewSet(LoginRequiredMixin, BaseTemplateMixin, DetailVie
elif 'submit-manufacturer-edit' in request.POST:
return self.edit_manufacturer(request)
return super().post(request, *args, **kwargs)
return super().post(request, *args, **kwargs)
def health_check_view(request) -> HttpResponse:
"""
Health checking view. Returns empty http response with HTTP status OK.
This will be used to check
"""
return HttpResponse(status=200)

View File

@@ -16,9 +16,13 @@ The following environment variables have to be set:
- DJANGO_MEDIA_URL
- DJANGO_MEDIA_ROOT
- DJANGO_POSTGRESQL_SOCKET
- DJANGO_POSTGRESQL_PORT
The following can be set
- DJANGO_POSTGRESQL_PW (assumed empty if missing)
- DJANGO_POSTGRESQL_USER (assmumed empty if mssing)
- DJANGO_SECURE_HSTS_SECONDS (defaults to 120)
- DJANGO_FORCE_DEV_MODE
"""
@@ -46,8 +50,11 @@ SECRET_KEY = get_env_value('DJANGO_SECRET_KEY')
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
if get_env_value('DJANGO_FORCE_DEV_MODE', default=False) == 'True':
DEBUG = True
ALLOWED_HOSTS = ['localhost', get_env_value('DJANGO_ALLOWED_HOST')]
ALLOWED_HOSTS = ['127.0.0.1', 'localhost', get_env_value('DJANGO_ALLOWED_HOST')]
# Application definition
@@ -138,6 +145,7 @@ DATABASES = {
'USER': db_user,
'PASSWORD': db_pw,
'HOST': get_env_value('DJANGO_POSTGRESQL_SOCKET'),
'PORT': get_env_value('DJANGO_POSTGRESQL_PORT'),
}
}
@@ -229,6 +237,6 @@ CRISPY_TEMPLATE_PACK = "bootstrap5"
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
SECURE_SSL_REDIRECT = True
SECURE_SSL_REDIRECT = False
SECURE_HSTS_SECONDS = get_env_value('DJANGO_SECURE_HSTS_SECONDS', default=120)
SECURE_HSTS_SECONDS = get_env_value('DJANGO_SECURE_HSTS_SECONDS', default=120)

View File

@@ -0,0 +1,2 @@
name;manufacturer;component_type;pref_distri;description;datasheet_link;package;image_url;storage_uuid;substorage_path;amount;lot;watermark;param:Resistance;param:Temperature coefficient;param:Tolerance;distri:Mouser
1K41;Phycomp;Resistor;;KVG - expired;;R0603;https://t3.ftcdn.net/jpg/02/95/44/22/360_F_295442295_OXsXOmLmqBUfZreTnGo9PREuAPSLQhff.jpg;a4909bb4-4d69-4e58-8fbd-fba4fa62d9fb;bew;1111;4000;0;1330;100;1;gggg
1 name manufacturer component_type pref_distri description datasheet_link package image_url storage_uuid substorage_path amount lot watermark param:Resistance param:Temperature coefficient param:Tolerance distri:Mouser
2 1K41 Phycomp Resistor KVG - expired R0603 https://t3.ftcdn.net/jpg/02/95/44/22/360_F_295442295_OXsXOmLmqBUfZreTnGo9PREuAPSLQhff.jpg a4909bb4-4d69-4e58-8fbd-fba4fa62d9fb bew 1111 4000 0 1330 100 1 gggg

View File

@@ -0,0 +1,14 @@
# The shimatta kenkyusho can import components from a CSV file uploaded to the website
All parameters are passed as names (e.g. package, manufacturer etc.).
Component parameters can be set using a prefix ``param:`` followed by the
parameter name. The value is then parsed bysed on the parameter type.
Distributor part numbers can be set similarly by prepending ``distri:``.
It is also possible to create initial stocks to one storage by passing the
storage uuid and/or the path to the storage (as printed in the breadcrumbs) or
a combination of a storage uuid and the path from this storage.
See example for details.

View File

@@ -12,9 +12,9 @@ function initialize_autocompletion_foreign_key_field(search_element) {
var name_field_name = search_element.getAttribute('data-ac-name-field');
var search_url = search_element.getAttribute('data-ac-url');
var base_id = search_element.getAttribute('id');
var uuid_field = search_element.parentElement.querySelector('#'+base_id+'-uuid-field');
var dflex_container = search_element.parentElement.querySelector('#'+base_id+'-dflex-container');
var initial_delete_button = search_element.parentElement.querySelector('[data-ac-delete]');
var uuid_field = search_element.parentElement.parentElement.querySelector('#'+base_id+'-uuid-field');
var dflex_container = search_element.parentElement.parentElement.querySelector('#'+base_id+'-dflex-container');
var initial_delete_button = search_element.parentElement.parentElement.querySelector('[data-ac-delete]');
console.log(initial_delete_button);
console.log(image_field_name);

View File

@@ -29,6 +29,10 @@ function api_search_user(search, onSuccess, onFail) {
return api_ajax_request_without_send('GET', api_urls_v1['user-list']+`?search=${encodeURIComponent(search)}`, function(method, url, json) {onSuccess(json);}, onFail);
}
function api_search_storage_template(search, onSuccess, onFail) {
return api_ajax_request_without_send('GET', api_urls_v1['storage-template-list']+`?search=${encodeURIComponent(search)}`, function(method, url, json) {onSuccess(json);}, onFail);
}
function api_search_component(search, onSuccess, onFail) {
return api_ajax_request_without_send('GET', api_urls_v1['component-list']+`?search=${encodeURIComponent(search)}`, function(method, url, json) {onSuccess(json);}, onFail);
}

View File

@@ -65,6 +65,7 @@
'user-list': '{% url 'user-list' %}',
'groups-list': '{% url 'user-list' %}',
'storage-list': '{% url 'storage-list' %}',
'storage-template-list': '{% url 'storage-template-list' %}',
'component-list': '{% url 'component-list' %}',
'package-list': '{% url 'package-list' %}',
'stock-list': '{% url 'stock-list' %}',
@@ -77,6 +78,11 @@
<script type="text/javascript" src="{% static 'js/kenyusho-api-v1.js' %}"></script>
<script type="text/javascript" src="{% static 'js/autocomplete.js' %}"></script>
<script type="text/javascript" src="{% static 'js/autocomplete-foreign-key-field.js' %}"></script>
<!-- Initialize bootstrap popovers -->
<script type="text/javascript">
const popoverTriggerList = document.querySelectorAll('[data-bs-toggle="popover"]')
const popoverList = [...popoverTriggerList].map(popoverTriggerEl => new bootstrap.Popover(popoverTriggerEl))
</script>
{% block custom_scripts %}
{% endblock custom_scripts %}

View File

@@ -14,6 +14,7 @@
</button>
<button class="btn btn-secondary" type="button" data-bs-toggle="collapse" href="#advanced-search-collapse">Advanced <i class="bi bi-search"></i></button>
<button class="btn btn-success" type="button" data-bs-toggle="modal" data-bs-target="#comp-edit-modal"><i class="bi bi-plus-circle"></i> Add Component</button>
<button class="btn btn-success" type="button" data-bs-toggle="modal" data-bs-target="#comp-import-modal"><i class="bi bi-plus-circle"></i> Import CSV</button>
</div>
</form>
<div class="collapse mb-3{% if advanced_search_shown %} show{% endif %}" id="advanced-search-collapse" aria-expanded="{% if advanced_search_shown %}true{% else %}false{% endif %}">
@@ -64,6 +65,7 @@
</div>
{% include 'parts/modals/edit-component-modal.html' with form=comp_form heading='New Component' open_component_button=True %}
{% include 'parts/modals/import-component-modal.html' with form=import_comp_form %}
{% endblock content %}
{% block custom_scripts %}
@@ -72,5 +74,8 @@
{% if comp_form.errors %}
bootstrap.Modal.getOrCreateInstance(document.getElementById('comp-edit-modal')).show()
{% endif %}
{% if import_comp_form.errors %}
bootstrap.Modal.getOrCreateInstance(document.getElementById('comp-import-modal')).show()
{% endif %}
</script>
{% endblock custom_scripts %}

View File

@@ -0,0 +1,22 @@
{% load static %}
{% load crispy_forms_tags %}
<div class="modal fade" id="add-sub-modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Add Storage</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
<div class="modal-body">
{{form|crispy}}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<input type="submit" class="btn btn-primary" value="Add Storage" name="submit-add-storage">
</div>
</form>
</div>
</div>
</div>

View File

@@ -0,0 +1,22 @@
{% load static %}
{% load crispy_forms_tags %}
<div class="modal fade" id="change-modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Change Storage</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
<div class="modal-body">
{{form|crispy}}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<input type="submit" class="btn btn-primary" value="Change Storage" name="submit-change-storage">
</div>
</form>
</div>
</div>
</div>

View File

@@ -0,0 +1,38 @@
{% load static %}
{% load crispy_forms_tags %}
<div class="modal fade" id="comp-import-modal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h2>Import Component CSV</h2>
<button type="button"
class="btn"
data-bs-toggle="popover"
data-bs-title="Import Component CSV"
data-bs-html="true"
data-bs-content="The shimatta kenkyusho can import components from a CSV file uploaded to the website.<br>
All parameters are passed as names (e.g. package, manufacturer etc.).<br><br>
Component parameters can be set using a prefix <code>param:</code> followed by the
parameter name. The value is then parsed bysed on the parameter type.<br><br>
Distributor part numbers can be set similarly by prepending <code>distri:</code>.<br><br>
It is also possible to create initial stocks to one storage by passing the
storage uuid and/or the path to the storage (as printed in the breadcrumbs) or
a combination of a storage uuid and the path from this storage.<br><br>
See <a href='{% static 'example/import_csv/import_csv.csv' %}'>example</a> for details.">
<i class="bi bi-info-circle"></i>
</button>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
<div class="modal-body">
{{form|crispy}}
</div>
<div class="modal-footer">
<input type="submit" name="submit-import-components" class="btn btn-primary" value="Save">
</div>
</form>
</div>
</div>
</div>

View File

@@ -1,46 +0,0 @@
{% load static %}
<div class="modal fade" id="add-sub-modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Add Storage</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<form action="" method="post">
{% csrf_token %}
<div class="modal-body">
<label for="add-storage-name" class="form-label">Storage Name</label>
<div class="input-group has-validation">
<input value="{{form.storage_name.value}}" class="form-control{% if form.storage_name.errors or form.non_field_errors %} is-invalid{% endif %}" id="add-storage-name" name="{{form.storage_name.name}}" type="text" aria-describedby="validationStorageName" required>
<div id="validationStorageName" class="invalid-feedback">
{% for msg in form.storage_name.errors %}
{{msg}}
{% endfor %}
</div>
</div>
<label for="{{form.responsible.id_for_label}}">Responsible</label>
<div class="input-group has-validation dropdown">
<span class="input-group-text" id="add_storage_username_prepend">@</span><input autocomplete="off" data-bs-toggle="dropdown" type="text" value="{{form.responsible.value}}" class="form-control{% if form.responsible.errors or form.non_field_errors %} is-invalid{% endif %}" id="{{form.responsible.id_for_label}}" name="{{form.responsible.name}}" aria-describedby="add_storage_username_prepend validationServerUsernameFeedback" required>
<ul class="dropdown-menu" aria-labelledby="{{form.responsible.id_for_label}}" id="{{form.responsible.id_for_label}}-ac-dropdown">
</ul>
<div id="validationServerUsernameFeedback" class="invalid-feedback">
{% for msg in form.responsible.errors %}
{{msg}}
{% endfor %}
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<input type="submit" class="btn btn-primary" value="Add Storage" name="submit-add-storage">
{% if form.non_field_errors %}
{% for error in form.non_field_errors %}
<p class="text-danger text-center">{{ error }}</p>
{% endfor %}
{% endif %}
</div>
</form>
</div>
</div>
</div>

View File

@@ -20,6 +20,9 @@
<div class="row">
{% qr_from_text object.get_qr_code size="m" image_format="svg" %}
</div>
<div class="row">
<h4>{{storage.name}}{% if storage.verbose_name %}<small> ({{storage.verbose_name}})</small>{% endif %}</h4>
</div>
<div class="row">
{% if object.parent_storage %}
<h1>Sub-Storages <a class="btn btn-secondary" href="{% url 'parts-stocks-detail' uuid=object.parent_storage.id %}">Parent Storage</a> {% else %}
@@ -27,13 +30,14 @@
{% endif %}
<button type="button" class="btn btn-danger" data-bs-toggle="modal" data-bs-target="#delete-storage-modal">Delete</button>
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#add-sub-modal"><i class="bi bi-plus-circle"></i></button>
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#change-modal"><i class="bi bi-pen-fill"></i></button>
</h1>
<div class="list-group">
{% for storage in storages %}
<a href="{% url 'parts-stocks-detail' uuid=storage.id %}" class="text-decoration-none">
<li class="list-group-item list-group-item-action justify-content-between align-items-center d-flex">
<div>
<h5>{{storage.name}}</h5>
<h5>{{storage.name}}{% if storage.verbose_name %}<small> ({{storage.verbose_name}})</small>{% endif %}</h5>
Responsible: {{ storage.responsible }}
</div>
<span class="badge bg-primary rounded-pill">{{storage.get_total_stock_amount}}</span>
@@ -109,7 +113,11 @@
{% endfor %}
<!-- Modal for adding a substorage-->
{% with add_storage_form as form %}
{% include 'parts/modals/new-substorage-modal.html' %}
{% include 'parts/modals/add-substorage-modal.html' %}
{% endwith %}
<!-- Modal to change current storag-->
{% with change_storage_form as form %}
{% include 'parts/modals/change-storage-modal.html' %}
{% endwith %}
<!-- Modal for deleting this storage -->
{% with delete_storage_errors as err_msgs %}
@@ -158,18 +166,6 @@ api_get_component_from_id(uuid, function(component){
}
{% endif %}
new AutocompleteText('{{add_storage_form.responsible.id_for_label}}', '{{add_storage_form.responsible.id_for_label}}-ac-dropdown',
function(search, autocomplete_obj) {
api_search_user(search, function(results) {
var usernames = new Array();
console.log(results);
for (var i = 0; i < results.results.length; i++) {
usernames.push(results.results[i].username);
}
console.log(usernames);
autocomplete_obj.show_results(usernames);
}, function(){});
});
</script>
{% endblock custom_scripts %}

View File

@@ -40,7 +40,7 @@
<a href="{% url 'parts-stocks-detail' uuid=storage.id %}" class="text-decoration-none">
<li class="list-group-item list-group-item-action justify-content-between align-items-center d-flex">
<div>
<h5>{{storage.name}}</h5>
<h5>{{storage.name}}{% if storage.verbose_name %}<small> ({{storage.verbose_name}})</small>{% endif %}</h5>
Responsible: {{ storage.responsible }}
</div>
<span class="badge bg-primary rounded-pill">{{storage.get_total_stock_amount}}</span>
@@ -54,7 +54,7 @@
<!-- Add storage modal form -->
{% with add_storage_form as form %}
{% include 'parts/modals/new-substorage-modal.html' %}
{% include 'parts/modals/add-substorage-modal.html' %}
{% endwith %}
</div>
@@ -67,18 +67,6 @@
var modal = bootstrap.Modal.getOrCreateInstance(addSubStorageModal);
modal.show();
{% endif %}
new AutocompleteText('{{add_storage_form.responsible.id_for_label}}', '{{add_storage_form.responsible.id_for_label}}-ac-dropdown',
function(search, autocomplete_obj) {
api_search_user(search, function(results) {
var usernames = new Array();
console.log(results);
for (var i = 0; i < results.results.length; i++) {
usernames.push(results.results[i].username);
}
console.log(usernames);
autocomplete_obj.show_results(usernames);
}, function(){});
});
</script>
{% endblock custom_scripts %}

View File

@@ -1,7 +1,12 @@
<div class="dropdown">
<input autocomplete="off" id="{{widget.attrs.id}}" data-ac-url="{{custom.search_url}}" data-ac-name-field="{{custom.name_field_name}}" {% if custom.image_field_name %}data-ac-image-field="{{custom.image_field_name}}"{% endif %} data-bs-toggle="dropdown" type="text" placeholder="Search..." class="{{widget.attrs.class}}">
<ul id="{{widget.attrs.id}}-ac-ul" class="dropdown-menu">
</ul>
<div class="input-group">
{% if custom.prepend %}
<span class="input-group-text" id="{{widget.attrs.id}}-prepend">{{custom.prepend}}</span>
{% endif %}
<input autocomplete="off" id="{{widget.attrs.id}}" data-ac-url="{{custom.search_url}}" data-ac-name-field="{{custom.name_field_name}}" {% if custom.image_field_name %}data-ac-image-field="{{custom.image_field_name}}"{% endif %} data-bs-toggle="dropdown" type="text" placeholder="Search..." class="{{widget.attrs.class}}">
<ul id="{{widget.attrs.id}}-ac-ul" class="dropdown-menu">
</ul>
</div>
<div class="d-flex align-items-center mt-3 mb-3" id="{{widget.attrs.id}}-dflex-container">
{% if custom.current_instance %}
{% if custom.image_field_name %}

View File

@@ -0,0 +1,7 @@
#!/bin/bash
# Startup the db container
docker-compose start shimatta-kenkyusho-db
# Override entrypoint to get interactive shell
docker-compose run --entrypoint="/bin/sh" -p 8000:8000 shimatta-kenkyusho-web

1
start_server.sh Executable file
View File

@@ -0,0 +1 @@
podman run -it -e DJANGO_SECRET_KEY=<secret_key> -e DJANGO_ALLOWED_HOST=parts.shimatta.net -e DJANGO_STATIC_ROOT=/var/static -e DJANGO_MEDIA_URL=media -e DJANGO_MEDIA_ROOT=/var/media -e DJANGO_POSTGRESQL_SOCKET=host.docker.internal -e DJANGO_POSTGRESQL_PORT=2345 -e DJANGO_POSTGRESQL_USER=<db_user> -e DJANGO_POSTGRESQL_PW=<db_pass> -v /var/parts/static:/var/static -v /var/parts/media:/var/media -p 8000:8000 --entrypoint /bin/sh localhost/kenkyusho:0.1