From 36ff6eb456ad0fc0def1ea2367405abd84086410 Mon Sep 17 00:00:00 2001 From: Peter Krenesky Date: Wed, 8 Jun 2011 13:53:00 -0700 Subject: [PATCH] Object Log: updating templates to be more tolerant of missing objects that they are trying to link to. also updating several templates to use FK rather than object to do the same thing (much faster with fk) --- ganeti_web/templates/ganeti/object_log/cluster_redistribute.html | 2 +- ganeti_web/templates/ganeti/object_log/node_migrate.html | 2 +- ganeti_web/templates/ganeti/object_log/node_role_change.html | 2 +- ganeti_web/templates/ganeti/object_log/permissions/add_user.html | 4 ++-- .../templates/ganeti/object_log/permissions/modify_perms.html | 4 ++-- .../templates/ganeti/object_log/permissions/remove_user.html | 4 ++-- ganeti_web/templates/ganeti/object_log/vm_migrate.html | 5 +++-- ganeti_web/templates/ganeti/object_log/vm_modify.html | 5 +++-- ganeti_web/templates/ganeti/object_log/vm_reboot.html | 5 +++-- ganeti_web/templates/ganeti/object_log/vm_recover.html | 5 +++-- ganeti_web/templates/ganeti/object_log/vm_reinstall.html | 5 +++-- ganeti_web/templates/ganeti/object_log/vm_rename.html | 5 +++-- ganeti_web/templates/ganeti/object_log/vm_start.html | 9 ++++++--- ganeti_web/templates/ganeti/object_log/vm_stop.html | 5 +++-- 14 files changed, 36 insertions(+), 26 deletions(-) diff --git a/ganeti_web/templates/ganeti/object_log/cluster_redistribute.html b/ganeti_web/templates/ganeti/object_log/cluster_redistribute.html index b59cf2d5..682fb7ea 100644 --- a/ganeti_web/templates/ganeti/object_log/cluster_redistribute.html +++ b/ganeti_web/templates/ganeti/object_log/cluster_redistribute.html @@ -1,4 +1,4 @@ - {% if log_item.object2 %} + {% if log_item.object2_id %} Job #{{ log_item.object2.job_id }} - {% endif %} {% if user.is_superuser %} diff --git a/ganeti_web/templates/ganeti/object_log/node_migrate.html b/ganeti_web/templates/ganeti/object_log/node_migrate.html index 5387ef58..1ad2d14e 100644 --- a/ganeti_web/templates/ganeti/object_log/node_migrate.html +++ b/ganeti_web/templates/ganeti/object_log/node_migrate.html @@ -1,4 +1,4 @@ - {% if log_item.object2 %} + {% if log_item.object2_id %} Job #{{ log_item.data.job_id }} - {% endif %} {% if user.is_superuser %} diff --git a/ganeti_web/templates/ganeti/object_log/node_role_change.html b/ganeti_web/templates/ganeti/object_log/node_role_change.html index 6dc8eed5..22475916 100644 --- a/ganeti_web/templates/ganeti/object_log/node_role_change.html +++ b/ganeti_web/templates/ganeti/object_log/node_role_change.html @@ -1,4 +1,4 @@ - {% if log_item.object2 %} + {% if log_item.object2_id %} Job #{{ log_item.data.job_id }} - {% endif %} {% if user.is_superuser %} diff --git a/ganeti_web/templates/ganeti/object_log/permissions/add_user.html b/ganeti_web/templates/ganeti/object_log/permissions/add_user.html index a5e9687f..581d07f9 100644 --- a/ganeti_web/templates/ganeti/object_log/permissions/add_user.html +++ b/ganeti_web/templates/ganeti/object_log/permissions/add_user.html @@ -7,14 +7,14 @@ {% endif %} added {{ data.affected_user_class }} - {% if user.is_superuser %} + {% if user.is_superuser and log_item.object2_id %} {% ifequal data.affected_user_class "User" %} {{data.affected_user}} {% else %} {{data.affected_user}} {% endifequal %} {% else %} - {{ data.affected_user }} + {{ data.affected_user|default:"[deleted user]"}} {% endif %} to {{log_item.object_type1}} {{data.object_str}} {% endwith %} \ No newline at end of file diff --git a/ganeti_web/templates/ganeti/object_log/permissions/modify_perms.html b/ganeti_web/templates/ganeti/object_log/permissions/modify_perms.html index 1aefe90f..efc6861d 100644 --- a/ganeti_web/templates/ganeti/object_log/permissions/modify_perms.html +++ b/ganeti_web/templates/ganeti/object_log/permissions/modify_perms.html @@ -7,14 +7,14 @@ {% endif %} modified permissions for {{ data.affected_user_class }} - {% if user.is_superuser %} + {% if user.is_superuser and log_item.object2_id %} {% ifequal data.affected_user_class "User" %} {{data.affected_user}} {% else %} {{data.affected_user}} {% endifequal %} {% else %} - {{ data.affected_user }} + {{ data.affected_user|default:"[deleted user]"}} {% endif %} on {{log_item.object_type1}} {{data.object_str}} {% endwith %} \ No newline at end of file diff --git a/ganeti_web/templates/ganeti/object_log/permissions/remove_user.html b/ganeti_web/templates/ganeti/object_log/permissions/remove_user.html index 2288660a..13af780b 100644 --- a/ganeti_web/templates/ganeti/object_log/permissions/remove_user.html +++ b/ganeti_web/templates/ganeti/object_log/permissions/remove_user.html @@ -7,14 +7,14 @@ {% endif %} removed {{ data.affected_user_class }} - {% if user.is_superuser %} + {% if user.is_superuser and log_item.object2_id %} {% ifequal data.affected_user_class "User" %} {{data.affected_user}} {% else %} {{data.affected_user}} {% endifequal %} {% else %} - {{ data.affected_user }} + {{ data.affected_user|default:"[deleted user]"}} {% endif %} from {{log_item.object_type1}} {{data.object_str}} {% endwith %} \ No newline at end of file diff --git a/ganeti_web/templates/ganeti/object_log/vm_migrate.html b/ganeti_web/templates/ganeti/object_log/vm_migrate.html index ab0b3898..80e30b7d 100644 --- a/ganeti_web/templates/ganeti/object_log/vm_migrate.html +++ b/ganeti_web/templates/ganeti/object_log/vm_migrate.html @@ -1,5 +1,5 @@ {% with log_item.data as data %} - {% if log_item.object2 %} + {% if log_item.object2_id %} Job #{{ data.job_id }} - {% endif %} {% if user.is_superuser %} @@ -7,5 +7,6 @@ {% else %} {{ log_item.user }} {% endif %} -migrated virtual machine {{data.hostname}} +migrated virtual machine {% if log_item.object1_id %}{{data.hostname}} + {% else %}[deleted]{% endif %} {% endwith %} \ No newline at end of file diff --git a/ganeti_web/templates/ganeti/object_log/vm_modify.html b/ganeti_web/templates/ganeti/object_log/vm_modify.html index 5c998cc1..c6246085 100644 --- a/ganeti_web/templates/ganeti/object_log/vm_modify.html +++ b/ganeti_web/templates/ganeti/object_log/vm_modify.html @@ -1,5 +1,5 @@ {% with log_item.data as data %} - {% if log_item.object2 %} + {% if log_item.object2_id %} Job #{{ data.job_id }} - {% endif %} {% if user.is_superuser %} @@ -7,5 +7,6 @@ {% else %} {{ log_item.user }} {% endif %} -modified settings for virtual machine {{data.hostname}} +modified settings for virtual machine {% if log_item.object1_id %}{{data.hostname}} + {% else %}[deleted]{% endif %} {% endwith %} \ No newline at end of file diff --git a/ganeti_web/templates/ganeti/object_log/vm_reboot.html b/ganeti_web/templates/ganeti/object_log/vm_reboot.html index 2c89ed54..f2bc1ae6 100644 --- a/ganeti_web/templates/ganeti/object_log/vm_reboot.html +++ b/ganeti_web/templates/ganeti/object_log/vm_reboot.html @@ -1,5 +1,5 @@ {% with log_item.data as data %} - {% if log_item.object2 %} + {% if log_item.object2_id %} Job #{{ data.job_id }} - {% endif %} {% if user.is_superuser %} @@ -7,5 +7,6 @@ {% else %} {{ log_item.user }} {% endif %} -rebooted virtual machine {{data.hostname}} +rebooted virtual machine {% if log_item.object1_id %}{{data.hostname}} + {% else %}[deleted]{% endif %} {% endwith %} \ No newline at end of file diff --git a/ganeti_web/templates/ganeti/object_log/vm_recover.html b/ganeti_web/templates/ganeti/object_log/vm_recover.html index d4864ef4..46f667dc 100644 --- a/ganeti_web/templates/ganeti/object_log/vm_recover.html +++ b/ganeti_web/templates/ganeti/object_log/vm_recover.html @@ -1,5 +1,5 @@ {% with log_item.data as data %} - {% if log_item.object2 %} + {% if log_item.object2_id %} Job #{{ data.job_id }} - {% endif %} {% if user.is_superuser %} @@ -8,5 +8,6 @@ {{ log_item.user }} {% endif %} attempted recovery of virtual machine - {{data.hostname}} + {% if log_item.object1_id %}{{data.hostname}} + {% else %}[deleted]{% endif %} {% endwith %} \ No newline at end of file diff --git a/ganeti_web/templates/ganeti/object_log/vm_reinstall.html b/ganeti_web/templates/ganeti/object_log/vm_reinstall.html index adf977bb..abea66ec 100644 --- a/ganeti_web/templates/ganeti/object_log/vm_reinstall.html +++ b/ganeti_web/templates/ganeti/object_log/vm_reinstall.html @@ -1,5 +1,5 @@ {% with log_item.data as data %} - {% if log_item.object2 %} + {% if log_item.object2_id %} Job #{{ data.job_id }} - {% endif %} {% if user.is_superuser %} @@ -7,5 +7,6 @@ {% else %} {{ log_item.user }} {% endif %} -reinstalled virtual machine {{data.hostname}} +reinstalled virtual machine {% if log_item.object1_id %}{{data.hostname}} + {% else %}[deleted]{% endif %} {% endwith %} \ No newline at end of file diff --git a/ganeti_web/templates/ganeti/object_log/vm_rename.html b/ganeti_web/templates/ganeti/object_log/vm_rename.html index cf812bbf..964ff5df 100644 --- a/ganeti_web/templates/ganeti/object_log/vm_rename.html +++ b/ganeti_web/templates/ganeti/object_log/vm_rename.html @@ -1,5 +1,5 @@ {% with log_item.data as data %} - {% if log_item.object2 %} + {% if log_item.object2_id %} Job #{{ data.job_id }} - {% endif %} {% if user.is_superuser %} @@ -8,5 +8,6 @@ {{ log_item.user }} {% endif %} renamed virtual machine - {{data.hostname}} + {% if log_item.object1_id %}{{data.hostname}} + {% else %}[deleted]{% endif %} {% endwith %} \ No newline at end of file diff --git a/ganeti_web/templates/ganeti/object_log/vm_start.html b/ganeti_web/templates/ganeti/object_log/vm_start.html index 4991a28c..273dd129 100644 --- a/ganeti_web/templates/ganeti/object_log/vm_start.html +++ b/ganeti_web/templates/ganeti/object_log/vm_start.html @@ -1,11 +1,14 @@ {% with log_item.data as data %} - {% if log_item.object2 %} - Job #{{ data.job_id }} - + {% if log_item.object2_id %} + {% if log_item.object1 %} + Job #{{ data.job_id }} - + {% endif %} {% endif %} {% if user.is_superuser %} {{log_item.user}} {% else %} {{ log_item.user }} {% endif %} -started virtual machine {{data.hostname}} +started virtual machine {% if log_item.object1_id %}{{data.hostname}} + {% else %}[deleted]{% endif %} {% endwith %} \ No newline at end of file diff --git a/ganeti_web/templates/ganeti/object_log/vm_stop.html b/ganeti_web/templates/ganeti/object_log/vm_stop.html index d56a8817..326b8196 100644 --- a/ganeti_web/templates/ganeti/object_log/vm_stop.html +++ b/ganeti_web/templates/ganeti/object_log/vm_stop.html @@ -1,5 +1,5 @@ {% with log_item.data as data %} - {% if log_item.object2 %} + {% if log_item.object2_id %} Job #{{ data.job_id }} - {% endif %} {% if user.is_superuser %} @@ -7,5 +7,6 @@ {% else %} {{ log_item.user }} {% endif %} -stopped virtual machine {{data.hostname}} +stopped virtual machine {% if log_item.object1_id %}{{data.hostname}} + {% else %}[deleted]{% endif %} {% endwith %} \ No newline at end of file -- 2.11.4.GIT