Skip to content

Commit

Permalink
Hack to get the nn
Browse files Browse the repository at this point in the history
  • Loading branch information
WillNilges committed Apr 26, 2024
1 parent 69a1ae7 commit 71c6547
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/meshapi/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ class NonrelatedBuildingInline(BetterNonrelatedInline):

add_button = True

# Hack to get the NN
network_number = None

def get_form_queryset(self, obj):
self.network_number = obj.pk
return self.model.objects.filter(nodes=obj)

def save_new_instance(self, parent, instance):
Expand Down
9 changes: 2 additions & 7 deletions src/meshapi/templates/admin/install_tabular.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,10 @@ <h2>{{ inline_admin_formset.opts.verbose_name_plural|capfirst }}</h2>
</tbody>
</table>
</fieldset>
<!--TODO: Add collapsible menu to add existing buildings...?-->
<div>
<p>test</p>
{% if inline_admin_formset.opts.add_button %}
<p>{{ inline_admin_formset.opts }}</p>
<p>{{ inline_admin_formset.opts.model }}</p>
<p>{{ inline_admin_form.opts.model }}</p>
<p>{% url 'request.get_host()' %}</p>
<p>{% url 'admin:meshapi_building_add' %}</p>
<a href="{{ inline_admin_formset.opts.model.add_url }}" class="addlink">Add</a>
<a href="{{ request.scheme }}://{{ request.get_host }}{% url 'admin:meshapi_building_add' %}?primary_node={{ inline_admin_formset.opts.network_number }}" class="addlink">Add</a>
{% endif %}
</div>
</div>
Expand Down

0 comments on commit 71c6547

Please sign in to comment.