- api/convenience will hold convenience functions for database lookup and data grouping - pt_map/model_test_fields holds the data from the GTFS reference relevant to model development - pt_map/test_data holds example data to be used to test models
170 lines
4.5 KiB
Python
170 lines
4.5 KiB
Python
from pt_map.models import *
|
|
from pt_map.model_test_fields import field_requirements
|
|
|
|
def get_all_fields(model_name):
|
|
for m in field_requirements:
|
|
if m["model"] == model_name:
|
|
return m["fields"]
|
|
|
|
def get_required_fields(model_name):
|
|
required_fields = []
|
|
for field in get_all_fields(model_name):
|
|
if field["required"] == "true":
|
|
required_fields.append(field)
|
|
return required_fields
|
|
|
|
def get_optional_fields(model_name):
|
|
optional_fields = []
|
|
for field in get_all_fields(model_name):
|
|
if field["required"] == "false":
|
|
optional_fields.append(field)
|
|
return optional_fields
|
|
|
|
def get_conditionally_required_fields(model_name):
|
|
conditionally_required_fields = []
|
|
for field in get_all_fields(model_name):
|
|
if field["required"] == "if":
|
|
conditionally_required_fields.append(field)
|
|
return conditionally_required_fields
|
|
|
|
def get_conditionally_forbidden_fields(model_name):
|
|
conditionally_forbidden_fields = []
|
|
for field in get_all_fields(model_name):
|
|
if field.get("forbidden_if") or field.get("forbidden_if_not") or field.get("forbidden_if_eq") or field.get("forbidden_if_not_eq"):
|
|
conditionally_forbidden_fields.append(field)
|
|
return conditionally_forbidden_fields
|
|
|
|
data = [
|
|
{
|
|
"name": "Fulton Conley",
|
|
"telephone": "1-538-373-2858",
|
|
"email": "duis@google.net",
|
|
"url": "http://bbc.co.uk",
|
|
"pk": "WKQ42OFT7XX",
|
|
"str": "tincidunt orci quis lectus. Nullam suscipit, est ac",
|
|
"time": "00:34:56",
|
|
"date": "20231223",
|
|
"curcode": "TRY",
|
|
"timezone": "Europe/Paris",
|
|
"langcode": "ZO"
|
|
},
|
|
{
|
|
"name": "Donna Collins",
|
|
"telephone": "1-858-166-4735",
|
|
"email": "arcu.vestibulum.ante@yahoo.org",
|
|
"url": "http://youtube.com",
|
|
"pk": "TEP72JJR8XE",
|
|
"str": "gravida molestie arcu. Sed eu nibh vulputate mauris",
|
|
"time": "04:14:54",
|
|
"date": "20240903",
|
|
"curcode": "HKD",
|
|
"timezone": "Africa/Abidjan",
|
|
"langcode": "RQ"
|
|
},
|
|
{
|
|
"name": "Tad Jensen",
|
|
"telephone": "(767) 770-8531",
|
|
"email": "dolor.egestas.rhoncus@icloud.com",
|
|
"url": "http://baidu.com",
|
|
"pk": "UVO18XXG8IB",
|
|
"str": "montes, nascetur ridiculus mus. Aenean eget magna. Suspendisse tristique",
|
|
"time": "20:27:48",
|
|
"date": "20240322",
|
|
"curcode": "KZT",
|
|
"timezone": "Europe/Paris",
|
|
"langcode": "GI"
|
|
},
|
|
{
|
|
"name": "Calvin Harrison",
|
|
"telephone": "1-547-884-7735",
|
|
"email": "etiam.laoreet@google.net",
|
|
"url": "https://instagram.com",
|
|
"pk": "NCV69RJX3HR",
|
|
"str": "aptent taciti sociosqu ad litora",
|
|
"time": "18:55:30",
|
|
"date": "20240720",
|
|
"curcode": "PLN",
|
|
"timezone": "Asia/Atyrau",
|
|
"langcode": "DP"
|
|
},
|
|
{
|
|
"name": "Phillip Britt",
|
|
"telephone": "(445) 832-4949",
|
|
"email": "nulla.tincidunt@protonmail.net",
|
|
"url": "http://naver.com",
|
|
"pk": "HGW71LUD1QL",
|
|
"str": "ultricies dignissim",
|
|
"time": "00:42:36",
|
|
"date": "20230627",
|
|
"curcode": "CHF",
|
|
"timezone": "Africa/Addis_Ababa",
|
|
"langcode": "CB"
|
|
},
|
|
{
|
|
"name": "Branden Leblanc",
|
|
"telephone": "(621) 519-7201",
|
|
"email": "erat.etiam@google.edu",
|
|
"url": "https://google.com",
|
|
"pk": "BIT71WZZ5MT",
|
|
"str": "Nunc pulvinar arcu et pede.",
|
|
"time": "13:57:23",
|
|
"date": "20250116",
|
|
"curcode": "MUR",
|
|
"timezone": "Asia/Atyrau",
|
|
"langcode": "YD"
|
|
},
|
|
{
|
|
"name": "Bradley Larson",
|
|
"telephone": "1-699-788-9354",
|
|
"email": "et.commodo@icloud.edu",
|
|
"url": "https://whatsapp.com",
|
|
"pk": "UON48QSJ0RD",
|
|
"str": "dui,",
|
|
"time": "01:26:35",
|
|
"date": "20231004",
|
|
"curcode": "EUR",
|
|
"timezone": "Europe/Berlin",
|
|
"langcode": "BU"
|
|
},
|
|
{
|
|
"name": "Scarlet Patterson",
|
|
"telephone": "(451) 444-7817",
|
|
"email": "scelerisque.scelerisque@outlook.edu",
|
|
"url": "http://wikipedia.org",
|
|
"pk": "LHE29UCR4BJ",
|
|
"str": "lacus. Cras",
|
|
"time": "13:51:51",
|
|
"date": "20240602",
|
|
"curcode": "SEK",
|
|
"timezone": "Asia/Damascus",
|
|
"langcode": "DY"
|
|
},
|
|
{
|
|
"name": "Latifah Alvarez",
|
|
"telephone": "(266) 713-8186",
|
|
"email": "mauris.magna@icloud.edu",
|
|
"url": "https://youtube.com",
|
|
"pk": "VOQ57DYR9CU",
|
|
"str": "orci tincidunt adipiscing. Mauris molestie pharetra nibh. Aliquam ornare,",
|
|
"time": "03:54:44",
|
|
"date": "20240923",
|
|
"curcode": "XCD",
|
|
"timezone": "Africa/Addis_Ababa",
|
|
"langcode": "OT"
|
|
},
|
|
{
|
|
"name": "Thane Moran",
|
|
"telephone": "1-674-463-6771",
|
|
"email": "odio.etiam.ligula@icloud.edu",
|
|
"url": "https://pinterest.com",
|
|
"pk": "CGR74BDF1DH",
|
|
"str": "eu metus. In lorem. Donec elementum,",
|
|
"time": "15:58:50",
|
|
"date": "20231225",
|
|
"curcode": "RUB",
|
|
"timezone": "Africa/Abidjan",
|
|
"langcode": "KS"
|
|
}
|
|
]
|
|
|