Skip to content

Commit 5ff7b6a

Browse files
authored
Collect final work on django implementation (#18)
this work will be tagged and then deleted
1 parent e406808 commit 5ff7b6a

File tree

6 files changed

+44
-23
lines changed

6 files changed

+44
-23
lines changed

nshm/admin.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
LocationList,
77
SeismicHazardModel,
88
SourceLogicTree,
9-
SourceLogicTreeComponent,
10-
SourceLogicTreeWeightedComponent,
9+
SourceLogicTreeSource,
10+
SourceLogicTreeBranch,
1111
)
1212

1313

@@ -24,7 +24,7 @@ class GMCMLogicTreeAdmin(admin.ModelAdmin):
2424
fields = ["version", "notes"]
2525

2626

27-
class SourceLogicTreeComponentAdmin(admin.ModelAdmin):
27+
class SourceLogicTreeSourceAdmin(admin.ModelAdmin):
2828
fields = [
2929
"tag",
3030
"notes",
@@ -37,7 +37,7 @@ class SourceLogicTreeComponentAdmin(admin.ModelAdmin):
3737
list_filter = ["tectonic_region", "group"]
3838

3939

40-
class SourceLogicTreeWeightedComponentAdmin(admin.ModelAdmin):
40+
class SourceLogicTreeBranchAdmin(admin.ModelAdmin):
4141
fields = ["weight", "source_logic_tree", "source_logic_tree_component"]
4242

4343

@@ -61,9 +61,9 @@ class HazardSolutionAdmin(admin.ModelAdmin):
6161
admin.site.register(SeismicHazardModel, SeismicHazardModelAdmin)
6262
admin.site.register(SourceLogicTree, SourceLogicTreeAdmin)
6363
admin.site.register(GMCMLogicTree, GMCMLogicTreeAdmin)
64-
admin.site.register(SourceLogicTreeComponent, SourceLogicTreeComponentAdmin)
64+
admin.site.register(SourceLogicTreeSource, SourceLogicTreeSourceAdmin)
6565
admin.site.register(
66-
SourceLogicTreeWeightedComponent, SourceLogicTreeWeightedComponentAdmin
66+
SourceLogicTreeBranch, SourceLogicTreeBranchAdmin
6767
)
6868

6969
admin.site.register(LocationList, LocationListAdmin)

nshm/documents.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ class Django:
7070
})
7171

7272
@registry.register_document
73-
class SourceLogicTreeComponentDocument(DocumentWithNodeId):
73+
class SourceLogicTreeSourceDocument(DocumentWithNodeId):
7474
class Index:
7575
name = COMMON_INDEX
7676

7777
class Django:
78-
model = models.SourceLogicTreeComponent
78+
model = models.SourceLogicTreeSource
7979
fields = [
8080
'tag',
8181
'notes',
@@ -92,13 +92,13 @@ class Django:
9292

9393

9494
@registry.register_document
95-
class SourceLogicTreeWeightedComponentDocument(DocumentWithNodeId):
95+
class SourceLogicTreeBranchDocument(DocumentWithNodeId):
9696

9797
class Index:
9898
name = COMMON_INDEX
9999

100100
class Django:
101-
model = models.SourceLogicTreeWeightedComponent
101+
model = models.SourceLogicTreeBranch
102102
fields = [
103103
'weight',
104104
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Generated by Django 4.2.5 on 2023-11-05 21:21
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("nshm", "0016_remove_seismichazardmodel_typename"),
10+
]
11+
12+
operations = [
13+
migrations.RenameModel(
14+
old_name="SourceLogicTreeWeightedComponent",
15+
new_name="SourceLogicTreeBranch",
16+
),
17+
migrations.RenameModel(
18+
old_name="SourceLogicTreeComponent",
19+
new_name="SourceLogicTreeSource",
20+
),
21+
]

nshm/models.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def __str__(self):
2020
return self.version
2121

2222

23-
class SourceLogicTreeComponent(models.Model):
23+
class SourceLogicTreeSource(models.Model):
2424
tag = models.CharField(max_length=50)
2525
notes = models.TextField(null=True, blank=True)
2626
inversion_toshi_id = models.CharField(max_length=50, null=False)
@@ -34,7 +34,7 @@ def __str__(self):
3434
return f"{self.tag} {self.tectonic_region}"
3535

3636

37-
class SourceLogicTreeWeightedComponent(models.Model):
37+
class SourceLogicTreeBranch(models.Model):
3838
weight = models.FloatField()
3939
source_logic_tree = models.ForeignKey(
4040
SourceLogicTree,
@@ -43,7 +43,7 @@ class SourceLogicTreeWeightedComponent(models.Model):
4343
on_delete=models.CASCADE,
4444
)
4545
source_logic_tree_component = models.ForeignKey(
46-
SourceLogicTreeComponent,
46+
SourceLogicTreeSource,
4747
related_name="slt_weighted_components",
4848
null=True,
4949
on_delete=models.SET_NULL,
@@ -102,6 +102,6 @@ class HazardSolution(models.Model):
102102
LocationList, related_name="hazard_solutions"
103103
)
104104
slt_components = models.ManyToManyField(
105-
SourceLogicTreeWeightedComponent, related_name="hazard_solutions"
105+
SourceLogicTreeBranch, related_name="hazard_solutions"
106106
)
107107

nshm/schema.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ class Meta:
2828
interfaces = (relay.Node,)
2929

3030

31-
class SourceLogicTreeComponent(DjangoObjectType):
31+
class SourceLogicTreeSource(DjangoObjectType):
3232
class Meta:
33-
model = models.SourceLogicTreeComponent
33+
model = models.SourceLogicTreeSource
3434
interfaces = (relay.Node,)
3535
filter_fields = [
3636
"tag",
@@ -41,9 +41,9 @@ class Meta:
4141
]
4242

4343

44-
class SourceLogicTreeWeightedComponent(DjangoObjectType):
44+
class SourceLogicTreeBranch(DjangoObjectType):
4545
class Meta:
46-
model = models.SourceLogicTreeWeightedComponent
46+
model = models.SourceLogicTreeBranch
4747
interfaces = (relay.Node,)
4848

4949

@@ -66,12 +66,12 @@ class Query(ObjectType):
6666
source_logic_tree = relay.Node.Field(SourceLogicTree)
6767
all_source_logic_trees = DjangoFilterConnectionField(SourceLogicTree)
6868

69-
source_logic_tree_component = relay.Node.Field(SourceLogicTreeComponent)
69+
source_logic_tree_component = relay.Node.Field(SourceLogicTreeSource)
7070
all_source_logic_tree_components = DjangoFilterConnectionField(
71-
SourceLogicTreeComponent
71+
SourceLogicTreeSource
7272
)
7373

7474
gmcm_logic_tree = relay.Node.Field(GMCM_LogicTree)
7575
all_gmcm_logic_trees = DjangoFilterConnectionField(GMCM_LogicTree)
7676

77-
# source_logic_tree_weighted_component = relay.Node.Field(SourceLogicTreeWeightedComponent)
77+
# source_logic_tree_weighted_component = relay.Node.Field(SourceLogicTreeBranch)

nzshm_model_graphql_api/settings.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@
181181
# For example, my-test-domain.us-east-1.es.amazonaws.com
182182
# ES_HOST = 'https://search-nshm-model-opensearch-poc-fz3qmvqjus5clpyxgvfju3c4fq.ap-southeast-2.es.amazonaws.com' # OpenSearch
183183
# ES_HOST = 'https://search-nshm-model-opensearch-es-fayxiqeijwlgiuo6gdv6cjf7vy.ap-southeast-2.es.amazonaws.com' # Elastic 7.10
184-
# ES_HOST = 'https://search-nzshm22-toshi-api-es-test-ybx3zlp6hz2shrytj2ns4zx6bm.ap-southeast-2.es.amazonaws.com' # TOSHI_TEST
185-
ES_HOST = "https://search-nzshm22-toshi-api-es-prod-cj4taqcgnefophpxzan55xeswa.ap-southeast-2.es.amazonaws.com" # TOSHI_PROD
184+
ES_HOST = 'https://search-nzshm22-toshi-api-es-test-ybx3zlp6hz2shrytj2ns4zx6bm.ap-southeast-2.es.amazonaws.com' # TOSHI_TEST
185+
# ES_HOST = "https://search-nzshm22-toshi-api-es-prod-cj4taqcgnefophpxzan55xeswa.ap-southeast-2.es.amazonaws.com" # TOSHI_PROD
186186

187187
ES_REGION = 'ap-southeast-2' # e.g. us-west-1
188188
IS_OFFLINE = None

0 commit comments

Comments
 (0)