diff --git a/apps/applications/api.py b/apps/applications/api.py index 48f06a806..508748ae6 100644 --- a/apps/applications/api.py +++ b/apps/applications/api.py @@ -64,10 +64,3 @@ class TerminalHeatbeatViewSet(viewsets.ModelViewSet): terminal = request.user.terminal TerminalHeatbeat.objects.create(terminal=terminal) return Response({'msg': 'Success'}, status=201) - - -class TestHeatbeat(APIView): - permission_classes = (IsAppUser,) - - def post(self, request): - return Response({'hello': 'world'}) \ No newline at end of file diff --git a/apps/applications/templates/applications/terminal_form.html b/apps/applications/templates/applications/terminal_form.html deleted file mode 100644 index e69de29bb..000000000 diff --git a/apps/applications/templates/applications/terminal_list.html b/apps/applications/templates/applications/terminal_list.html index cf570395d..9a93b761b 100644 --- a/apps/applications/templates/applications/terminal_list.html +++ b/apps/applications/templates/applications/terminal_list.html @@ -122,12 +122,10 @@ $(document).ready(function(){ }).on('click', '#btn_terminal_accept', function () { var $form = $('#form_terminal_accept'); function success (data, textStatus, jqXHR) { - if (data.success === false) { - console.log(data.msg); + if (data.success === true) { window.location.reload() - } else { - console.log(data.msg); + $('#modal-error').html(data.msg).css('display', 'block'); } } $form.ajaxSubmit({success: success}); diff --git a/apps/applications/templates/applications/terminal_modal_accept.bak.html b/apps/applications/templates/applications/terminal_modal_accept.bak.html deleted file mode 100644 index 1664642dc..000000000 --- a/apps/applications/templates/applications/terminal_modal_accept.bak.html +++ /dev/null @@ -1,26 +0,0 @@ -{% extends '_modal.html' %} -{% load static %} -{% load bootstrap %} -{% load i18n %} - -{% block modal_body %} -
- {% csrf_token %} - {{ form.name|bootstrap_horizontal }} - {{ form.remote_addr|bootstrap_horizontal }} - {{ form.type|bootstrap_horizontal }} - {{ form.url|bootstrap_horizontal }} - {{ form.comment|bootstrap_horizontal }} - -
-
-
- - -
-
-
-{% endblock %} - -{% block custom_foot_js %} -{% endblock %} \ No newline at end of file diff --git a/apps/applications/templates/applications/terminal_modal_accept.html b/apps/applications/templates/applications/terminal_modal_accept.html index a48923dd0..2036eb7c5 100644 --- a/apps/applications/templates/applications/terminal_modal_accept.html +++ b/apps/applications/templates/applications/terminal_modal_accept.html @@ -7,6 +7,7 @@ {% load bootstrap %}
{% csrf_token %} + {{ form.name|bootstrap_horizontal }} {{ form.remote_addr|bootstrap_horizontal }} {{ form.type|bootstrap_horizontal }} diff --git a/apps/applications/views.py b/apps/applications/views.py index 70bbd27cb..c9a370c0a 100644 --- a/apps/applications/views.py +++ b/apps/applications/views.py @@ -2,6 +2,7 @@ # from django.views.generic import ListView, UpdateView, DeleteView, FormView +from django.views.generic.edit import BaseUpdateView from django.utils.translation import ugettext as _ from django.urls import reverse_lazy @@ -44,10 +45,14 @@ class TerminalDeleteView(DeleteView): success_url = reverse_lazy('applications:applications-list') -class TerminalModelAccept(AdminUserRequiredMixin, JSONResponseMixin, UpdateView): +class TerminalModelAccept(AdminUserRequiredMixin, JSONResponseMixin, BaseUpdateView): model = Terminal form_class = TerminalForm + def post(self, request, *args, **kwargs): + print(request.POST) + return super(TerminalModelAccept, self).post(request, *args, **kwargs) + def form_valid(self, form): terminal = form.save() terminal.is_accepted = True @@ -57,14 +62,13 @@ class TerminalModelAccept(AdminUserRequiredMixin, JSONResponseMixin, UpdateView) 'success': True, 'msg': 'success' } - print('Valid') return self.render_json_response(data) def form_invalid(self, form): - print(form.errors) + print('form.data') data = { 'success': False, - 'msg': ','.join(form.errors) + 'msg': str(form.errors), } return self.render_json_response(data) diff --git a/apps/users/authentication.py b/apps/users/authentication.py index 5bd6843f0..db58b0ed4 100644 --- a/apps/users/authentication.py +++ b/apps/users/authentication.py @@ -65,8 +65,6 @@ class AccessKeyAuthentication(authentication.BaseAuthentication): raise exceptions.AuthenticationFailed(_('Invalid signature.')) access_key_secret = access_key.secret - print(request_date) - try: request_unix_time = http_to_unixtime(request_date) except ValueError: