customizations icon indicating copy to clipboard operation
customizations copied to clipboard

Create export-rearports-for-adding-details.txt

Open gdprdatasubect opened this issue 2 years ago • 2 comments

Why? We use Label and description of rear ports to mark in where which room a port ends. After adding the information it can be reimported again thanks to the recently added edit functionality.

Example: id,name,description,label 1337,1,Wallmounted,R4711 1338,2,In Ceiling ,Floor 0815

gdprdatasubect avatar Mar 27 '23 11:03 gdprdatasubect

I get what this is trying to accomplish, but I wonder if its too simple of an export template to warrent inclusion in the repo. Anyone with an opinion here?

kkthxbye-code avatar Jun 04 '23 10:06 kkthxbye-code

Seems very simple. You could do it without an export templating just by selecting the columns of interest, except that the column headings will be wrong.

If you want a more sophisticated example, you could use something like this for cables:

side_a_device,side_a_type,side_a_name,side_b_device,side_b_type,side_b_name,type,status,label,color,length,length_unit
{%- for c in queryset %}
{%- if c.a_terminations and c.b_terminations %}
{%- set act = c.a_terminations[0].cable_terminations.content_type %}
{%- set bct = c.b_terminations[0].cable_terminations.content_type %}
{%- if act.app_label != 'circuits' and bct.app_label != 'circuits' %}
{{ c.a_terminations[0].device.name }},{{ act.app_label }}.{{ act.model }},{{ c.a_terminations[0].name }},{{ c.b_terminations[0].device.name }},{{ bct.app_label }}.{{ bct.model }},{{ c.b_terminations[0].name }},{{ c.type }},{{ c.status }},"{{ c.label }}",{{c.color}},{{ c.length|default("", True) }},{{ c.length_unit }}
{%- endif %}
{%- endif %}
{%- endfor %}

(although since AFAIK it's not possible to use CSV to import multi-termination cables, this only works if there are single terminations at each end)

candlerb avatar Feb 12 '24 13:02 candlerb