Skip to content

Commit

Permalink
fixup! Make node aliases not nullable #10437
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls committed Nov 1, 2024
1 parent 49a97e3 commit ea0d34a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
8 changes: 6 additions & 2 deletions arches/app/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -904,9 +904,13 @@ def __init__(self, *args, **kwargs):
if not self.nodeid:
self.nodeid = uuid.uuid4()

def save(self, *args, **kwargs):
if self.alias is None:
def clean(self):
if not self.alias:
Graph.objects.get(pk=self.graph_id).create_node_alias(self)

def save(self, **kwargs):
if not self.alias:
self.clean()
add_to_update_fields(kwargs, "alias")
if self.pk == self.source_identifier_id:
self.source_identifier_id = None
Expand Down
3 changes: 3 additions & 0 deletions releases/8.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ JavaScript:

- `ensure_userprofile_exists()` was removed from the `Tile` model.

- The following fields are no longer nullable. If you have custom SQL (or Python code that uses direct ORM operations to bypass model methods, etc.), you will need to set these fields directly on creation:
- `Node.alias`

### Upgrading Arches

1. You must be upgraded to at least version before proceeding. If you are on an earlier version, please refer to the upgrade process in the []()
Expand Down
11 changes: 11 additions & 0 deletions tests/models/node_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from arches.app.models.graph import Graph
from arches.app.models.models import Node
from tests.base_test import ArchesTestCase


class NodeTests(ArchesTestCase):
def test_missing_alias_supplied(self):
new_graph = Graph.new(name="Missing alias test")
new_node = Node(graph_id=new_graph.pk)
new_node.clean()
self.assertIsNotNone(new_node.alias)

0 comments on commit ea0d34a

Please sign in to comment.