diff --git a/apps/assets/tasks.py b/apps/assets/tasks.py index 89e2e410e..b716dc644 100644 --- a/apps/assets/tasks.py +++ b/apps/assets/tasks.py @@ -12,8 +12,7 @@ def update_assets_hardware_info(assets): task_tuple = ( ('setup', ''), ) - task_name = ','.join([asset.hostname for asset in assets]) - summary, result = run_AdHoc(task_tuple, assets, record=True, task_name=task_name) + summary, result = run_AdHoc(task_tuple, assets, record=False) for hostname, info in result['contacted'].items(): if info: info = info[0]['ansible_facts'] diff --git a/apps/assets/templates/assets/asset_list.html b/apps/assets/templates/assets/asset_list.html index d12462cab..6641fb0e6 100644 --- a/apps/assets/templates/assets/asset_list.html +++ b/apps/assets/templates/assets/asset_list.html @@ -104,37 +104,6 @@ function tagShow() { } } //onload; -function objDelete(obj, name, url) { - function doDelete() { - var body = {}; - var success = function() { - swal('Deleted!', "[ "+name+"]"+" has been deleted ", "success"); - $(obj).parent().parent().remove(); - }; - var fail = function() { - swal("Failed", "Delete"+"[ "+name+" ]"+"failed", "error"); - }; - APIUpdateAttr({ - url: url, - body: JSON.stringify(body), - method: 'DELETE', - success: success, - error: fail - }); - } - swal({ - title: 'Are you sure delete ?', - text: " [" + name + "] ", - type: "warning", - showCancelButton: true, - cancelButtonText: 'Cancel', - confirmButtonColor: "#DD6B55", - confirmButtonText: 'Confirm', - closeOnConfirm: false - }, function () { - doDelete() - }); -} $(document).ready(function(){ var options = { @@ -214,15 +183,10 @@ $(document).ready(function(){ .on('click', '.btn_asset_delete', function () { var $this = $(this); - var $data_table = $("#asset_list_table").DataTable(); var name = $(this).closest("tr").find(":nth-child(2)").children('a').html(); var uid = $this.data('uid'); var the_url = '{% url "api-assets:asset-detail" pk=99991937 %}'.replace('99991937', uid); - console.log(the_url); - objDelete($this, name, the_url); - setTimeout( function () { - $data_table.ajax.reload(); - }, 3000); + objectDelete($this, name, the_url); }) .on('click', '#btn_bulk_update', function () { diff --git a/apps/ops/api.py b/apps/ops/api.py new file mode 100644 index 000000000..3a9e45b25 --- /dev/null +++ b/apps/ops/api.py @@ -0,0 +1,15 @@ +# ~*~ coding: utf-8 ~*~ + + +from rest_framework import viewsets + +from .hands import IsSuperUser +from .models import Task +from .serializers import TaskSerializer + + +class TaskViewSet(viewsets.ModelViewSet): + queryset = Task.objects.all() + serializer_class = TaskSerializer + permission_classes = (IsSuperUser,) + diff --git a/apps/ops/api/__init__.py b/apps/ops/api/__init__.py deleted file mode 100644 index c8b15abe0..000000000 --- a/apps/ops/api/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from views import * \ No newline at end of file diff --git a/apps/ops/api/exc.py b/apps/ops/api/exc.py deleted file mode 100644 index 81deb805c..000000000 --- a/apps/ops/api/exc.py +++ /dev/null @@ -1,16 +0,0 @@ -# ~*~ coding: utf-8 ~*~ -from __future__ import unicode_literals, print_function - -from rest_framework.exceptions import APIException -from django.utils.translation import ugettext as _ - - -class ServiceUnavailable(APIException): - status_code = default_code = 503 - default_detail = _('Service temporarily unavailable, try again later.') - - -class ServiceNotImplemented(APIException): - status_code = default_code = 501 - default_detail = _('This service maybe implemented in the future, but now not implemented!') - diff --git a/apps/ops/api/permissions.py b/apps/ops/api/permissions.py deleted file mode 100644 index 0fc0d0861..000000000 --- a/apps/ops/api/permissions.py +++ /dev/null @@ -1,19 +0,0 @@ -# ~*~ coding: utf-8 ~*~ -from __future__ import unicode_literals - -from rest_framework import permissions - - -class AdminUserRequired(permissions.BasePermission): - """ - Custom permission to only allow admin user to access the resource. - """ - - def has_object_permission(self, request, view, obj): - # Read permissions are allowed to any request, - # so we'll always allow GET, HEAD or OPTIONS requests. - if request.method in permissions.SAFE_METHODS: - return True - - # Write permissions are only allowed to the admin role. - return request.user.is_staff diff --git a/apps/ops/api/serializers.py b/apps/ops/api/serializers.py deleted file mode 100644 index af472b3cb..000000000 --- a/apps/ops/api/serializers.py +++ /dev/null @@ -1,4 +0,0 @@ -# ~*~ coding: utf-8 ~*~ -from __future__ import unicode_literals - - diff --git a/apps/ops/api/views.py b/apps/ops/api/views.py deleted file mode 100644 index affa9cdc7..000000000 --- a/apps/ops/api/views.py +++ /dev/null @@ -1,7 +0,0 @@ -# ~*~ coding: utf-8 ~*~ -from __future__ import unicode_literals -from rest_framework import viewsets - -from serializers import * -from permissions import * - diff --git a/apps/ops/hands.py b/apps/ops/hands.py new file mode 100644 index 000000000..d7175db18 --- /dev/null +++ b/apps/ops/hands.py @@ -0,0 +1,4 @@ +# ~*~ coding: utf-8 ~*~ + +from users.permissions import IsSuperUser + diff --git a/apps/ops/serializers.py b/apps/ops/serializers.py new file mode 100644 index 000000000..986ee66e6 --- /dev/null +++ b/apps/ops/serializers.py @@ -0,0 +1,13 @@ +# ~*~ coding: utf-8 ~*~ +from __future__ import unicode_literals +from rest_framework import serializers + +from .models import Task + + +class TaskSerializer(serializers.ModelSerializer): + class Meta: + model = Task + fields = '__all__' + + diff --git a/apps/ops/templates/ops/task_list.html b/apps/ops/templates/ops/task_list.html index cb64849a4..dac614805 100644 --- a/apps/ops/templates/ops/task_list.html +++ b/apps/ops/templates/ops/task_list.html @@ -35,7 +35,7 @@ {% endblock %} {% block table_head %} -