Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions back/boxtribute_server/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ def __init__(
self._max_beta_level = int(max_beta_level or 0)
self._timezone = timezone

def __repr__(self):
return f"User ID {self._id}"

@classmethod
def from_jwt(cls, payload):
"""Extract user information from custom claims in JWT payload. The prefix and
Expand Down
23 changes: 15 additions & 8 deletions back/boxtribute_server/cron/data_faking.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
from ..models.definitions.unit import Unit
from ..models.utils import convert_ids, utcnow

NR_BASES = 4
NR_BASES = 8
NR_OF_CREATED_TAGS_PER_BASE = 20
NR_OF_DELETED_TAGS_PER_BASE = round(NR_OF_CREATED_TAGS_PER_BASE / 10)
LOCATION_BOX_STATES = [
Expand All @@ -81,7 +81,7 @@
BoxState.Donated,
BoxState.InStock,
]
LOCATION_NAMES = ("Stockroom", "WH", "WH2", "FreeShop", "Donated location", "Unused WH")
LOCATION_NAMES = ("Stockroom", "WH", "WH2", "FreeShop", "PartnerHelp", "Unused WH")
NR_OF_CREATED_LOCATIONS_PER_BASE = len(LOCATION_NAMES)
NR_OF_ADULTS_PER_LARGE_BASE = 300
NR_OF_CHILDREN_PER_LARGE_BASE = 300
Expand Down Expand Up @@ -227,7 +227,7 @@ def _fetch_bases_and_users(self):
"""Obtain relevant test bases (exclude the ones used for Cypress tests), as well
as test users.
"""
bases = list(Base.select().where(Base.id < 100))
bases = list(Base.select().orwhere(Base.id < 100, Base.id > 100000001))
self.base_ids = [b.id for b in bases]
self.products = {b: [] for b in self.base_ids}
self.tags = {b: [] for b in self.base_ids}
Expand All @@ -240,16 +240,23 @@ def _fetch_bases_and_users(self):
result = execute_sql(
self.base_ids,
query="""\
SELECT cuc.camp_id, group_concat(u.id ORDER BY u.id) AS user_ids
FROM cms_users u
INNER JOIN cms_usergroups_camps cuc
SELECT c.id AS camp_id, group_concat(u.id ORDER BY u.id) AS user_ids
FROM camps c
LEFT JOIN cms_usergroups_camps cuc
ON cuc.camp_id = c.id
LEFT JOIN cms_users u
ON u.cms_usergroups_id = cuc.cms_usergroups_id
AND cuc.camp_id in %s
GROUP BY cuc.camp_id
WHERE c.id in %s
GROUP BY c.id
;""",
)
god_user = CurrentUser(id=1, is_god=True, organisation_id=None)
for row in result:
base_id = row["camp_id"]
if row["user_ids"] is None:
# Base has no users
self.users[base_id] = [god_user]
continue
self.users[base_id] = [
CurrentUser(
id=int(i),
Expand Down
105 changes: 73 additions & 32 deletions back/boxtribute_server/cron/reseed_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,82 +59,123 @@ def execute_sql_statements_from_file(cursor, sql_file):
# 2. Change data structure: jq '.roles | map({(.name): .id}) | add' tenant.json
STAGING_AUTH0_ROLE_IDS = {
"administrator": "rol_I49URaIyhBnMQHJQ",
"base_100000000_external_free_shop_checkout": "rol_oJCLEkuiplrbYX00",
"base_100000000_coordinator": "rol_tcBvcFXhVekggU8H",
"base_100000000_free_shop_volunteer": "rol_R19NxnEOO3iGctqc",
"base_100000000_label_creation": "rol_3jwyihkX503dI2XI",
"base_100000000_library_volunteer": "rol_8tqEAp6v0qmK4SiX",
"base_100000000_warehouse_volunteer": "rol_7syKQNdCCteg5BDi",
"base_100000001_external_free_shop_checkout": "rol_6x0gDYN1CkUo99qS",
"base_100000001_coordinator": "rol_Fv2c7Mzh2Njr2pp0",
"base_100000001_free_shop_volunteer": "rol_76CagkHaSRsHNosv",
"base_100000001_label_creation": "rol_yqMsT3EmaLymy8ez",
"base_100000001_library_volunteer": "rol_9qyfKtUXKZap8ngz",
"base_100000001_warehouse_volunteer": "rol_17GcfmcO6kQ94zYZ",
"base_1_external_free_shop_checkout": "rol_LQU376MESdeH0VuW",
"base_1_coordinator": "rol_V4nNNkYco84WlMRT",
"base_1_external_free_shop_checkout": "rol_LQU376MESdeH0VuW",
"base_1_free_shop_volunteer": "rol_cUiwTC7Hjda6ZRt0",
"base_1_label_creation": "rol_rH3ypspbLKPpv5Hv",
"base_1_library_volunteer": "rol_Gn1K628NdOCHqwOV",
"base_1_warehouse_volunteer": "rol_zF0wNUwB8gFbGrVJ",
"base_2_external_free_shop_checkout": "rol_4Q2Igr6pgQgYCtf0",
"base_2_coordinator": "rol_5xjOjvRSch83q8RV",
"base_2_external_free_shop_checkout": "rol_4Q2Igr6pgQgYCtf0",
"base_2_free_shop_volunteer": "rol_GPN3nIYLVgKfRG8M",
"base_2_label_creation": "rol_JQgq1dTehqfmWOnm",
"base_2_library_volunteer": "rol_Odg5F3mr7L9jtsxA",
"base_2_warehouse_volunteer": "rol_0QGJMfQZEIhw52H9",
"base_3_external_free_shop_checkout": "rol_nl2zVwPW5PFpe8j3",
"base_3_coordinator": "rol_uW12dtjMiwyHvE7A",
"base_3_external_free_shop_checkout": "rol_nl2zVwPW5PFpe8j3",
"base_3_free_shop_volunteer": "rol_XxJvcFSHa3As9xs5",
"base_3_label_creation": "rol_zRCKpXBedneXHxlb",
"base_3_library_volunteer": "rol_MvRbNPaust2tvLMz",
"base_3_warehouse_volunteer": "rol_cxgyk1fs8zocqJYM",
"base_4_external_free_shop_checkout": "rol_judZpcBrtZvDeoLe",
"base_4_coordinator": "rol_9R5O6UJiGJpuTGD5",
"base_4_external_free_shop_checkout": "rol_judZpcBrtZvDeoLe",
"base_4_free_shop_volunteer": "rol_vxlRm59SSUuETdrC",
"base_4_label_creation": "rol_X2TyZ4GHxjukAAQk",
"base_4_warehouse_volunteer": "rol_RUqIRfh5nKTFme9z",
"base_100000000_coordinator": "rol_tcBvcFXhVekggU8H",
"base_100000000_external_free_shop_checkout": "rol_oJCLEkuiplrbYX00",
"base_100000000_free_shop_volunteer": "rol_R19NxnEOO3iGctqc",
"base_100000000_label_creation": "rol_3jwyihkX503dI2XI",
"base_100000000_library_volunteer": "rol_8tqEAp6v0qmK4SiX",
"base_100000000_warehouse_volunteer": "rol_7syKQNdCCteg5BDi",
"base_100000001_coordinator": "rol_Fv2c7Mzh2Njr2pp0",
"base_100000001_external_free_shop_checkout": "rol_6x0gDYN1CkUo99qS",
"base_100000001_free_shop_volunteer": "rol_76CagkHaSRsHNosv",
"base_100000001_label_creation": "rol_yqMsT3EmaLymy8ez",
"base_100000001_library_volunteer": "rol_9qyfKtUXKZap8ngz",
"base_100000001_warehouse_volunteer": "rol_17GcfmcO6kQ94zYZ",
"base_100000002_coordinator": "rol_PfOXCc0AAnhmT4tY",
"base_100000002_external_free_shop_checkout": "rol_K0yifOt6v3FT4mJa",
"base_100000002_free_shop_volunteer": "rol_NbOMIpwf7eacyCh3",
"base_100000002_label_creation": "rol_1eDGSg6Srva6aupa",
"base_100000002_warehouse_volunteer": "rol_CkjUNGslzCy6V9GF",
"base_100000003_coordinator": "rol_g3XofM0nz2h0Y0gh",
"base_100000003_external_free_shop_checkout": "rol_gjaVIjNWs5WfW0pe",
"base_100000003_free_shop_volunteer": "rol_uCBYhlnTrpoJAZIU",
"base_100000003_label_creation": "rol_VfsFzNOJj9n8WXQz",
"base_100000003_warehouse_volunteer": "rol_BKrOcpGtVrxXSFI7",
"base_100000004_coordinator": "rol_YMUXlEkXS7ET3Smt",
"base_100000004_external_free_shop_checkout": "rol_S7u8XzaUQQnLK56P",
"base_100000004_free_shop_volunteer": "rol_XelH93L7eQobDPpc",
"base_100000004_label_creation": "rol_7PC8DPLSO16xOcbY",
"base_100000004_warehouse_volunteer": "rol_5feUWq2sgPQuy2BJ",
"base_100000005_coordinator": "rol_gjRBdMfr8M1MGC7X",
"base_100000005_external_free_shop_checkout": "rol_UBPmJ6KAXH0vaJ6I",
"base_100000005_free_shop_volunteer": "rol_z9mnrR7lJRkPrMBm",
"base_100000005_label_creation": "rol_Qq8l0FwunkceRsG1",
"base_100000005_warehouse_volunteer": "rol_6RfkafXRAvef4kMZ",
"boxtribute_god": "rol_4qH3g8SAxZf8JRdW",
}


DEMO_AUTH0_ROLE_IDS = {
"administrator": "rol_op4UNr1UtE1wJsa9",
"base_100000000_external_free_shop_checkout": "rol_GLNhWp6RFL7YQEh3",
"base_100000000_coordinator": "rol_Vw7ufFoqp4sunt0D",
"base_100000000_free_shop_volunteer": "rol_45SoLF5ExZpR8c4D",
"base_100000000_label_creation": "rol_Yo0RoX9Jj608S90x",
"base_100000000_library_volunteer": "rol_Am7LTDQvyoeP4fvs",
"base_100000000_warehouse_volunteer": "rol_nqsovW11U6knqajN",
"base_100000001_external_free_shop_checkout": "rol_NM6meRpaU9b8L3Lq",
"base_100000001_coordinator": "rol_yxO1hxJlDg6PisFU",
"base_100000001_free_shop_volunteer": "rol_1VnGx7URodlD7Nc4",
"base_100000001_label_creation": "rol_muIeQrZ0P7MEDluy",
"base_100000001_library_volunteer": "rol_onEjTcGJ7a5POcPn",
"base_100000001_warehouse_volunteer": "rol_bCLxWbN4FwiX5TiO",
"base_1_external_free_shop_checkout": "rol_hFAVLTdd36O1dYZh",
"base_1_coordinator": "rol_Ph8BOcANdYLDQrIE",
"base_1_external_free_shop_checkout": "rol_hFAVLTdd36O1dYZh",
"base_1_free_shop_volunteer": "rol_yP4RsBfpW3vTTdiW",
"base_1_label_creation": "rol_kFXWQedhsisZnjuL",
"base_1_library_volunteer": "rol_4YwmG5QogoWHBOmn",
"base_1_warehouse_volunteer": "rol_8GhKyFhbZkEHYP0f",
"base_2_external_free_shop_checkout": "rol_NywtTw6WthA6aebc",
"base_2_coordinator": "rol_EYKFuEd1sw2v127e",
"base_2_external_free_shop_checkout": "rol_NywtTw6WthA6aebc",
"base_2_free_shop_volunteer": "rol_HuL7HiLFKPVw69Zm",
"base_2_label_creation": "rol_lPdKTOzdHouc0Kum",
"base_2_library_volunteer": "rol_IIvTCKV1q6ZodJtK",
"base_2_warehouse_volunteer": "rol_M5sW5aR9S1H6P3jN",
"base_3_external_free_shop_checkout": "rol_Cc4YtNHzsOaqaY4J",
"base_3_coordinator": "rol_Ah0OjBn2UyxAMrMB",
"base_3_external_free_shop_checkout": "rol_Cc4YtNHzsOaqaY4J",
"base_3_free_shop_volunteer": "rol_IhnLdlP4HGtt7Ejl",
"base_3_label_creation": "rol_5nsnxGTKOsq5Q36D",
"base_3_library_volunteer": "rol_rgPftpf2GDGN0fFP",
"base_3_warehouse_volunteer": "rol_dygeJmfDmrXdvlmG",
"base_4_external_free_shop_checkout": "rol_phpA0pP7pGvHKk8d",
"base_4_coordinator": "rol_OlxAuwTSUViCg1o9",
"base_4_external_free_shop_checkout": "rol_phpA0pP7pGvHKk8d",
"base_4_free_shop_volunteer": "rol_YeJEYELuMadIYiml",
"base_4_label_creation": "rol_Xvm4DS5Rxu60vHxm",
"base_4_warehouse_volunteer": "rol_rr6vS0gNxkbqPk0W",
"base_100000000_coordinator": "rol_Vw7ufFoqp4sunt0D",
"base_100000000_external_free_shop_checkout": "rol_GLNhWp6RFL7YQEh3",
"base_100000000_free_shop_volunteer": "rol_45SoLF5ExZpR8c4D",
"base_100000000_label_creation": "rol_Yo0RoX9Jj608S90x",
"base_100000000_library_volunteer": "rol_Am7LTDQvyoeP4fvs",
"base_100000000_warehouse_volunteer": "rol_nqsovW11U6knqajN",
"base_100000001_coordinator": "rol_yxO1hxJlDg6PisFU",
"base_100000001_external_free_shop_checkout": "rol_NM6meRpaU9b8L3Lq",
"base_100000001_free_shop_volunteer": "rol_1VnGx7URodlD7Nc4",
"base_100000001_label_creation": "rol_muIeQrZ0P7MEDluy",
"base_100000001_library_volunteer": "rol_onEjTcGJ7a5POcPn",
"base_100000001_warehouse_volunteer": "rol_bCLxWbN4FwiX5TiO",
# the rol_* values need to be replaced after reseeding Auth0 on demo
"base_100000002_coordinator": "rol_PfOXCc0AAnhmT4tY",
"base_100000002_external_free_shop_checkout": "rol_K0yifOt6v3FT4mJa",
"base_100000002_free_shop_volunteer": "rol_NbOMIpwf7eacyCh3",
"base_100000002_label_creation": "rol_1eDGSg6Srva6aupa",
"base_100000002_warehouse_volunteer": "rol_CkjUNGslzCy6V9GF",
Comment on lines +159 to +163
"base_100000003_coordinator": "rol_g3XofM0nz2h0Y0gh",
"base_100000003_external_free_shop_checkout": "rol_gjaVIjNWs5WfW0pe",
"base_100000003_free_shop_volunteer": "rol_uCBYhlnTrpoJAZIU",
"base_100000003_label_creation": "rol_VfsFzNOJj9n8WXQz",
"base_100000003_warehouse_volunteer": "rol_BKrOcpGtVrxXSFI7",
"base_100000004_coordinator": "rol_YMUXlEkXS7ET3Smt",
"base_100000004_external_free_shop_checkout": "rol_S7u8XzaUQQnLK56P",
"base_100000004_free_shop_volunteer": "rol_XelH93L7eQobDPpc",
"base_100000004_label_creation": "rol_7PC8DPLSO16xOcbY",
"base_100000004_warehouse_volunteer": "rol_5feUWq2sgPQuy2BJ",
"base_100000005_coordinator": "rol_gjRBdMfr8M1MGC7X",
"base_100000005_external_free_shop_checkout": "rol_UBPmJ6KAXH0vaJ6I",
"base_100000005_free_shop_volunteer": "rol_z9mnrR7lJRkPrMBm",
"base_100000005_label_creation": "rol_Qq8l0FwunkceRsG1",
"base_100000005_warehouse_volunteer": "rol_6RfkafXRAvef4kMZ",
"boxtribute_god": "rol_M4N5piyqWIe5l9Td",
"warehouse_volunteer": "rol_fyybK5RykMrK7bIE",
}
Expand Down
Loading
Loading