-
-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #398 from RyanPark44/387-feature-convert-the-unit-…
…property-into-a-db-model [FEAT] Convert the Unit property into a db Unit model
- Loading branch information
Showing
7 changed files
with
83 additions
and
8 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from ..core import CrudMixin, db | ||
from sqlalchemy.ext.associationproxy import association_proxy | ||
|
||
|
||
class Unit(db.Model, CrudMixin): | ||
id = db.Column(db.Integer, primary_key=True) | ||
name = db.Column(db.Text) | ||
website_url = db.Column(db.Text) | ||
phone = db.Column(db.Text) | ||
email = db.Column(db.Text) | ||
description = db.Column(db.Text) | ||
address = db.Column(db.Text) | ||
zip = db.Column(db.Text) | ||
agency_url = db.Column(db.Text) | ||
officers_url = db.Column(db.Text) | ||
|
||
commander_id = db.Column(db.Integer, db.ForeignKey('officer.id')) | ||
agency_id = db.Column(db.Integer, db.ForeignKey('agency.id')) | ||
|
||
agency = db.relationship("Agency", back_populates="units") | ||
officer_association = db.relationship('Employment', back_populates='unit') | ||
officers = association_proxy('officer_association', 'officer') | ||
|
||
def __repr__(self): | ||
return f"<Unit {self.name}>" |
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