diff --git a/apps/assets/forms.py b/apps/assets/forms.py
index 221420ce0..101ad854b 100644
--- a/apps/assets/forms.py
+++ b/apps/assets/forms.py
@@ -155,7 +155,7 @@ class SystemUserForm(forms.ModelForm):
attrs={'class': 'select2',
'data-placeholder': _('Select asset groups')})
)
- auto_generate_key = forms.BooleanField(required=True, initial=True)
+ auto_generate_key = forms.BooleanField(initial=True)
# Form field name can not start with `_`, so redefine it,
password = forms.CharField(widget=forms.PasswordInput, max_length=100, min_length=8, strip=True,
help_text=_('If also set private key, use that first'), required=False)
diff --git a/apps/assets/templates/assets/system_user_asset.html b/apps/assets/templates/assets/system_user_asset.html
new file mode 100644
index 000000000..4f1fb4097
--- /dev/null
+++ b/apps/assets/templates/assets/system_user_asset.html
@@ -0,0 +1,139 @@
+{% extends 'base.html' %}
+{% load common_tags %}
+{% load users_tags %}
+{% load static %}
+{% load i18n %}
+
+{% block custom_head_css_js %}
+
+
+{% endblock %}
+{% block content %}
+
+
+
+
+
+
+
+
+
+
{% trans 'Asset list of ' %} {{ admin_user.name }}
+
+
+
+
+
+
+ {% trans 'Hostname' %} |
+ {% trans 'IP' %} |
+ {% trans 'Port' %} |
+ {% trans 'Alive' %} |
+
+
+
+ {% for asset in page_obj %}
+
+ {{ asset.hostname }} |
+ {{ asset.ip }} |
+ {{ asset.port }} |
+ Alive |
+
+ {% endfor %}
+
+
+
+ {% include '_pagination.html' %}
+
+
+
+
+
+
+
+ {% trans 'Add asset to this system user' %}
+
+
+
+
+
+
+
+
+
+
+
+{% endblock %}
+{% block custom_foot_js %}
+
+{% endblock %}
\ No newline at end of file
diff --git a/apps/assets/templates/assets/system_user_asset_group.html b/apps/assets/templates/assets/system_user_asset_group.html
new file mode 100644
index 000000000..bcddd09fc
--- /dev/null
+++ b/apps/assets/templates/assets/system_user_asset_group.html
@@ -0,0 +1,140 @@
+{% extends 'base.html' %}
+{% load common_tags %}
+{% load users_tags %}
+{% load static %}
+{% load i18n %}
+
+{% block custom_head_css_js %}
+
+
+{% endblock %}
+{% block content %}
+
+
+
+
+
+
+
+
+
+
{% trans 'Asset list of ' %} {{ admin_user.name }}
+
+
+
+
+
+
+ {% trans 'Name' %} |
+ {% trans 'Asset num' %} |
+ {% trans 'Unavailable num' %} |
+ {% trans 'Comment' %} |
+
+
+
+ {% for asset_group in page_obj %}
+
+ {{ asset_group.name }} |
+ {{ asset_group_group.assets.count }} |
+ {{ asset_group_group.assets.count }} |
+ {{ asset_group.comment|truncatewords:4 }} |
+
+ {% endfor %}
+
+
+
+ {% include '_pagination.html' %}
+
+
+
+
+
+
+
+ {% trans 'Add asset group to this system user' %}
+
+
+
+
+
+
+
+
+
+
+
+{% endblock %}
+{% block custom_foot_js %}
+
+{% endblock %}
\ No newline at end of file
diff --git a/apps/assets/templates/assets/system_user_detail.html b/apps/assets/templates/assets/system_user_detail.html
new file mode 100644
index 000000000..9dde0a0e1
--- /dev/null
+++ b/apps/assets/templates/assets/system_user_detail.html
@@ -0,0 +1,192 @@
+{% extends 'base.html' %}
+{% load common_tags %}
+{% load users_tags %}
+{% load static %}
+{% load i18n %}
+
+{% block custom_head_css_js %}
+
+
+{% endblock %}
+{% block content %}
+
+
+
+
+
+
+
+
+
+
{{ system_user.name }}
+
+
+
+
+
+
+ {% trans 'Name' %}: |
+ {{ system_user.name }} |
+
+
+ {% trans 'Username' %}: |
+ {{ system_user.username }} |
+
+
+ {% trans 'Protocol' %}: |
+ {{ system_user.protocol }} |
+
+
+ {% trans 'Auto push' %}: |
+ {{ system_user.protocol }} |
+
+
+ {% trans 'Auto update' %}: |
+ {{ system_user.auto_update }} |
+
+
+ {% trans 'As default' %}: |
+ {{ system_user.protocol }} |
+
+
+ {% trans 'Sudo' %}: |
+ {{ system_user.sudo }} |
+
+ {% if system_user.shell %}
+
+ {% trans 'Shell' %}: |
+ {{ system_user.shell }} |
+
+ {% endif %}
+ {% if system_user.home %}
+
+ {% trans 'Home' %}: |
+ {{ system_user.home }} |
+
+ {% endif %}
+ {% if system_user.uid %}
+
+ {% trans 'Uid' %}: |
+ {{ system_user.uid }} |
+
+ {% endif %}
+
+ {% trans 'Date created' %}: |
+ {{ system_user.date_created }} |
+
+
+ {% trans 'Created by' %}: |
+ {{ asset_group.created_by }} |
+
+
+ {% trans 'Comment' %}: |
+ {{ system_user.comment }} |
+
+
+
+
+
+
+
+
+
+
+ {% trans 'Quick update' %}
+
+
+
+
+
+ {% trans 'Get mannual install script' %}: |
+
+
+
+
+ |
+
+
+
+ {% trans 'Retest asset connectivity' %}: |
+
+
+
+
+ |
+
+
+
+ {% trans 'Reset private key' %}: |
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+{% endblock %}
+{% block custom_foot_js %}
+
+{% endblock %}
\ No newline at end of file
diff --git a/apps/assets/templates/assets/system_user_list.html b/apps/assets/templates/assets/system_user_list.html
index 12f2b0bdf..37be0c3fc 100644
--- a/apps/assets/templates/assets/system_user_list.html
+++ b/apps/assets/templates/assets/system_user_list.html
@@ -11,7 +11,7 @@
{% trans 'Username' %} |
{% trans 'Asset num' %} |
{% trans 'Asset group num' %} |
- {% trans 'Lost connection' %} |
+ {% trans 'Unavailable' %} |
{% trans 'Comment' %} |
|
{% endblock %}
@@ -29,7 +29,7 @@
{{ system_user.assets.count }} |
{{ system_user.asset_groups.count }} |
{{ system_user.assets.count }} |
- {{ system_user.comment|truncatewords:8 }} |
+ {{ system_user.comment|truncatewords:4 }} |
{% trans 'Script' %}
diff --git a/apps/assets/urls.py b/apps/assets/urls.py
index d19f294a4..ad2224048 100644
--- a/apps/assets/urls.py
+++ b/apps/assets/urls.py
@@ -38,5 +38,8 @@ urlpatterns = [
url(r'^system-user/(?P[0-9]+)$', views.SystemUserDetailView.as_view(), name='system-user-detail'),
url(r'^system-user/(?P[0-9]+)/update', views.SystemUserUpdateView.as_view(), name='system-user-update'),
url(r'^system-user/(?P[0-9]+)/delete$', views.SystemUserDeleteView.as_view(), name='system-user-delete'),
+ url(r'^system-user/(?P[0-9]+)/asset$', views.SystemUserAssetView.as_view(), name='system-user-asset'),
+ url(r'^system-user/(?P[0-9]+)/asset-group$', views.SystemUserAssetGroupView.as_view(),
+ name='system-user-asset-group'),
# url(r'^api/v1.0/', include(router.urls)),
]
diff --git a/apps/assets/views.py b/apps/assets/views.py
index aa44c819d..04f4ae053 100644
--- a/apps/assets/views.py
+++ b/apps/assets/views.py
@@ -335,8 +335,8 @@ class SystemUserCreateView(AdminUserRequiredMixin, SuccessMessageMixin, CreateVi
def get_context_data(self, **kwargs):
context = {
- 'app': 'assets',
- 'action': 'Create system user'
+ 'app': _('Assets'),
+ 'action': _('Create system user'),
}
kwargs.update(context)
return super(SystemUserCreateView, self).get_context_data(**kwargs)
@@ -356,8 +356,8 @@ class SystemUserUpdateView(AdminUserRequiredMixin, UpdateView):
def get_context_data(self, **kwargs):
context = {
- 'app': 'assets',
- 'action': 'Update system user'
+ 'app': _('Assets'),
+ 'action': _('Update system user')
}
kwargs.update(context)
return super(SystemUserUpdateView, self).get_context_data(**kwargs)
@@ -367,10 +367,68 @@ class SystemUserUpdateView(AdminUserRequiredMixin, UpdateView):
return success_url
-class SystemUserDetailView(DetailView):
- pass
+class SystemUserDetailView(AdminUserRequiredMixin, DetailView):
+ template_name = 'assets/system_user_detail.html'
+ context_object_name = 'system_user'
+ model = SystemUser
+
+ def get_context_data(self, **kwargs):
+ context = {
+ 'app': _('Assets'),
+ 'action': _('System user detail')
+ }
+ kwargs.update(context)
+ return super(SystemUserDetailView, self).get_context_data(**kwargs)
-class SystemUserDeleteView(DeleteView):
- pass
+class SystemUserDeleteView(AdminUserRequiredMixin, DeleteView):
+ model = SystemUser
+ template_name = 'assets/delete_confirm.html'
+ success_url = 'assets:system-user-list'
+
+
+class SystemUserAssetView(AdminUserRequiredMixin, SingleObjectMixin, ListView):
+ paginate_by = settings.CONFIG.DISPLAY_PER_PAGE
+ template_name = 'assets/system_user_asset.html'
+ context_object_name = 'system_user'
+
+ def get(self, request, *args, **kwargs):
+ self.object = self.get_object(queryset=SystemUser.objects.all())
+ return super(SystemUserAssetView, self).get(request, *args, **kwargs)
+
+ # Todo: queryset default order by connectivity, need ops support
+ def get_queryset(self):
+ return self.object.assets.all()
+
+ def get_context_data(self, **kwargs):
+ context = {
+ 'app': 'assets',
+ 'action': 'System user asset',
+ 'assets': self.get_queryset(),
+ }
+ kwargs.update(context)
+ return super(SystemUserAssetView, self).get_context_data(**kwargs)
+
+
+class SystemUserAssetGroupView(AdminUserRequiredMixin, SingleObjectMixin, ListView):
+ paginate_by = settings.CONFIG.DISPLAY_PER_PAGE
+ template_name = 'assets/system_user_asset_group.html'
+ context_object_name = 'system_user'
+
+ def get(self, request, *args, **kwargs):
+ self.object = self.get_object(queryset=SystemUser.objects.all())
+ return super(SystemUserAssetGroupView, self).get(request, *args, **kwargs)
+
+ # Todo: queryset default order by connectivity, need ops support
+ def get_queryset(self):
+ return self.object.asset_groups.all()
+
+ def get_context_data(self, **kwargs):
+ context = {
+ 'app': 'assets',
+ 'action': 'System user asset group',
+ 'asset_groups': self.get_queryset(),
+ }
+ kwargs.update(context)
+ return super(SystemUserAssetGroupView, self).get_context_data(**kwargs)
|