Skip to content

Commit

Permalink
Merge branch 'dev' into fix/extended_target_model_permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
jchate6 authored Aug 21, 2024
2 parents d4502f7 + 3f0e9be commit 154ec04
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
2 changes: 2 additions & 0 deletions tom_base/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
'rest_framework.authtoken',
'django_filters',
'django_gravatar',
'django_htmx',
'tom_targets',
'tom_alerts',
'tom_catalogs',
Expand All @@ -70,6 +71,7 @@
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django_htmx.middleware.HtmxMiddleware',
'tom_common.middleware.Raise403Middleware',
'tom_common.middleware.ExternalServiceMiddleware',
'tom_common.middleware.AuthStrategyMiddleware',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,18 @@
<th>{{ key }}</th>
<td>{{ value1 }}</td>
<td>{{ value2 }}</td>
{% if value1 and value1 != 'None'%}
<td>{{ value1 }}</td>
{% if key == 'aliases' %}
<td>{{ value1 }}, {{ target2_data.name }}, {{ value2 }}</td>
{% else %}
<td>{{ value2 }}</td>
{% if key == 'target lists' %}
<td>{{ value1 }}, {{ value2 }}</td>
{% else %}
{% if value1 and value1 != 'None'%}
<td>{{ value1 }}</td>
{% else %}
<td>{{ value2 }}</td>
{% endif %}
{% endif %}
{% endif %}
</tr>
{% endif %}
Expand Down
6 changes: 5 additions & 1 deletion tom_targets/templates/tom_targets/target_merge.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@
{% csrf_token %}
{% bootstrap_form form %}

<div class="alert alert-primary">
<b>Note:</b> Confirming the merge will also combine the DataProducts, ReducedDatums, TargetExtras, and ObservationRecords of the two targets.
The primary target will take precedence in any conflicts that occur, and the secondary target's name will become an alias of the merged target.
</div>
<!-- display the target fields table -->
{% target_merge_fields target1 target2 %}


<button type="submit" class="btn btn-outline-danger float-right btn-lg" name="submit"><a href="{% url 'targets:list' %}" style="color: rgb(167, 11, 11)">Cancel</a></button>
<button type="submit" class="btn btn-outline-primary float-right btn-lg" name="confirm">Confirm</button>


</form>
</div>
{% endblock %}
8 changes: 8 additions & 0 deletions tom_targets/templatetags/targets_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,19 @@ def target_merge_fields(target1, target2):
for field in target1._meta.get_fields():
if not field.is_relation:
target1_data[field.name] = field.value_to_string(target1)
target1_data['aliases'] = ', '.join(alias.name for alias in target1.aliases.all())
target1_data['target lists'] = \
', '.join(target_list.name for target_list in TargetList.objects.filter(targets=target1))

target2_data = {}
for field in target2._meta.get_fields():
if not field.is_relation:
target2_data[field.name] = field.value_to_string(target2)
# else:
# print(field.name)
target2_data['aliases'] = ', '.join(alias.name for alias in target2.aliases.all())
target2_data['target lists'] = \
', '.join(target_list.name for target_list in TargetList.objects.filter(targets=target2))

combined_target_data = [x for x in zip(target1_data.keys(), target1_data.values(), target2_data.values())]

Expand Down

0 comments on commit 154ec04

Please sign in to comment.