-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Restructure stations and lines apps by removing unused files, a…
…dding new models, and enhancing admin configurations
- Loading branch information
1 parent
75188da
commit 6d2be92
Showing
19 changed files
with
189 additions
and
54 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,48 @@ | ||
# apps/stations/admin.py | ||
|
||
from django.contrib import admin | ||
from .models import Line, Station, LineStation | ||
|
||
class LineStationInline(admin.TabularInline): | ||
""" | ||
Inline admin for LineStation to manage the relationship between lines and stations. | ||
""" | ||
model = LineStation | ||
extra = 1 | ||
fields = ["station", "order"] | ||
ordering = ["order"] | ||
|
||
|
||
@admin.register(Line) | ||
class LineAdmin(admin.ModelAdmin): | ||
""" | ||
Admin configuration for the Line model. | ||
""" | ||
list_display = ("name", "color_code", "total_stations") | ||
search_fields = ("name",) | ||
inlines = [LineStationInline] | ||
|
||
|
||
@admin.register(Station) | ||
class StationAdmin(admin.ModelAdmin): | ||
""" | ||
Admin configuration for the Station model. | ||
""" | ||
list_display = ("name", "latitude", "longitude", "is_interchange") | ||
search_fields = ("name",) | ||
inlines = [LineStationInline] # Use the inline for managing lines | ||
fieldsets = ( | ||
(None, { | ||
"fields": ("name", "latitude", "longitude"), | ||
}), | ||
) | ||
|
||
|
||
# Register your models here. | ||
@admin.register(LineStation) | ||
class LineStationAdmin(admin.ModelAdmin): | ||
""" | ||
Admin configuration for the LineStation model. | ||
""" | ||
list_display = ("line", "station", "order") | ||
list_filter = ("line",) | ||
ordering = ["line", "order"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Generated by Django 5.1.3 on 2024-12-11 19:48 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Line', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('name', models.CharField(max_length=255, unique=True)), | ||
('color_code', models.CharField(blank=True, help_text='Format: #RRGGBB', max_length=10, null=True)), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='LineStation', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('order', models.PositiveIntegerField()), | ||
('line', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='line_stations', to='stations.line')), | ||
], | ||
options={ | ||
'ordering': ['order'], | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='Station', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('name', models.CharField(max_length=255, unique=True)), | ||
('latitude', models.FloatField(blank=True, null=True)), | ||
('longitude', models.FloatField(blank=True, null=True)), | ||
('lines', models.ManyToManyField(related_name='stations', through='stations.LineStation', to='stations.line')), | ||
], | ||
), | ||
migrations.AddField( | ||
model_name='linestation', | ||
name='station', | ||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='station_lines', to='stations.station'), | ||
), | ||
migrations.AlterUniqueTogether( | ||
name='linestation', | ||
unique_together={('line', 'station')}, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# This file marks the directory as a Python package. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# apps/stations/services/route_service.py | ||
|
||
from collections import defaultdict | ||
import heapq | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.