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.master
parent
daba5a8438
commit
da83ae7afc
@ -0,0 +1,19 @@
|
||||
from django import forms
|
||||
|
||||
from booking.models import Booking
|
||||
|
||||
|
||||
class BookingBaseForm(forms.ModelForm):
|
||||
"""
|
||||
Base form for booking-related forms.
|
||||
This can be extended by other booking forms.
|
||||
"""
|
||||
|
||||
class Meta:
|
||||
fields = '__all__'
|
||||
model = Booking
|
||||
|
||||
class BookingCreateForm(BookingBaseForm):
|
||||
|
||||
class Meta(BookingBaseForm.Meta):
|
||||
fields = ['number', 'vehicles', 'container_type', 'container_count', 'carrier', 'line', 'container_number']
|
||||
@ -0,0 +1,7 @@
|
||||
from django.urls import path
|
||||
|
||||
from booking.views import CreateBookingView
|
||||
|
||||
urlpatterns = [
|
||||
path('client/', CreateBookingView.as_view(), name='client_booking'),
|
||||
]
|
||||
@ -1,14 +1,35 @@
|
||||
from django.shortcuts import render
|
||||
from django.urls import reverse_lazy
|
||||
from django.views.generic import CreateView
|
||||
|
||||
from booking.forms import BookingCreateForm
|
||||
from booking.models import Booking
|
||||
from common.utils import filter_queryset_by_user
|
||||
|
||||
|
||||
# Create your views here.
|
||||
class CreateBookingView(CreateView):
|
||||
template_name = 'create-booking.html'
|
||||
extra_context = {
|
||||
'title': 'Create Booking',
|
||||
'description': 'This is the create booking page.',
|
||||
}
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
return render(request, self.template_name, self.extra_context)
|
||||
template_name = 'client-booking-content.html'
|
||||
model = Booking
|
||||
form_class = BookingCreateForm
|
||||
success_url = reverse_lazy('dashboard')
|
||||
|
||||
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 form_valid(self, form):
|
||||
# todo more validation
|
||||
form.instance.created_by = self.request.user.id
|
||||
form.instance.updated_by = self.request.user.id
|
||||
if self.request.user.line:
|
||||
form.instance.line = self.request.user.line
|
||||
return super().form_valid(form)
|
||||
Loading…
Reference in New Issue