mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-06-23 13:37:31 +00:00
stash it
This commit is contained in:
parent
95e64d7809
commit
071d1922d0
@ -27,23 +27,6 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block tags_list %}
|
|
||||||
<div class="ydxbd" id="ydxbd" style="display: none;">
|
|
||||||
<div class="tagBtnList">
|
|
||||||
{% for tag in tag_list %}
|
|
||||||
<a href="{% url 'assets:asset-tags' tag_id=tag.0 %}"
|
|
||||||
{% if tag.0 == tag_id %}
|
|
||||||
class="tagBtn2 label label-warning" name="tag_on">
|
|
||||||
{% else %}
|
|
||||||
class="tagBtn2 label label-default">
|
|
||||||
{% endif %}
|
|
||||||
{{ tag.1}}({{ tag.2 }})
|
|
||||||
</a>
|
|
||||||
{% endfor %}
|
|
||||||
<a href="{% url 'assets:asset-list' %}" class="tagBtn2 label label-default" >移除选择</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block table_container %}
|
{% block table_container %}
|
||||||
<div class="uc pull-left m-l-5 m-r-5"><a href="{% url "assets:asset-create" %}" class="btn btn-sm btn-primary"> {% trans "Create asset" %} </a></div>
|
<div class="uc pull-left m-l-5 m-r-5"><a href="{% url "assets:asset-create" %}" class="btn btn-sm btn-primary"> {% trans "Create asset" %} </a></div>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% block custom_head_css_js %}
|
{% block custom_head_css_js %}
|
||||||
<link href="{% static "css/plugins/dataTables/datatables.min.css" %}" rel="stylesheet">
|
<link href="{% static "css/plugins/dataTables/datatables.min.css" %}" rel="stylesheet">
|
||||||
<link href="{% static "css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" %}" rel="stylesheet">
|
{# <link href="{% static "css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" %}" rel="stylesheet">#}
|
||||||
<link href="{% static "css/plugins/select2/select2.min.css" %}" rel="stylesheet">
|
<link href="{% static "css/plugins/select2/select2.min.css" %}" rel="stylesheet">
|
||||||
<script src="{% static "js/plugins/select2/select2.full.min.js" %}"></script>
|
<script src="{% static "js/plugins/select2/select2.full.min.js" %}"></script>
|
||||||
<script src="{% static "js/plugins/dataTables/dataTables.min.js" %}"></script>
|
<script src="{% static "js/plugins/dataTables/dataTables.min.js" %}"></script>
|
||||||
|
@ -114,10 +114,15 @@ class UserPublicKeyForm(forms.Form):
|
|||||||
return self.instance
|
return self.instance
|
||||||
|
|
||||||
|
|
||||||
class UserBulkImportForm(forms.ModelForm):
|
# class UserBulkImportForm(forms.ModelForm):
|
||||||
|
# class Meta:
|
||||||
|
# model = User
|
||||||
|
# fields = ['username', 'email', 'enable_otp', 'role']
|
||||||
|
|
||||||
|
class UserBulkUpdateForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = User
|
model = User
|
||||||
fields = ['username', 'email', 'enable_otp', 'role']
|
fields = ['role', 'groups', 'date_expired', 'is_active', 'enable_otp']
|
||||||
|
|
||||||
|
|
||||||
class UserGroupForm(forms.ModelForm):
|
class UserGroupForm(forms.ModelForm):
|
||||||
|
@ -23,6 +23,7 @@ class UserGroup(NoDeleteModelMixin):
|
|||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
__str__ = __unicode__
|
||||||
|
|
||||||
def delete(self, using=None, keep_parents=False):
|
def delete(self, using=None, keep_parents=False):
|
||||||
self.group_ptr.delete()
|
self.group_ptr.delete()
|
||||||
|
@ -1,37 +1,37 @@
|
|||||||
{% extends '_modal.html' %}
|
{% extends '_modal.html' %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
{% load bootstrap3 %}
|
||||||
{% block modal_id %}user_bulk_update_modal{% endblock %}
|
{% block modal_id %}user_bulk_update_modal{% endblock %}
|
||||||
{% block modal_title%}{% trans "Update User" %}{% endblock %}
|
{% block modal_class %}modal-lg{% endblock %}
|
||||||
|
{% block modal_title%}{% trans "Update selected user" %}{% endblock %}
|
||||||
{% block modal_body %}
|
{% block modal_body %}
|
||||||
<p class="text-success text-center">{% trans "Hint: only change the field you want to update." %}</p>
|
<div class="ydxbd" id="ydxbd" style="display: block;">
|
||||||
|
<div>
|
||||||
|
<p id="tags_p">
|
||||||
|
<a href="/assets/asset-by-tag/5">
|
||||||
|
<span class="label label-default">三年质保(0)</span>
|
||||||
|
</a>
|
||||||
|
<a href="/assets/asset-by-tag/5">
|
||||||
|
<span class="label label-default">三年质保(0)</span>
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<form method="post" class="form-horizontal" action="" id="fm_user_bulk_update">
|
<form method="post" class="form-horizontal" action="" id="fm_user_bulk_update">
|
||||||
<div class="form-group">
|
{# {% for field in form %}#}
|
||||||
<label class="control-label col-sm-2 col-lg-2 " for="id_role">{% trans "Role" %}</label>
|
{# <input type="checkbox">#}
|
||||||
<div class=" col-sm-9 col-lg-9 ">
|
{# {% bootstrap_field field layout='horizontal' %}#}
|
||||||
<select class=" form-control" id="id_role" name="role">
|
{# {% endfor %}#}
|
||||||
<option value="">---------</option>
|
{% bootstrap_form form layout='horizontal' %}
|
||||||
<option value="Admin">{% trans "Admin" %}</option>
|
|
||||||
<option value="User">{% trans "User" %}</option>
|
{# <div class="form-group">#}
|
||||||
</select>
|
{# <div class="col-sm-9 col-lg-9 col-sm-offset-2">#}
|
||||||
</div>
|
{# <div class="checkbox">#}
|
||||||
</div>
|
{# <input type="checkbox" name="enable_otp" checked id="id_enable_otp" disabled><label for="id_enable_otp">{% trans 'Enable-OTP' %}</label>#}
|
||||||
<div class="form-group">
|
{# </div>#}
|
||||||
<label for="groups" class="col-sm-2 control-label">{% trans 'Groups' %}</label>
|
{# </div>#}
|
||||||
<div class="col-sm-9" id="select2-container">
|
{# </div>#}
|
||||||
<select name="groups" id="select2_groups" data-placeholder="{% trans 'Select groups' %}" class="select2 form-control m-b" multiple>
|
|
||||||
{% for group in groups %}
|
|
||||||
<option value="{{ group.id }}">{{ group.name }}</option>
|
|
||||||
{% endfor %}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<div class="col-sm-9 col-lg-9 col-sm-offset-2">
|
|
||||||
<div class="checkbox">
|
|
||||||
<input type="checkbox" name="enable_otp" checked id="id_enable_otp"><label for="id_enable_otp">{% trans 'Enable-OTP' %}</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
</form>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block modal_confirm_id %}btn_user_bulk_update{% endblock %}
|
{% block modal_confirm_id %}btn_user_bulk_update{% endblock %}
|
||||||
|
|
||||||
|
@ -8,11 +8,12 @@
|
|||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label" for="id_users">{% trans "Template" %}</label>
|
<label class="control-label" for="id_users">{% trans "Template" %}</label>
|
||||||
<a href="{{ MEDIA_URL }}files/user_import_template.xlsx" style="display: block">{% trans 'Download' %}</a>
|
<a href="{% url 'users:user-export' %}" style="display: block">{% trans 'Download' %}</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label" for="id_users">{% trans "Users excel file" %}</label>
|
<label class="control-label" for="id_users">{% trans "Users excel file" %}</label>
|
||||||
<input id="id_users" type="file" name="file" />
|
<input id="id_users" type="file" name="file" />
|
||||||
|
<span class="help-block">{% trans 'If set id, will use this id update existed' %}</span>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<p>
|
<p>
|
||||||
|
@ -55,7 +55,8 @@
|
|||||||
{% block custom_foot_js %}
|
{% block custom_foot_js %}
|
||||||
<script src="{% static 'js/jquery.form.min.js' %}"></script>
|
<script src="{% static 'js/jquery.form.min.js' %}"></script>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function(){
|
|
||||||
|
function renderTable() {
|
||||||
var options = {
|
var options = {
|
||||||
ele: $('#user_list_table'),
|
ele: $('#user_list_table'),
|
||||||
columnDefs: [
|
columnDefs: [
|
||||||
@ -91,7 +92,13 @@ $(document).ready(function(){
|
|||||||
op_html: $('#actions').html()
|
op_html: $('#actions').html()
|
||||||
};
|
};
|
||||||
var table = jumpserver.initDataTable(options);
|
var table = jumpserver.initDataTable(options);
|
||||||
|
}
|
||||||
|
$(document).ready(function(){
|
||||||
|
renderTable();
|
||||||
|
var fields = $('#fm_user_bulk_update .form-group');
|
||||||
|
$.each(fields, function (index, value) {
|
||||||
|
console.log(value)
|
||||||
|
});
|
||||||
$('.btn_export').click(function () {
|
$('.btn_export').click(function () {
|
||||||
var users = [];
|
var users = [];
|
||||||
var rows = table.rows('.selected').data();
|
var rows = table.rows('.selected').data();
|
||||||
@ -242,7 +249,8 @@ $(document).ready(function(){
|
|||||||
$('#user_list_table').DataTable().ajax.reload();
|
$('#user_list_table').DataTable().ajax.reload();
|
||||||
jumpserver.checked = false;
|
jumpserver.checked = false;
|
||||||
};
|
};
|
||||||
APIUpdateAttr({url: the_url, method: 'PATCH', body: JSON.stringify(post_list), success: success});
|
console.log(body);
|
||||||
|
{# APIUpdateAttr({url: the_url, method: 'PATCH', body: JSON.stringify(post_list), success: success});#}
|
||||||
$('#user_bulk_update_modal').modal('hide');
|
$('#user_bulk_update_modal').modal('hide');
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -52,7 +52,8 @@ class UserListView(AdminUserRequiredMixin, TemplateView):
|
|||||||
context.update({
|
context.update({
|
||||||
'app': _('Users'),
|
'app': _('Users'),
|
||||||
'action': _('User list'),
|
'action': _('User list'),
|
||||||
'groups': UserGroup.objects.all()
|
'groups': UserGroup.objects.all(),
|
||||||
|
'form': forms.UserBulkUpdateForm(),
|
||||||
})
|
})
|
||||||
return context
|
return context
|
||||||
|
|
||||||
@ -122,16 +123,16 @@ class UserDetailView(AdminUserRequiredMixin, DetailView):
|
|||||||
return super(UserDetailView, self).get_context_data(**kwargs)
|
return super(UserDetailView, self).get_context_data(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
USER_ATTR_MAPPING = (
|
# USER_ATTR_MAPPING = (
|
||||||
('name', 'Name'),
|
# ('name', 'Name'),
|
||||||
('username', 'Username'),
|
# ('username', 'Username'),
|
||||||
('email', 'Email'),
|
# ('email', 'Email'),
|
||||||
('groups', 'User groups'),
|
# ('groups', 'User groups'),
|
||||||
('role', 'Role'),
|
# ('role', 'Role'),
|
||||||
('phone', 'Phone'),
|
# ('phone', 'Phone'),
|
||||||
('wechat', 'Wechat'),
|
# ('wechat', 'Wechat'),
|
||||||
('comment', 'Comment'),
|
# ('comment', 'Comment'),
|
||||||
)
|
# )
|
||||||
|
|
||||||
|
|
||||||
@method_decorator(csrf_exempt, name='dispatch')
|
@method_decorator(csrf_exempt, name='dispatch')
|
||||||
@ -208,7 +209,6 @@ class UserBulkImportView(AdminUserRequiredMixin, JSONResponseMixin, FormView):
|
|||||||
mapping_reverse = {field.verbose_name: field.name for field in fields}
|
mapping_reverse = {field.verbose_name: field.name for field in fields}
|
||||||
mapping_reverse[_('User groups')] = 'groups'
|
mapping_reverse[_('User groups')] = 'groups'
|
||||||
attr = [mapping_reverse.get(n, None) for n in header_]
|
attr = [mapping_reverse.get(n, None) for n in header_]
|
||||||
print(attr)
|
|
||||||
if None in attr:
|
if None in attr:
|
||||||
data = {'valid': False,
|
data = {'valid': False,
|
||||||
'msg': 'Must be same format as '
|
'msg': 'Must be same format as '
|
||||||
|
Loading…
Reference in New Issue
Block a user