Add IntelliJ IDEA project configuration files

This commit adds IntelliJ IDEA-specific configuration files for the project, including module setup, version control integration, inspection profiles, and workspace settings. These files facilitate development environment configuration for contributors using IntelliJ IDEA.
This commit is contained in:
2025-06-30 18:06:35 +03:00
parent 72e0fc963c
commit daba5a8438
51 changed files with 2686 additions and 1377 deletions
+24
View File
@@ -0,0 +1,24 @@
from django.forms import ModelForm
from django.urls import reverse_lazy
from preinfo.models import Preinfo
class PreinfoBaseForm(ModelForm):
class Meta:
model = Preinfo
fields = '__all__'
# success_url = reverse_lazy('client_preinfo')
class PreinfoCreateForm(PreinfoBaseForm):
"""
Form for creating a new PreinfoModel instance.
Inherits from PreinfoBaseForm.
"""
class Meta(PreinfoBaseForm.Meta):
exclude = ['created_on',
'created_by',
'deleted',
'deleted_on',
'deleted_by',
'received'] # Exclude fields that should not be set by the user
+5 -4
View File
@@ -1,7 +1,7 @@
from django.db import models
# Create your models here.
class PreinfoModel(models.Model):
class Preinfo(models.Model):
container_number = models.CharField(
max_length=11,
)
@@ -17,18 +17,19 @@ class PreinfoModel(models.Model):
)
created_on = models.DateTimeField(auto_now_add=True)
created_by = models.ForeignKey(
'users.DepotUser',
'accounts.DepotUser',
on_delete=models.CASCADE,
related_name='preinfo_created_by',
db_column='created_by_id', # Ensure the column name matches your database schema
)
deleted = models.BooleanField(default=False, null=False)
deleted_by = models.ForeignKey(
'users.DepotUser',
'accounts.DepotUser',
on_delete=models.CASCADE,
related_name='preinfo_deleted_by',
db_column='deleted_by_id', # Ensure the column name matches your database schema
null=True,
blank=True
)
deleted_on = models.DateTimeField(null=True)
deleted_on = models.DateTimeField(null=True, blank=True)
received = models.BooleanField(default=False, null=False)
+8
View File
@@ -0,0 +1,8 @@
from django.urls import path
from preinfo.views import ClientPreinfoView, check_preinfo, PreinfoSearchView
urlpatterns = [
path('client/', ClientPreinfoView.as_view(), name='client_preinfo'),
path('check-preinfo/', check_preinfo, name='check_preinfo'),
path('preinfo-search/', PreinfoSearchView.as_view(), name='preinfo_search'),
]
+81 -2
View File
@@ -1,3 +1,82 @@
from django.shortcuts import render
from django.contrib.auth import get_user_model
from django.contrib.auth.mixins import LoginRequiredMixin
from django.forms import forms
from django.forms.widgets import HiddenInput
from django.http import JsonResponse
from django.shortcuts import render, redirect
from django.urls import reverse_lazy
from django.views import View
from django.views.generic import TemplateView, FormView, CreateView
# Create your views here.
from common.utils import filter_queryset_by_user, get_preinfo_by_number
from preinfo.forms import PreinfoBaseForm, PreinfoCreateForm
from preinfo.models import Preinfo
class ClientPreinfoView(LoginRequiredMixin, CreateView):
template_name = 'client-preinfo-content.html'
form_class = PreinfoCreateForm
success_url = reverse_lazy('client_preinfo')
model = Preinfo
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
queryset = self.model.objects.all().order_by('-created_on')
user = self.request.user
# !!! important
queryset = filter_queryset_by_user( queryset, user)[:10]
# !!! important
context['recent'] = queryset
return context
def get_form(self, form_class=None):
form = super().get_form(form_class)
user = self.request.user
# If user has a specific line, limit the line choices
if user.line:
form.fields['line'].queryset = form.fields['line'].queryset.filter(pk=user.line.pk)
form.fields['line'].initial = user.line
form.fields['line'].widget.attrs['disabled'] = True
# Keep the value when form is submitted
# form.fields['line'].widget = HiddenInput()
return form
def form_valid(self, form):
form.instance.created_by = self.request.user
return super().form_valid(form)
# Check if a preinfo exists for the given container number
def check_preinfo(request):
number = request.GET.get('number')
preinfo = Preinfo.objects.filter(container_number=number, received=False).first()
if preinfo:
return JsonResponse({
'found': True,
'line': preinfo.line.name,
'container_type': preinfo.container_type.name,
'preinfo_id': preinfo.id,
})
return JsonResponse({'found': False})
class PreinfoSearchView(View):
template_name = 'container-search.html'
def get(self, request):
return render(request, self.template_name)
def post(self, request):
number = request.POST.get('number')
preinfo = get_preinfo_by_number(number)
if preinfo:
next_url = request.POST.get('param')
return redirect(next_url, pk=preinfo.pk)
return render(request, self.template_name, {'error': 'Not found'})