()
| 2 | |
| 3 | |
| 4 | def initialize(): |
| 5 | human = Character(name="Human") |
| 6 | human.save() |
| 7 | |
| 8 | droid = Character(name="Droid") |
| 9 | droid.save() |
| 10 | |
| 11 | rebels = Faction(id="1", name="Alliance to Restore the Republic", hero=human) |
| 12 | rebels.save() |
| 13 | |
| 14 | empire = Faction(id="2", name="Galactic Empire", hero=droid) |
| 15 | empire.save() |
| 16 | |
| 17 | xwing = Ship(id="1", name="X-Wing", faction=rebels) |
| 18 | xwing.save() |
| 19 | |
| 20 | human.ship = xwing |
| 21 | human.save() |
| 22 | |
| 23 | ywing = Ship(id="2", name="Y-Wing", faction=rebels) |
| 24 | ywing.save() |
| 25 | |
| 26 | awing = Ship(id="3", name="A-Wing", faction=rebels) |
| 27 | awing.save() |
| 28 | |
| 29 | # Yeah, technically it's Corellian. But it flew in the service of the rebels, |
| 30 | # so for the purposes of this demo it's a rebel ship. |
| 31 | falcon = Ship(id="4", name="Millennium Falcon", faction=rebels) |
| 32 | falcon.save() |
| 33 | |
| 34 | homeOne = Ship(id="5", name="Home One", faction=rebels) |
| 35 | homeOne.save() |
| 36 | |
| 37 | tieFighter = Ship(id="6", name="TIE Fighter", faction=empire) |
| 38 | tieFighter.save() |
| 39 | |
| 40 | tieInterceptor = Ship(id="7", name="TIE Interceptor", faction=empire) |
| 41 | tieInterceptor.save() |
| 42 | |
| 43 | executor = Ship(id="8", name="Executor", faction=empire) |
| 44 | executor.save() |
| 45 | |
| 46 | |
| 47 | def create_ship(ship_name, faction_id): |
searching dependent graphs…