[Bugfix] 修复以下bug

1. 查看执行历史异常
2. 用户授权资产页显示message
pull/915/head
ibuler 2018-01-10 18:08:27 +08:00
parent d415e81add
commit 6aaa106aff
3 changed files with 6 additions and 6 deletions

View File

@ -218,8 +218,8 @@ class AdHoc(models.Model):
history.result = raw
history.summary = summary
return raw, summary
except:
return {}, {}
except Exception as e:
return {}, {"dark": {"all": str(e)}, "contacted": []}
finally:
history.date_finished = timezone.now()
history.timedelta = time.time() - time_start

View File

@ -43,8 +43,8 @@ class AdHocRunHistorySerializer(serializers.ModelSerializer):
def get_stat(obj):
return {
"total": len(obj.adhoc.hosts),
"success": len(obj.summary["contacted"]),
"failed": len(obj.summary["dark"]),
"success": len(obj.summary.get("contacted", [])),
"failed": len(obj.summary.get("dark", [])),
}
def get_field_names(self, declared_fields, info):

View File

@ -1,6 +1,6 @@
{% load i18n %}
{% block first_login_message %}
{% if user.is_authenticated and user.is_first_login %}
{% if request.user.is_authenticated and request.user.is_first_login %}
<div class="alert alert-danger help-message">
{% url 'users:user-first-login' as first_login_url %}
{% blocktrans %}
@ -10,7 +10,7 @@
{% endif %}
{% endblock %}
{% block update_public_key_message %}
{% if user.is_authenticated and not user.is_public_key_valid %}
{% if request.user.is_authenticated and not request.user.is_public_key_valid %}
<div class="alert alert-danger help-message">
{% url 'users:user-pubkey-update' as user_pubkey_update %}
{% blocktrans %}