* Vietnamese translation incomplete

Transport forms

Transport forms (English fallback)

Aug. 17, 2025

Posted by admin

Nhom

Notes

 

Transport Forms - Detailed Analysis and Usage

Current Form Structure

The forms.py file contains a single form class:

from django import forms

from .models import TransportNegotiationOffer

class TransportNegotiationOfferForm(forms.ModelForm):

    class Meta:

        model = TransportNegotiationOffer

        fields = ['price', 'notes']

        widgets = {

            'notes': forms.Textarea(attrs={'rows': 2}),

 

 

Form Analysis and Issues

1. TransportNegotiationOfferForm

Purpose: This form was designed to handle negotiation offers for transport services (flights and transit options).

Current Status: ⚠️ Potentially Broken - The form references a model TransportNegotiationOffer that appears to have been created in migrations but is not currently present in the models.py file.

Form Fields:

  • price: DecimalField for the negotiated price offer
  • notes: TextField with custom widget (Textarea with 2 rows) for additional offer details

Widget Customization:

  • The notes field uses a custom Textarea widget with reduced height (2 rows) for better UI experience

Missing Model Issue

From the migration files, the TransportNegotiationOffer model was designed with these fields:

  • id: Primary key
  • price: DecimalField(max_digits=10, decimal_places=2)
  • notes: TextField(blank=True)
  • accepted: BooleanField(default=False)
  • created_at: DateTimeField(auto_now_add=True)
  • submitted_by: ForeignKey to User
  • session: ForeignKey to TransportNegotiationSession

 

 

Current Form Usage in the System

1. Template Forms (HTML-based)

The transport system currently uses HTML-based forms in templates rather than Django ModelForms:

A. Flight Search Form (flight_search.html):

<form method="GET" action="{% url 'transport:flight_search' %}">

    <!-- Origin, destination, date selection -->

</form>

B. Transit Search Form (transit_search.html):

<form method="GET" action="{% url 'transport:transit_search' %}">

    <!-- Station selection, date, type filters -->

</form>

C. Transit Filter Form (transit_list.html):

<form method="GET" class="row g-3">

    <!-- Type and date filtering -->

</form>

2. Form Processing in Views

The views handle form data through GET parameters:

# Flight search processing

if request.GET.get('origin') and request.GET.get('destination'):

    origin_code = request.GET.get('origin')

    destination_code = request.GET.get('destination')

    departure_date = request.GET.get('departure_date')

# Transit search processing  

if request.GET.get('origin_station') and request.GET.get('destination_station'):

    origin_id = request.GET.get('origin_station')

    destination_id = request.GET.get('destination_station')

    departure_date = request.GET.get('departure_date')

 

 

Recommended Form Improvements

1. Fix the Missing Model Issue

Option A: Add the missing model back to models.py:

class TransportNegotiationOffer(models.Model):

    session = models.ForeignKey('TransportNegotiationSession', on_delete=models.CASCADE, related_name='offers')

    price = models.DecimalField(max_digits=10, decimal_places=2)

    notes = models.TextField(blank=True)

    accepted = models.BooleanField(default=False)

    created_at = models.DateTimeField(auto_now_add=True)

    submitted_by = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, null=True)

Option B: Update the form to use the existing NegotiationOffer model from the negotiations app.

2. Add Missing Search Forms

Create Django forms for better validation and security:

class FlightSearchForm(forms.Form):

    origin = forms.CharField(max_length=3, label="Origin Airport")

    destination = forms.CharField(max_length=3, label="Destination Airport") 

    departure_date = forms.DateField(widget=forms.DateInput(attrs={'type': 'date'}))

    passengers = forms.IntegerField(min_value=1, initial=1)

    

class TransitSearchForm(forms.Form):

    origin_station = forms.ModelChoiceField(queryset=TransportStation.objects.all())

    destination_station = forms.ModelChoiceField(queryset=TransportStation.objects.all())

    departure_date = forms.DateField(widget=forms.DateInput(attrs={'type': 'date'}))

    transit_type = forms.ChoiceField(choices=Transit.TYPE_CHOICES, required=False)

3. Add Booking Forms

class FlightBookingForm(forms.Form):

    passengers = forms.IntegerField(min_value=1, max_value=10)

    class_type = forms.ChoiceField(choices=[

        ('economy', 'Economy'),

        ('business', 'Business'), 

        ('first', 'First Class')

    ])

    special_requests = forms.CharField(widget=forms.Textarea(attrs={'rows': 3}), required=False)

class TransitBookingForm(forms.Form):

    passengers = forms.IntegerField(min_value=1, max_value=10)

    seat_preference = forms.ChoiceField(choices=[

        ('standard', 'Standard'),

        ('premium', 'Premium')

    ])

    special_requests = forms.CharField(widget=forms.Textarea(attrs={'rows': 3}), required=False)

  •  

 

 

Current System Architecture

Form Processing Flow:

  1. Search Phase: HTML forms → GET parameters → View processing → Template rendering
  2. Filter Phase: HTML forms → GET parameters → Queryset filtering → Results display
  3. Missing: Booking/Negotiation forms for actual transactions

Integration with Other Apps:

  • Negotiations App: Contains general NegotiationOffer model
  • Planner App: Likely integrates with transport for itinerary planning
  • Bookings App: Should handle actual transport bookings

 

 

Business Use Cases

Current Functionality:

  1. Search Flights: By origin/destination airports and date
  2. Search Transit: By stations, date, and transport type
  3. Filter Results: By type, date, and other criteria
  4. View Details: Individual flight/transit information

Missing Functionality:

  1. Booking Process: No forms for actual reservations
  2. Price Negotiation: Broken due to missing model
  3. User Preferences: No forms for saving search preferences
  4. Payment Integration: No payment forms

Recommendations

  1. Immediate: Fix the TransportNegotiationOffer model issue
  2. Short-term: Convert HTML forms to Django ModelForms for better validation
  3. Medium-term: Add booking and preference forms
  4. Long-term: Integrate with payment and user management systems

The current forms system is minimal and primarily relies on HTML forms with GET parameter processing, which works for search functionality but lacks the robustness needed for booking and negotiation features.

 

Vietnamese translation is not available for this article. Showing English content:

Nhom

Notes

 

Transport Forms - Detailed Analysis and Usage

Current Form Structure

The forms.py file contains a single form class:

from django import forms

from .models import TransportNegotiationOffer

class TransportNegotiationOfferForm(forms.ModelForm):

    class Meta:

        model = TransportNegotiationOffer

        fields = ['price', 'notes']

        widgets = {

            'notes': forms.Textarea(attrs={'rows': 2}),

 

 

Form Analysis and Issues

1. TransportNegotiationOfferForm

Purpose: This form was designed to handle negotiation offers for transport services (flights and transit options).

Current Status: ⚠️ Potentially Broken - The form references a model TransportNegotiationOffer that appears to have been created in migrations but is not currently present in the models.py file.

Form Fields:

  • price: DecimalField for the negotiated price offer
  • notes: TextField with custom widget (Textarea with 2 rows) for additional offer details

Widget Customization:

  • The notes field uses a custom Textarea widget with reduced height (2 rows) for better UI experience

Missing Model Issue

From the migration files, the TransportNegotiationOffer model was designed with these fields:

  • id: Primary key
  • price: DecimalField(max_digits=10, decimal_places=2)
  • notes: TextField(blank=True)
  • accepted: BooleanField(default=False)
  • created_at: DateTimeField(auto_now_add=True)
  • submitted_by: ForeignKey to User
  • session: ForeignKey to TransportNegotiationSession

 

 

Current Form Usage in the System

1. Template Forms (HTML-based)

The transport system currently uses HTML-based forms in templates rather than Django ModelForms:

A. Flight Search Form (flight_search.html):

<form method="GET" action="{% url 'transport:flight_search' %}">

    <!-- Origin, destination, date selection -->

</form>

B. Transit Search Form (transit_search.html):

<form method="GET" action="{% url 'transport:transit_search' %}">

    <!-- Station selection, date, type filters -->

</form>

C. Transit Filter Form (transit_list.html):

<form method="GET" class="row g-3">

    <!-- Type and date filtering -->

</form>

2. Form Processing in Views

The views handle form data through GET parameters:

# Flight search processing

if request.GET.get('origin') and request.GET.get('destination'):

    origin_code = request.GET.get('origin')

    destination_code = request.GET.get('destination')

    departure_date = request.GET.get('departure_date')

# Transit search processing  

if request.GET.get('origin_station') and request.GET.get('destination_station'):

    origin_id = request.GET.get('origin_station')

    destination_id = request.GET.get('destination_station')

    departure_date = request.GET.get('departure_date')

 

 

Recommended Form Improvements

1. Fix the Missing Model Issue

Option A: Add the missing model back to models.py:

class TransportNegotiationOffer(models.Model):

    session = models.ForeignKey('TransportNegotiationSession', on_delete=models.CASCADE, related_name='offers')

    price = models.DecimalField(max_digits=10, decimal_places=2)

    notes = models.TextField(blank=True)

    accepted = models.BooleanField(default=False)

    created_at = models.DateTimeField(auto_now_add=True)

    submitted_by = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, null=True)

Option B: Update the form to use the existing NegotiationOffer model from the negotiations app.

2. Add Missing Search Forms

Create Django forms for better validation and security:

class FlightSearchForm(forms.Form):

    origin = forms.CharField(max_length=3, label="Origin Airport")

    destination = forms.CharField(max_length=3, label="Destination Airport") 

    departure_date = forms.DateField(widget=forms.DateInput(attrs={'type': 'date'}))

    passengers = forms.IntegerField(min_value=1, initial=1)

    

class TransitSearchForm(forms.Form):

    origin_station = forms.ModelChoiceField(queryset=TransportStation.objects.all())

    destination_station = forms.ModelChoiceField(queryset=TransportStation.objects.all())

    departure_date = forms.DateField(widget=forms.DateInput(attrs={'type': 'date'}))

    transit_type = forms.ChoiceField(choices=Transit.TYPE_CHOICES, required=False)

3. Add Booking Forms

class FlightBookingForm(forms.Form):

    passengers = forms.IntegerField(min_value=1, max_value=10)

    class_type = forms.ChoiceField(choices=[

        ('economy', 'Economy'),

        ('business', 'Business'), 

        ('first', 'First Class')

    ])

    special_requests = forms.CharField(widget=forms.Textarea(attrs={'rows': 3}), required=False)

class TransitBookingForm(forms.Form):

    passengers = forms.IntegerField(min_value=1, max_value=10)

    seat_preference = forms.ChoiceField(choices=[

        ('standard', 'Standard'),

        ('premium', 'Premium')

    ])

    special_requests = forms.CharField(widget=forms.Textarea(attrs={'rows': 3}), required=False)

  •  

 

 

Current System Architecture

Form Processing Flow:

  1. Search Phase: HTML forms → GET parameters → View processing → Template rendering
  2. Filter Phase: HTML forms → GET parameters → Queryset filtering → Results display
  3. Missing: Booking/Negotiation forms for actual transactions

Integration with Other Apps:

  • Negotiations App: Contains general NegotiationOffer model
  • Planner App: Likely integrates with transport for itinerary planning
  • Bookings App: Should handle actual transport bookings

 

 

Business Use Cases

Current Functionality:

  1. Search Flights: By origin/destination airports and date
  2. Search Transit: By stations, date, and transport type
  3. Filter Results: By type, date, and other criteria
  4. View Details: Individual flight/transit information

Missing Functionality:

  1. Booking Process: No forms for actual reservations
  2. Price Negotiation: Broken due to missing model
  3. User Preferences: No forms for saving search preferences
  4. Payment Integration: No payment forms

Recommendations

  1. Immediate: Fix the TransportNegotiationOffer model issue
  2. Short-term: Convert HTML forms to Django ModelForms for better validation
  3. Medium-term: Add booking and preference forms
  4. Long-term: Integrate with payment and user management systems

The current forms system is minimal and primarily relies on HTML forms with GET parameter processing, which works for search functionality but lacks the robustness needed for booking and negotiation features.

 

Attached Files

0 files found.

You are viewing this article in public mode. Some features may be limited.