diff --git a/apps/assets/serializers.py b/apps/assets/serializers.py new file mode 100644 index 000000000..4014f4bb6 --- /dev/null +++ b/apps/assets/serializers.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +from django.utils.translation import ugettext_lazy as _ +from rest_framework import viewsets, serializers,generics +from .models import AssetGroup, Asset, IDC, AssetExtend +from common.mixins import BulkDeleteApiMixin +from rest_framework_bulk import BulkListSerializer, BulkSerializerMixin + +class AssetBulkUpdateSerializer(BulkSerializerMixin, serializers.ModelSerializer): + # group_display = serializers.SerializerMethodField() + # active_display = serializers.SerializerMethodField() + #groups = serializers.PrimaryKeyRelatedField(many=True, queryset=AssetGroup.objects.all()) + + class Meta(object): + model = Asset + list_serializer_class = BulkListSerializer + fields = ['id', 'is_active', 'hostname'] + + # def get_group_display(self, obj): + # return " ".join([group.name for group in obj.groups.all()]) + # + # def get_active_display(self, obj): + # # TODO: user ative state + # return not (obj.is_expired and obj.is_active) \ No newline at end of file diff --git a/apps/assets/templates/assets/_asset_bulk_update_modal.html b/apps/assets/templates/assets/_asset_bulk_update_modal.html new file mode 100644 index 000000000..35b74492f --- /dev/null +++ b/apps/assets/templates/assets/_asset_bulk_update_modal.html @@ -0,0 +1,82 @@ +{% extends '_modal.html' %} +{% load i18n %} +{% block modal_id %}asset_bulk_update_modal{% endblock %} +{% block modal_class %}modal-lg{% endblock %} +{% block modal_title%}{% trans "Update Asset" %}{% endblock %} +{% block modal_body %} +{% load bootstrap %} +

{% trans "Hint: only change the field you want to update." %}

+ +
+
+

+ + 三年质保(0) + +

+
+
+
+
+ +
+ +
+
+
+ + +
+ +
+
+
+
+
+ +
+
+
+ + +
+ + + + + +
+ + + + + +

+ 最多5个标签,单个标签最长8个汉字,按回车确认 +

+ +
+ +
+ + + + + +
+{% endblock %} +{% block modal_confirm_id %}btn_asset_bulk_update{% endblock %} \ No newline at end of file diff --git a/apps/assets/templates/assets/asset_modal_update.html b/apps/assets/templates/assets/asset_modal_update.html new file mode 100644 index 000000000..138f7ed98 --- /dev/null +++ b/apps/assets/templates/assets/asset_modal_update.html @@ -0,0 +1,65 @@ +{% extends '_base_create_update.html' %} +{% load static %} +{% load bootstrap %} +{% load i18n %} + +{% block form %} + +
+
+
+

+ + + {% for f in form %} + {{ f.hostname }} + + {% endfor %} + 移除选择 +

+
+
+
+
+ {% csrf_token %} + + +
+ {{ form.hostname|bootstrap_horizontal }} + {{ form.ip|bootstrap_horizontal }} + {{ form.port|bootstrap_horizontal }} + {{ form.type|bootstrap_horizontal }} + + {{ form.idc|bootstrap_horizontal }} + {{ form.groups|bootstrap_horizontal }} + + {{ form.admin_user|bootstrap_horizontal }} + {{ form.system_users|bootstrap_horizontal }} + + {{ form.tags|bootstrap_horizontal }} + {{ form.comment|bootstrap_horizontal }} + +
+
+
+ + +
+
+ +
+{% endblock %} + +{% block custom_foot_js %} + +{% endblock %}