Compare commits

...

2 Commits

Author SHA1 Message Date
Ethan Paul ea564459f0
Add basic database structure 2022-02-07 22:49:38 -05:00
Ethan Paul 6e1bd3191a
Add database ORM dependencies 2022-02-07 22:49:18 -05:00
4 changed files with 334 additions and 1 deletions

28
poetry.lock generated
View File

@ -664,6 +664,25 @@ category = "dev"
optional = false
python-versions = ">=2.6"
[[package]]
name = "peewee"
version = "3.14.8"
description = "a little orm"
category = "main"
optional = false
python-versions = "*"
[[package]]
name = "peewee-plus"
version = "1.1.0"
description = "Various extensions, helpers, and utilities for Peewee"
category = "main"
optional = false
python-versions = ">=3.6.1,<4.0.0"
[package.dependencies]
peewee = ">=3.14.8,<4.0.0"
[[package]]
name = "pexpect"
version = "4.8.0"
@ -1182,7 +1201,7 @@ python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7"
[metadata]
lock-version = "1.1"
python-versions = "^3.10"
content-hash = "849bb4ca7f6c2b98e526bd6bee2b7d04058de337e1bba6caf56a6e81cb8a828b"
content-hash = "34a315e8100872c11d5de1aabd6411adef473a95c3cb9d63451482ca6067875a"
[metadata.files]
appnope = [
@ -1620,6 +1639,13 @@ pbr = [
{file = "pbr-5.8.1-py2.py3-none-any.whl", hash = "sha256:27108648368782d07bbf1cb468ad2e2eeef29086affd14087a6d04b7de8af4ec"},
{file = "pbr-5.8.1.tar.gz", hash = "sha256:66bc5a34912f408bb3925bf21231cb6f59206267b7f63f3503ef865c1a292e25"},
]
peewee = [
{file = "peewee-3.14.8.tar.gz", hash = "sha256:01bd7f734defb08d7a3346a0c0ca7011bc8d0d685934ec0e001b3371d522ec53"},
]
peewee-plus = [
{file = "peewee-plus-1.1.0.tar.gz", hash = "sha256:7507ef1ffe28b8755079fa6fc22dbc8b15353ed976a31d81ae50be52de61d68e"},
{file = "peewee_plus-1.1.0-py3-none-any.whl", hash = "sha256:979379be6f56a6c60e4c1fa5483a6d45417cc205fab2328a58bc1f30baecdd12"},
]
pexpect = [
{file = "pexpect-4.8.0-py2.py3-none-any.whl", hash = "sha256:0b48a55dcb3c05f3329815901ea4fc1537514d6ba867a152b581d69ae3710937"},
{file = "pexpect-4.8.0.tar.gz", hash = "sha256:fc65a43959d153d0114afe13997d439c22823a27cefceb5ff35c2178c6784c0c"},

View File

@ -16,6 +16,8 @@ readme = "README.md"
[tool.poetry.dependencies]
python = "^3.10"
peewee = "^3.14.8"
peewee-plus = "^1.1.0"
[tool.poetry.dev-dependencies]
bandit = "^1.6.2"

269
section7/constants.py Normal file
View File

@ -0,0 +1,269 @@
import enum
class PayRate(enum.Enum):
ANNUALY = enum.auto()
QUARTERLY = enum.auto()
MONTHLY = enum.auto()
WEEKLY = enum.auto()
DAILY = enum.auto()
HOURLY = enum.auto()
OTHER = enum.auto()
class Gender(enum.Enum):
MALE = enum.auto()
FEMALE = enum.auto()
NONBINARY = enum.auto()
OTHER = enum.auto()
class Country(enum.Enum):
AF = "Afghanistan"
AX = "Ã…land Islands"
AL = "Albania"
DZ = "Algeria"
AS = "American Samoa"
AD = "Andorra"
AO = "Angola"
AI = "Anguilla"
AQ = "Antarctica"
AG = "Antigua and Barbuda"
AR = "Argentina"
AM = "Armenia"
AW = "Aruba"
AU = "Australia"
AT = "Austria"
AZ = "Azerbaijan"
BS = "Bahamas"
BH = "Bahrain"
BD = "Bangladesh"
BB = "Barbados"
BY = "Belarus"
BE = "Belgium"
BZ = "Belize"
BJ = "Benin"
BM = "Bermuda"
BT = "Bhutan"
BO = "Plurinational State of Bolivia"
BQ = "Sint Eustatius and Saba Bonaire"
BA = "Bosnia and Herzegovina"
BW = "Botswana"
BV = "Bouvet Island"
BR = "Brazil"
IO = "British Indian Ocean Territory"
BN = "Brunei Darussalam"
BG = "Bulgaria"
BF = "Burkina Faso"
BI = "Burundi"
KH = "Cambodia"
CM = "Cameroon"
CA = "Canada"
CV = "Cape Verde"
KY = "Cayman Islands"
CF = "Central African Republic"
TD = "Chad"
CL = "Chile"
CN = "China"
CX = "Christmas Island"
CC = "Cocos (Keeling) Islands"
CO = "Colombia"
KM = "Comoros"
CG = "Congo"
CD = "the Democratic Republic of the Congo"
CK = "Cook Islands"
CR = "Costa Rica"
CI = "´te d'Ivoire"
HR = "Croatia"
CU = "Cuba"
CW = "Curaçao"
CY = "Cyprus"
CZ = "Czech Republic"
DK = "Denmark"
DJ = "Djibouti"
DM = "Dominica"
DO = "Dominican Republic"
EC = "Ecuador"
EG = "Egypt"
SV = "El Salvador"
GQ = "Equatorial Guinea"
ER = "Eritrea"
EE = "Estonia"
ET = "Ethiopia"
FK = "Falkland Islands (Malvinas)"
FO = "Faroe Islands"
FJ = "Fiji"
FI = "Finland"
FR = "France"
GF = "French Guiana"
PF = "French Polynesia"
TF = "French Southern Territories"
GA = "Gabon"
GM = "Gambia"
GE = "Georgia"
DE = "Germany"
GH = "Ghana"
GI = "Gibraltar"
GR = "Greece"
GL = "Greenland"
GD = "Grenada"
GP = "Guadeloupe"
GU = "Guam"
GT = "Guatemala"
GG = "Guernsey"
GN = "Guinea"
GW = "Guinea-Bissau"
GY = "Guyana"
HT = "Haiti"
HM = "Heard Island and McDonald Islands"
VA = "Holy See (Vatican City State)"
HN = "Honduras"
HK = "Hong Kong"
HU = "Hungary"
IS = "Iceland"
IN = "India"
ID = "Indonesia"
IR = "Islamic Republic of Iran"
IQ = "Iraq"
IE = "Ireland"
IM = "Isle of Man"
IL = "Israel"
IT = "Italy"
JM = "Jamaica"
JP = "Japan"
JE = "Jersey"
JO = "Jordan"
KZ = "Kazakhstan"
KE = "Kenya"
KI = "Kiribati"
KP = "Democratic People's Republic of Korea"
KR = "Republic of Korea"
KW = "Kuwait"
KG = "Kyrgyzstan"
LA = "Lao People's Democratic Republic"
LV = "Latvia"
LB = "Lebanon"
LS = "Lesotho"
LR = "Liberia"
LY = "Libya"
LI = "Liechtenstein"
LT = "Lithuania"
LU = "Luxembourg"
MO = "Macao"
MK = "the Former Yugoslav Republic of Macedonia"
MG = "Madagascar"
MW = "Malawi"
MY = "Malaysia"
MV = "Maldives"
ML = "Mali"
MT = "Malta"
MH = "Marshall Islands"
MQ = "Martinique"
MR = "Mauritania"
MU = "Mauritius"
YT = "Mayotte"
MX = "Mexico"
FM = "Federated States of Micronesia"
MD = "Republic of Moldova"
MC = "Monaco"
MN = "Mongolia"
ME = "Montenegro"
MS = "Montserrat"
MA = "Morocco"
MZ = "Mozambique"
MM = "Myanmar"
NA = "Namibia"
NR = "Nauru"
NP = "Nepal"
NL = "Netherlands"
NC = "New Caledonia"
NZ = "New Zealand"
NI = "Nicaragua"
NE = "Niger"
NG = "Nigeria"
NU = "Niue"
NF = "Norfolk Island"
MP = "Northern Mariana Islands"
NO = "Norway"
OM = "Oman"
PK = "Pakistan"
PW = "Palau"
PS = "State of Palestine"
PA = "Panama"
PG = "Papua New Guinea"
PY = "Paraguay"
PE = "Peru"
PH = "Philippines"
PN = "Pitcairn"
PL = "Poland"
PT = "Portugal"
PR = "Puerto Rico"
QA = "Qatar"
RE = "Réunion"
RO = "Romania"
RU = "Russian Federation"
RW = "Rwanda"
BL = "Saint Barthélemy"
SH = "Ascension and Tristan da Cunha Saint Helena"
KN = "Saint Kitts and Nevis"
LC = "Saint Lucia"
MF = "Saint Martin (French part)"
PM = "Saint Pierre and Miquelon"
VC = "Saint Vincent and the Grenadines"
WS = "Samoa"
SM = "San Marino"
ST = "Sao Tome and Principe"
SA = "Saudi Arabia"
SN = "Senegal"
RS = "Serbia"
SC = "Seychelles"
SL = "Sierra Leone"
SG = "Singapore"
SX = "Sint Maarten (Dutch part)"
SK = "Slovakia"
SI = "Slovenia"
SB = "Solomon Islands"
SO = "Somalia"
ZA = "South Africa"
GS = "South Georgia and the South Sandwich Islands"
SS = "South Sudan"
ES = "Spain"
LK = "Sri Lanka"
SD = "Sudan"
SR = "Suriname"
SJ = "Svalbard and Jan Mayen"
SZ = "Swaziland"
SE = "Sweden"
CH = "Switzerland"
SY = "Syrian Arab Republic"
TW = "Province of China Taiwan"
TJ = "Tajikistan"
TZ = "United Republic of Tanzania"
TH = "Thailand"
TL = "Timor-Leste"
TG = "Togo"
TK = "Tokelau"
TO = "Tonga"
TT = "Trinidad and Tobago"
TN = "Tunisia"
TR = "Turkey"
TM = "Turkmenistan"
TC = "Turks and Caicos Islands"
TV = "Tuvalu"
UG = "Uganda"
UA = "Ukraine"
AE = "United Arab Emirates"
GB = "United Kingdom"
US = "United States"
UM = "United States Minor Outlying Islands"
UY = "Uruguay"
UZ = "Uzbekistan"
VU = "Vanuatu"
VE = "Bolivarian Republic of Venezuela"
VN = "Viet Nam"
VG = "British Virgin Islands"
VI = "U.S. Virgin Islands"
WF = "Wallis and Futuna"
EH = "Western Sahara"
YE = "Yemen"
ZM = "Zambia"

36
section7/database.py Normal file
View File

@ -0,0 +1,36 @@
import datetime
import uuid
import peewee
import peewee_plus
from section7 import constants
INTERFACE = peewee.DatabaseProxy()
class Section7Model(peewee.Model):
"""Base model for defining common fields and attaching database"""
class Meta: # pylint: disable=too-few-public-methods,missing-class-docstring
database = INTERFACE
uuid = peewee.UUIDField(null=False, unique=True, default=uuid.uuid4)
created = peewee.DateTimeField(null=False, default=datetime.datetime.utcnow)
class DisclosureRecord(Section7Model):
value = peewee.DecimalField(max_digits=20, decimal_places=3)
rate = peewee_plus.EnumField(constants.PayRate)
additionals = peewee_plus.JSONField(default={})
recipients = peewee_plus.JSONField(default=[])
publish = peewee.BooleanField()
rate_comment = peewee.CharField(null=True)
name = peewee.CharField(null=True)
age = peewee.IntegerField(null=True)
gender = peewee_plus.EnumField(constants.Gender, null=True)
race = peewee_plus.EnumField(null=True)
country = peewee_plus.EnumField(constants.Country, null=True)
city = peewee.CharField(null=True)