Another Ham Radio Logbook -- Web, Multi-user multiple-logbook, with eQSL upload support
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.

dbseed.py 9.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. from models import user_datastore, Config, Role, Band
  2. from flask_security.utils import encrypt_password
  3. def make_db_seed(db):
  4. print("== Seeding database")
  5. db.session.begin(subtransactions=True)
  6. try:
  7. print("++ Seeding config")
  8. seed_config(db)
  9. seed_users(db) # after timezones because not null relation
  10. # also seeds roles admin/user
  11. except: # noqa: E722
  12. db.session.rollback()
  13. raise
  14. def seed_users(db):
  15. print("++ Seeding users")
  16. role_usr = Role()
  17. role_usr.name = "user"
  18. role_usr.description = "Simple user"
  19. role_adm = Role()
  20. role_adm.name = "admin"
  21. role_adm.description = "Admin user"
  22. db.session.add(role_usr)
  23. db.session.add(role_adm)
  24. user_datastore.create_user(
  25. email="dashie@sigpipe.me",
  26. password=encrypt_password("fluttershy"),
  27. name="toto",
  28. timezone="UTC",
  29. roles=[role_adm],
  30. callsign="N0C4LL",
  31. locator="JN",
  32. )
  33. db.session.commit()
  34. return
  35. def seed_config(db):
  36. a = Config(
  37. lotw_download_url="https://p1k.arrl.org/lotwuser/lotwreport.adi",
  38. lotw_upload_url="https://p1k.arrl.org/lotwuser/upload",
  39. lotw_rcvd_mark="Y",
  40. lotw_login_url="https://p1k.arrl.org/lotwuser/default",
  41. eqsl_download_url="https://www.eqsl.cc/qslcard/DownloadInBox.cfm",
  42. eqsl_upload_url="https://www.eqsl.cc/qslcard/ImportADIF.cfm",
  43. eqsl_rcvd_mark="Y",
  44. )
  45. db.session.add(a)
  46. db.session.commit()
  47. db.session.commit()
  48. # Bug, two commit necessary
  49. # Only used by tests
  50. def seed_bands(db):
  51. db.session.add(Band(name="2222m", zone="iaru1", lower=135700, upper=137800))
  52. db.session.add(Band(name="630m", zone="iaru1", lower=472000, upper=476000))
  53. db.session.add(Band(name="160m", zone="iaru1", lower=1810000, upper=1850000))
  54. db.session.add(Band(name="80m", zone="iaru1", lower=3500000, upper=3800000))
  55. db.session.add(Band(name="60m", zone="iaru1", lower=5351500, upper=5366500))
  56. db.session.add(Band(name="40m", zone="iaru1", lower=7000000, upper=7200000))
  57. db.session.add(Band(name="30m", zone="iaru1", lower=10100000, upper=10150000))
  58. db.session.add(Band(name="20m", zone="iaru1", lower=14000000, upper=14350000))
  59. db.session.add(Band(name="17m", zone="iaru1", lower=18068000, upper=18168000))
  60. db.session.add(Band(name="15m", zone="iaru1", lower=21000000, upper=21450000))
  61. db.session.add(Band(name="12m", zone="iaru1", lower=24890000, upper=24990000))
  62. db.session.add(Band(name="10m", zone="iaru1", lower=28000000, upper=29700000))
  63. db.session.add(Band(name="6m", zone="iaru1", lower=50000000, upper=52000000))
  64. db.session.add(Band(name="2m", zone="iaru1", lower=144000000, upper=146000000))
  65. db.session.add(Band(name="70cm", zone="iaru1", lower=430000000, upper=440000000))
  66. db.session.add(Band(name="23cm", zone="iaru1", lower=1240000000, upper=1300000000))
  67. db.session.add(Band(name="13cm", zone="iaru1", lower=2300000000, upper=2450000000))
  68. db.session.add(Band(name="5cm", zone="iaru1", lower=5650000000, upper=5850000000))
  69. db.session.add(Band(name="3cm", zone="iaru1", lower=10000000000, upper=10500000000))
  70. db.session.add(Band(name="1,2cm", zone="iaru1", lower=24000000000, upper=24250000000))
  71. db.session.add(Band(name="6mm", zone="iaru1", lower=47000000000, upper=47200000000))
  72. db.session.add(Band(name="4mm", zone="iaru1", lower=76000000000, upper=81500000000))
  73. db.session.add(Band(name="2,4mm", zone="iaru1", lower=122250000000, upper=123000000000))
  74. db.session.add(Band(name="2mm", zone="iaru1", lower=134000000000, upper=141000000000))
  75. db.session.add(Band(name="1,2mm", zone="iaru1", lower=241000000000, upper=250000000000))
  76. # Modes plans for IARU1
  77. # Only CW on 2222m
  78. db.session.add(Band(name="2222m", zone="iaru1", modes=None, start=135700))
  79. db.session.add(Band(name="160m", zone="iaru1", modes="CW", start=1810000))
  80. db.session.add(Band(name="160m", zone="iaru1", modes="RTTY,PSK31,PSK63,SSTV", start=1838000))
  81. db.session.add(Band(name="160m", zone="iaru1", modes="SSB,AM", start=1838000))
  82. db.session.add(Band(name="160m", zone="iaru1", modes=None, start=1810000))
  83. db.session.add(Band(name="80m", zone="iaru1", modes="CW", start=3500000))
  84. db.session.add(Band(name="80m", zone="iaru1", modes="RTTY,PSK31,PSK63,SSTV", start=3580000))
  85. db.session.add(Band(name="80m", zone="iaru1", modes="SSB,AM", start=3600000))
  86. db.session.add(Band(name="80m", zone="iaru1", modes=None, start=3500000))
  87. db.session.add(Band(name="40m", zone="iaru1", modes="CW", start=7000000))
  88. db.session.add(Band(name="40m", zone="iaru1", modes="RTTY,PSK31,PSK63,SSTV", start=7040000))
  89. db.session.add(Band(name="40m", zone="iaru1", modes="SSB,AM", start=7060000))
  90. db.session.add(Band(name="40m", zone="iaru1", modes=None, start=7000000))
  91. db.session.add(Band(name="30m", zone="iaru1", modes="CW", start=10100000))
  92. db.session.add(Band(name="30m", zone="iaru1", modes="RTTY,PSK31,PSK63", start=10140000))
  93. db.session.add(Band(name="30m", zone="iaru1", modes=None, start=10100000))
  94. db.session.add(Band(name="20m", zone="iaru1", modes="CW", start=14000000))
  95. db.session.add(Band(name="20m", zone="iaru1", modes="RTTY,PSK31,PSK63", start=14070000))
  96. db.session.add(Band(name="20m", zone="iaru1", modes="SSB,AM", start=14101000))
  97. db.session.add(Band(name="20m", zone="iaru1", modes=None, start=14000000))
  98. db.session.add(Band(name="17m", zone="iaru1", modes="CW", start=18068000))
  99. db.session.add(Band(name="17m", zone="iaru1", modes="RTTY,PSK31,PSK63", start=18095000))
  100. db.session.add(Band(name="17m", zone="iaru1", modes="SSB,AM", start=18111000))
  101. db.session.add(Band(name="17m", zone="iaru1", modes=None, start=18068000))
  102. db.session.add(Band(name="15m", zone="iaru1", modes="CW", start=21000000))
  103. db.session.add(Band(name="15m", zone="iaru1", modes="RTTY,PSK31,PSK63", start=21070000))
  104. db.session.add(Band(name="15m", zone="iaru1", modes="SSB,AM,SSTV", start=21151000))
  105. db.session.add(Band(name="15m", zone="iaru1", modes=None, start=21000000))
  106. db.session.add(Band(name="12m", zone="iaru1", modes="CW", start=24890000))
  107. db.session.add(Band(name="12m", zone="iaru1", modes="RTTY,PSK31,PSK63", start=24915000))
  108. db.session.add(Band(name="12m", zone="iaru1", modes="SSB,AM,SSTV", start=24931000))
  109. db.session.add(Band(name="12m", zone="iaru1", modes=None, start=24890000))
  110. db.session.add(Band(name="10m", zone="iaru1", modes="CW", start=28000000))
  111. db.session.add(Band(name="10m", zone="iaru1", modes="RTTY,PSK31,PSK63", start=28070000))
  112. db.session.add(Band(name="10m", zone="iaru1", modes="SSB,AM,SSTV", start=28225000))
  113. db.session.add(Band(name="10m", zone="iaru1", modes="FM,PKT", start=29200000))
  114. db.session.add(Band(name="10m", zone="iaru1", modes=None, start=28000000))
  115. db.session.add(Band(name="6m", zone="iaru1", modes="CW", start=50000000))
  116. db.session.add(Band(name="6m", zone="iaru1", modes="SSB", start=50110000))
  117. db.session.add(Band(name="6m", zone="iaru1", modes="SSTV", start=50510000))
  118. db.session.add(Band(name="6m", zone="iaru1", modes="FM", start=50520000))
  119. db.session.add(Band(name="6m", zone="iaru1", modes="RTTY", start=50600000))
  120. db.session.add(Band(name="6m", zone="iaru1", modes=None, start=50000000))
  121. db.session.add(Band(name="2m", zone="iaru1", modes="CW,SSB", start=144025000))
  122. db.session.add(Band(name="2m", zone="iaru1", modes="FM", start=145000000))
  123. db.session.add(Band(name="2m", zone="iaru1", modes=None, start=144000000))
  124. db.session.add(Band(name="70cm", zone="iaru1", modes="FM", start=430250000))
  125. db.session.add(Band(name="70cm", zone="iaru1", modes="CW,SSB", start=432000000))
  126. db.session.add(Band(name="70cm", zone="iaru1", modes="PSK31", start=432088000))
  127. db.session.add(Band(name="70cm", zone="iaru1", modes="SSTV", start=432500000))
  128. db.session.add(Band(name="70cm", zone="iaru1", modes="RTTY", start=432562500))
  129. db.session.add(Band(name="70cm", zone="iaru1", modes=None, start=430000000))
  130. db.session.add(Band(name="23cm", zone="iaru1", modes="FM,SSB,CW", start=1260000000))
  131. db.session.add(Band(name="23cm", zone="iaru1", modes="RTTY", start=1270000000))
  132. db.session.add(Band(name="23cm", zone="iaru1", modes="PSK31", start=1296138000))
  133. db.session.add(Band(name="23cm", zone="iaru1", modes=None, start=1240000000))
  134. db.session.add(Band(name="13cm", zone="iaru1", modes="CW", start=2320025000))
  135. db.session.add(Band(name="13cm", zone="iaru1", modes="PSK31", start=2320138000))
  136. db.session.add(Band(name="13cm", zone="iaru1", modes="LSB", start=2320150000))
  137. db.session.add(Band(name="13cm", zone="iaru1", modes="FM", start=2321000000))
  138. db.session.add(Band(name="13cm", zone="iaru1", modes=None, start=2300000000))
  139. db.session.add(Band(name="5cm", zone="iaru1", modes=None, start=5650000000))
  140. db.session.add(Band(name="3cm", zone="iaru1", modes="CW,SSB", start=10368000000))
  141. db.session.add(Band(name="3cm", zone="iaru1", modes=None, start=10000000000))
  142. db.session.add(Band(name="1,2cm", zone="iaru1", modes=None, start=24000000000))
  143. db.session.add(Band(name="6mm", zone="iaru1", modes=None, start=47000000000))
  144. db.session.add(Band(name="4mm", zone="iaru1", modes=None, start=76000000000))
  145. db.session.add(Band(name="2,4mm", zone="iaru1", modes=None, start=122250000000))
  146. db.session.add(Band(name="2mm", zone="iaru1", modes=None, start=134000000000))
  147. db.session.add(Band(name="1,2mm", zone="iaru1", modes=None, start=241000000000))
  148. db.session.commit()