-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create a primary name based on a passed in string template, re #997
- Loading branch information
Showing
3 changed files
with
29 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,20 @@ | ||
import uuid, re | ||
from arches.app.models import models | ||
from arches.app.models.tile import Tile | ||
|
||
def get_primary_name_from_nodes(resource, config): | ||
# eventally use sort order | ||
config['nodegroupid'] = '' | ||
config['string_template'] = '{some_nodeid} ({some_other_nodeid})' | ||
#tile = models.Tile.objects.filter(nodegroup_id=config['nodegroupid'])[0] | ||
#config['string_template'] % () | ||
return 'this is an example primary name' | ||
#uuid_regex = '(?P<nodeid>[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})' | ||
# x = {} | ||
# for match in re.findall(uuid_regex, config['string_template']): | ||
# x[match] = '' | ||
|
||
for tile in models.Tile.objects.filter(nodegroup_id=uuid.UUID(config['nodegroup_id'])): | ||
t = Tile(tile) | ||
t.get_node_display_values() | ||
for nodeid, nodevalue in t.data.iteritems(): | ||
#x[nodeid] = nodevalue | ||
print nodevalue | ||
config['string_template'] = config['string_template'].replace('{%s}' % nodeid, nodevalue) | ||
|
||
return config['string_template'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters