From 86c5f0d3d33f39935cddc616d7d9c972f205e0ec Mon Sep 17 00:00:00 2001 From: yumaojun03 <719118794@qq.com> Date: Mon, 19 Dec 2016 00:24:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90cron=E5=92=8Csudo=E7=9A=84lis?= =?UTF-8?q?t=E5=92=8Cdetail=E5=9F=BA=E7=A1=80=EF=BC=8Cansible=20Task?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=9B=B4=E4=B8=8A=E5=B1=82=E6=8A=BD=E8=B1=A1?= =?UTF-8?q?=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/ops/models/ansible.py | 16 +- apps/ops/templates/cron/detail.html | 141 ++------------ apps/ops/templates/cron/list.html | 9 +- apps/ops/templates/sudo/detail.html | 141 ++------------ apps/ops/templates/sudo/list.html | 7 +- apps/ops/templates/task/_task.html | 97 ++++++++++ apps/ops/templates/task/create.html | 16 ++ apps/ops/templates/task/detail.html | 282 ++++++++++++++++++++++++++++ apps/ops/templates/task/list.html | 226 ++++++++++++++++++++++ apps/ops/templates/task/update.html | 20 ++ 10 files changed, 689 insertions(+), 266 deletions(-) create mode 100644 apps/ops/templates/task/_task.html create mode 100644 apps/ops/templates/task/create.html create mode 100644 apps/ops/templates/task/detail.html create mode 100644 apps/ops/templates/task/list.html create mode 100644 apps/ops/templates/task/update.html diff --git a/apps/ops/models/ansible.py b/apps/ops/models/ansible.py index 3ebb5d18b..7ebf59476 100644 --- a/apps/ops/models/ansible.py +++ b/apps/ops/models/ansible.py @@ -4,10 +4,12 @@ from __future__ import unicode_literals, absolute_import import logging import json +from assets.models import Asset + from django.db import models from django.utils.translation import ugettext_lazy as _ -__all__ = ["Tasker", "AnsiblePlay", "AnsibleTask", "AnsibleHostResult"] +__all__ = ["Task", "Tasker", "AnsiblePlay", "AnsibleTask", "AnsibleHostResult"] logger = logging.getLogger(__name__) @@ -290,11 +292,9 @@ class AnsibleHostResult(models.Model): print('Error: %s, continue...' % e.message) continue +class Task(models.Model): + name = models.CharField(max_length=128, blank=True, verbose_name=_('Name')) + asset = models.ForeignKey(Asset, null=True, blank=True, related_name='crontables') - - - - - - - + def __unicode__(self): + pass \ No newline at end of file diff --git a/apps/ops/templates/cron/detail.html b/apps/ops/templates/cron/detail.html index b87e17a39..8089f917b 100644 --- a/apps/ops/templates/cron/detail.html +++ b/apps/ops/templates/cron/detail.html @@ -18,20 +18,20 @@
- {{ user_object.name }} + {{ cron.name }}
@@ -49,58 +49,9 @@
- - - - - - - - - - - - - - {% if user_object.phone %} - - - - - {% endif %} - {% if user_object.wechat %} - - - - - {% endif %} - - - - - - - - - - - - - - - - - - - - - - - +
- -
{% trans 'Name' %}:{{ user_object.name }}
{% trans 'Username' %}:{{ user_object.username }}
{% trans 'Email' %}:{{ user_object.email }}
{% trans 'Phone' %}:{{ user_object.phone }}
{% trans 'Wechat' %}:{{ user_object.wechat }}
{% trans 'Role' %}:{{ user_object.get_role_display }}
{% trans 'Date expired' %}:{{ user_object.date_expired|date:"Y-m-j H:i:s" }}
{% trans 'Created by' %}:{{ user_object.created_by }}
{% trans 'Date joined' %}:{{ user_object.date_joined|date:"Y-m-j H:i:s" }}
{% trans 'Last login' %}:{{ user_object.last_login|date:"Y-m-j H:i:s" }}
{% trans 'Comment' %}:{{ user_object.comment }}{{ cron.name }}
@@ -120,7 +71,7 @@
- +
-
+
+
+
+ +
+
+ {% csrf_token %} +

{% trans 'Account' %}

+ {% block username %} {% endblock %} + {{ form.email|bootstrap_horizontal }} + {{ form.name|bootstrap_horizontal }} + {{ form.groups|bootstrap_horizontal }} + +
+ {% block password %} {% endblock %} + +
+

{% trans 'Security and Role' %}

+ {{ form.role|bootstrap_horizontal }} +
+ +
+
+ + +
+ {{ form.date_expired.errors }} +
+
+{# {{ form.date_expired|bootstrap_horizontal }}#} +
+ +
+ {{ form.enable_otp }} +
+
+
+

{% trans 'Profile' %}

+ {{ form.phone|bootstrap_horizontal }} + {{ form.wechat|bootstrap_horizontal }} + {{ form.comment|bootstrap_horizontal }} +
+
+
+ + +
+
+
+
+
+
+
+
+{% endblock %} +{% block custom_foot_js %} + + +{% endblock %} diff --git a/apps/ops/templates/task/create.html b/apps/ops/templates/task/create.html new file mode 100644 index 000000000..19727e102 --- /dev/null +++ b/apps/ops/templates/task/create.html @@ -0,0 +1,16 @@ +{% extends 'sudo/_sudo.html' %} +{% load i18n %} +{% load bootstrap %} +{% block user_template_title %}{% trans "Create user" %}{% endblock %} +{% block username %} + {{ form.username|bootstrap_horizontal }} +{% endblock %} +{% block password %} +

{% trans 'Password' %}

+
+ +
+ {% trans 'Reset link will be generated and sent to the user. ' %} +
+
+{% endblock %} \ No newline at end of file diff --git a/apps/ops/templates/task/detail.html b/apps/ops/templates/task/detail.html new file mode 100644 index 000000000..95faa39e5 --- /dev/null +++ b/apps/ops/templates/task/detail.html @@ -0,0 +1,282 @@ +{% extends 'base.html' %} +{% load common_tags %} +{% load users_tags %} +{% load static %} +{% load i18n %} + +{% block custom_head_css_js %} + + + + +{% endblock %} +{% block content %} +
+
+
+
+ +
+
+
+
+ {{ sudo.name }} +
+ + + + + + + + + + +
+
+
+ + + + + + + +
{% trans 'Name' %}:{{ sudo.name }}
+
+
+
+
+
+
+ {% trans 'Quick modify' %} +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
{% trans 'Active' %}: +
+
+ + +
+
+
{% trans 'Enable OTP' %}: +
+
+ + +
+
+
{% trans 'Reset password' %}: + + + +
{% trans 'Reset ssh key' %}: + + + +
{% trans 'Update ssh key' %}: + + + +
+
+
+ +
+
+ {% trans 'User group' %} +
+
+ + + + + + + + + + + + {% for group in user_object.groups.all %} + + + + + {% endfor %} + +
+ +
+ +
{{ group.name }} + +
+
+
+
+
+
+
+
+
+ {% include 'users/_user_update_pk_modal.html' %} +{% endblock %} +{% block custom_foot_js %} + +{% endblock %} diff --git a/apps/ops/templates/task/list.html b/apps/ops/templates/task/list.html new file mode 100644 index 000000000..8da993251 --- /dev/null +++ b/apps/ops/templates/task/list.html @@ -0,0 +1,226 @@ +{% extends '_base_list.html' %} +{% load i18n static %} +{% block table_search %} +{% endblock %} +{% block table_container %} + +{##} + + + + + + + + + + + + + +
+ + {% trans 'Name' %}{% trans 'Privileges' %}{% trans 'Extra Lines' %}{% trans 'Action' %}
+
+
+ +
+ +
+
+
+{#{% include "users/_user_bulk_update_modal.html" %}#} +{#{% include "users/_user_import_modal.html" %}#} +{% endblock %} +{% block content_bottom_left %}{% endblock %} +{% block custom_foot_js %} + + +{% endblock %} + diff --git a/apps/ops/templates/task/update.html b/apps/ops/templates/task/update.html new file mode 100644 index 000000000..3172d23f4 --- /dev/null +++ b/apps/ops/templates/task/update.html @@ -0,0 +1,20 @@ +{% extends 'sudo/_sudo.html' %} +{% load i18n %} +{% block user_template_title %}{% trans "Update user" %}{% endblock %} +{% block username %} +
+ +
+ +
+
+{% endblock %} +{% block password %} +

{% trans 'Password' %}

+
+ +
+ +
+
+{% endblock %}