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
0e371d5e
Commit
0e371d5e
authored
Dec 01, 2022
by
Alia Lawraine Olay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added ManytoManyField in Booking model
parent
d44dc515
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
32 additions
and
11 deletions
+32
-11
admin.cpython-310.pyc
MagisAir/booking/__pycache__/admin.cpython-310.pyc
+0
-0
models.cpython-310.pyc
MagisAir/booking/__pycache__/models.cpython-310.pyc
+0
-0
admin.py
MagisAir/booking/admin.py
+1
-1
0002_booking_additional_item.py
MagisAir/booking/migrations/0002_booking_additional_item.py
+18
-0
0002_booking_additional_item.cpython-310.pyc
.../__pycache__/0002_booking_additional_item.cpython-310.pyc
+0
-0
models.py
MagisAir/booking/models.py
+13
-10
db.sqlite3
MagisAir/db.sqlite3
+0
-0
No files found.
MagisAir/booking/__pycache__/admin.cpython-310.pyc
View file @
0e371d5e
No preview for this file type
MagisAir/booking/__pycache__/models.cpython-310.pyc
View file @
0e371d5e
No preview for this file type
MagisAir/booking/admin.py
View file @
0e371d5e
...
@@ -42,7 +42,7 @@ class Booking_SchedAdmin(admin.ModelAdmin):
...
@@ -42,7 +42,7 @@ class Booking_SchedAdmin(admin.ModelAdmin):
class
Booking_AddItemAdmin
(
admin
.
ModelAdmin
):
class
Booking_AddItemAdmin
(
admin
.
ModelAdmin
):
model
=
Booking_AddItem
model
=
Booking_AddItem
list_display
=
(
'Booking_ID'
,
'AddItem_Desc'
,
'Quantity'
,
'
s
ubtotal'
)
list_display
=
(
'Booking_ID'
,
'AddItem_Desc'
,
'Quantity'
,
'
S
ubtotal'
)
class
PilotAdmin
(
admin
.
ModelAdmin
):
class
PilotAdmin
(
admin
.
ModelAdmin
):
model
=
Pilot
model
=
Pilot
...
...
MagisAir/booking/migrations/0002_booking_additional_item.py
0 → 100644
View file @
0e371d5e
# Generated by Django 4.0.4 on 2022-12-01 05:22
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'booking'
,
'0001_initial'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'booking'
,
name
=
'Additional_Item'
,
field
=
models
.
ManyToManyField
(
through
=
'booking.Booking_AddItem'
,
to
=
'booking.additional_item'
),
),
]
MagisAir/booking/migrations/__pycache__/0002_booking_additional_item.cpython-310.pyc
0 → 100644
View file @
0e371d5e
File added
MagisAir/booking/models.py
View file @
0e371d5e
...
@@ -31,23 +31,25 @@ class Passenger(models.Model):
...
@@ -31,23 +31,25 @@ class Passenger(models.Model):
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
First_Name
+
' '
+
self
.
Last_Name
return
self
.
First_Name
+
' '
+
self
.
Last_Name
class
Additional_Item
(
models
.
Model
):
Description
=
models
.
CharField
(
max_length
=
50
,
primary_key
=
True
,
editable
=
True
,
unique
=
True
)
Item_Cost
=
models
.
IntegerField
(
default
=
0
)
def
__str__
(
self
):
return
self
.
Description
class
Booking
(
models
.
Model
):
class
Booking
(
models
.
Model
):
Booking_ID
=
models
.
AutoField
(
primary_key
=
True
,
editable
=
False
,
unique
=
True
)
Booking_ID
=
models
.
AutoField
(
primary_key
=
True
,
editable
=
False
,
unique
=
True
)
Booking_Date
=
models
.
DateField
(
null
=
True
,
blank
=
True
)
Booking_Date
=
models
.
DateField
(
null
=
True
,
blank
=
True
)
Total_Cost
=
models
.
IntegerField
(
blank
=
True
,
default
=
0
,
null
=
False
)
Total_Cost
=
models
.
IntegerField
(
blank
=
True
,
default
=
0
,
null
=
False
)
Passenger
=
models
.
ForeignKey
(
Passenger
,
on_delete
=
models
.
CASCADE
)
Passenger
=
models
.
ForeignKey
(
Passenger
,
on_delete
=
models
.
CASCADE
)
Additional_Item
=
models
.
ManyToManyField
(
Additional_Item
,
through
=
'Booking_AddItem'
)
def
__str__
(
self
):
def
__str__
(
self
):
return
str
(
self
.
Booking_ID
)
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
)
def
__str__
(
self
):
return
self
.
Description
class
Booking_AddItem
(
models
.
Model
):
class
Booking_AddItem
(
models
.
Model
):
class
Meta
:
class
Meta
:
...
@@ -56,13 +58,14 @@ class Booking_AddItem(models.Model):
...
@@ -56,13 +58,14 @@ class Booking_AddItem(models.Model):
Booking_ID
=
models
.
ForeignKey
(
Booking
,
on_delete
=
models
.
CASCADE
)
Booking_ID
=
models
.
ForeignKey
(
Booking
,
on_delete
=
models
.
CASCADE
)
AddItem_Desc
=
models
.
ForeignKey
(
Additional_Item
,
on_delete
=
models
.
CASCADE
)
AddItem_Desc
=
models
.
ForeignKey
(
Additional_Item
,
on_delete
=
models
.
CASCADE
)
Quantity
=
models
.
IntegerField
(
default
=
0
)
Quantity
=
models
.
IntegerField
(
default
=
0
)
Subtotal
=
models
.
IntegerField
(
default
=
0
,
editable
=
False
)
@
property
@
property
def
s
ubtotal
(
self
):
def
s
ave
(
self
):
add_item
=
Additional_Item
.
objects
.
get
(
Description
=
self
.
AddItem_Desc
)
add_item
=
Additional_Item
.
objects
.
get
(
Description
=
self
.
AddItem_Desc
)
itemcost
=
add_item
.
Item_Cost
itemcost
=
add_item
.
Item_Cost
subtotal
=
itemcost
*
self
.
Quantity
s
elf
.
s
ubtotal
=
itemcost
*
self
.
Quantity
return
su
btotal
return
su
per
()
.
save
()
...
...
MagisAir/db.sqlite3
View file @
0e371d5e
No preview for this file type
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