Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CSCI 41 Project
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patricia Isabella Nava
CSCI 41 Project
Commits
c14d0c68
Commit
c14d0c68
authored
Dec 01, 2022
by
Patricia Isabella Nava
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: add subtotal to attributes of Booking_AddItem
parent
74fd40aa
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
3 deletions
+17
-3
admin.py
MagisAir/booking/admin.py
+2
-2
models.py
MagisAir/booking/models.py
+15
-1
No files found.
MagisAir/booking/admin.py
View file @
c14d0c68
...
...
@@ -10,7 +10,7 @@ class PassengerAdmin(admin.ModelAdmin):
class
BookingAdmin
(
admin
.
ModelAdmin
):
model
=
Booking
list_display
=
(
'Booking_ID'
,
'Booking_Date'
,
'
Total_Cost'
,
'Passenger
'
)
list_display
=
(
'Booking_ID'
,
'Booking_Date'
,
'
Passenger'
,
'Total_Cost
'
)
class
Sched_CrewAdmin
(
admin
.
ModelAdmin
):
model
=
Sched_Crew
...
...
@@ -42,7 +42,7 @@ class Booking_SchedAdmin(admin.ModelAdmin):
class
Booking_AddItemAdmin
(
admin
.
ModelAdmin
):
model
=
Booking_AddItem
list_display
=
(
'Booking_ID'
,
'AddItem_Desc'
,
'Quantity'
)
list_display
=
(
'Booking_ID'
,
'AddItem_Desc'
,
'Quantity'
,
'subtotal'
)
class
PilotAdmin
(
admin
.
ModelAdmin
):
model
=
Pilot
...
...
MagisAir/booking/models.py
View file @
c14d0c68
from
django.db
import
models
from
django.http
import
Http404
from
django.core.validators
import
RegexValidator
,
EmailValidator
# Create your models here.
...
...
@@ -34,9 +35,13 @@ class Passenger(models.Model):
class
Booking
(
models
.
Model
):
Booking_ID
=
models
.
AutoField
(
primary_key
=
True
,
editable
=
False
,
unique
=
True
)
Booking_Date
=
models
.
DateField
(
null
=
True
,
blank
=
True
)
Total_Cost
=
models
.
CharField
(
max_length
=
100
)
Total_Cost
=
models
.
IntegerField
(
blank
=
True
,
default
=
0
,
null
=
False
)
Passenger
=
models
.
ForeignKey
(
Passenger
,
on_delete
=
models
.
CASCADE
)
def
__str__
(
self
):
return
str
(
self
.
Booking_ID
)
class
Additional_Item
(
models
.
Model
):
Description
=
models
.
CharField
(
max_length
=
50
,
primary_key
=
True
,
editable
=
True
,
unique
=
True
)
Item_Cost
=
models
.
IntegerField
(
default
=
0
)
...
...
@@ -52,6 +57,15 @@ class Booking_AddItem(models.Model):
AddItem_Desc
=
models
.
ForeignKey
(
Additional_Item
,
on_delete
=
models
.
CASCADE
)
Quantity
=
models
.
IntegerField
(
default
=
0
)
@
property
def
subtotal
(
self
):
add_item
=
Additional_Item
.
objects
.
get
(
Description
=
self
.
AddItem_Desc
)
itemcost
=
add_item
.
Item_Cost
subtotal
=
itemcost
*
self
.
Quantity
return
subtotal
class
City
(
models
.
Model
):
Airport_Code
=
models
.
AutoField
(
primary_key
=
True
,
editable
=
False
,
unique
=
True
)
Airport_name
=
models
.
CharField
(
max_length
=
50
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment