You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.2 KiB
40 lines
1.2 KiB
from minibase.blueprints.geography.models import Country, City, State, Region, Subregion
|
|
import minibase.blueprints.database.utils as dbUtils
|
|
from sqlalchemy import case
|
|
|
|
def queryCountryNames():
|
|
choices = Country.query.order_by(Country.name.asc())
|
|
return choices
|
|
|
|
def queryCountryNamesWithDefault(defId):
|
|
choices = dbUtils.queryNameWithDefaultId(Country,defId)
|
|
return choices
|
|
|
|
|
|
def queryStateNames():
|
|
choices = State.query.order_by(State.name.asc())
|
|
return choices
|
|
|
|
def queryStateNamesWithDefault(defId):
|
|
choices = dbUtils.queryNameWithDefaultId(State,defId)
|
|
return choices
|
|
|
|
|
|
def queryCityNames():
|
|
choices = City.query.order_by(City.name.asc())
|
|
return choices
|
|
|
|
def queryCityNamesWithDefault(defId):
|
|
choices = dbUtils.queryNameWithDefaultId(City,defId)
|
|
return choices
|
|
|
|
def queryCiytNamesOfStateWithDefId(defId, Filterid):
|
|
table=City
|
|
choices = table.query.order_by(case((table.id == defId, 0),else_=1), table.name.asc()).filter_by(state_id=Filterid)
|
|
return choices
|
|
|
|
def queryStateNamesOfCuntryWithDefId(defId, Filterid):
|
|
table=State
|
|
choices = table.query.order_by(case((table.id == defId, 0),else_=1), table.name.asc()).filter_by(country_id=Filterid)
|
|
return choices
|