| 1227 | |
| 1228 | |
| 1229 | def setup_paas_demo( |
| 1230 | organization_name="paas", |
| 1231 | username="paas", |
| 1232 | email="paas@paas.com", |
| 1233 | password="paas", |
| 1234 | org_type=Organization.OrganizationType.EXTERNAL_DEMO, |
| 1235 | ): |
| 1236 | try: |
| 1237 | org = Organization.objects.get(organization_name=organization_name) |
| 1238 | Event.objects.filter(organization=org).delete() |
| 1239 | org.delete() |
| 1240 | logger.info("[PAAS DEMO]: Deleted existing organization, replacing") |
| 1241 | except Organization.DoesNotExist: |
| 1242 | logger.info("[PAAS DEMO]: creating from scratch") |
| 1243 | try: |
| 1244 | user = User.objects.get(username=username, email=email) |
| 1245 | except Exception: |
| 1246 | user = User.objects.create_user( |
| 1247 | username=username, email=email, password=password |
| 1248 | ) |
| 1249 | if user.organization is None: |
| 1250 | organization, _ = Organization.objects.get_or_create( |
| 1251 | organization_name=organization_name |
| 1252 | ) |
| 1253 | user.organization = organization |
| 1254 | organization.organization_type = org_type |
| 1255 | user.save() |
| 1256 | organization.save() |
| 1257 | organization = user.organization |
| 1258 | organization.subscription_filter_keys = ["shard_id"] |
| 1259 | big_customers = [] |
| 1260 | for _ in range(1): |
| 1261 | customer = Customer.objects.create( |
| 1262 | organization=organization, |
| 1263 | customer_name="BigCompany " + str(uuid.uuid4().hex)[:6], |
| 1264 | email=f"{str(uuid.uuid4().hex)}@{str(uuid.uuid4().hex)}.com", |
| 1265 | ) |
| 1266 | big_customers.append(customer) |
| 1267 | medium_customers = [] |
| 1268 | for _ in range(2): |
| 1269 | customer = Customer.objects.create( |
| 1270 | organization=organization, |
| 1271 | customer_name="MediumCompany " + str(uuid.uuid4().hex)[:6], |
| 1272 | email=f"{str(uuid.uuid4().hex)}@{str(uuid.uuid4().hex)}.com", |
| 1273 | ) |
| 1274 | medium_customers.append(customer) |
| 1275 | small_customers = [] |
| 1276 | for _ in range(5): |
| 1277 | customer = Customer.objects.create( |
| 1278 | organization=organization, |
| 1279 | customer_name="SmallCompany " + str(uuid.uuid4().hex)[:6], |
| 1280 | email=f"{str(uuid.uuid4().hex)[:8]}@{str(uuid.uuid4().hex)[:8]}.com", |
| 1281 | ) |
| 1282 | small_customers.append(customer) |
| 1283 | ( |
| 1284 | valnodes, |
| 1285 | rpcnodes, |
| 1286 | ixnodes, |