mirror of https://github.com/jumpserver/jumpserver
stash it
parent
95e64d7809
commit
071d1922d0
|
@ -27,23 +27,6 @@
|
|||
</div>
|
||||
{% 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 %}
|
||||
<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 %}
|
||||
{% block custom_head_css_js %}
|
||||
<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">
|
||||
<script src="{% static "js/plugins/select2/select2.full.min.js" %}"></script>
|
||||
<script src="{% static "js/plugins/dataTables/dataTables.min.js" %}"></script>
|
||||
|
|
|
@ -114,10 +114,15 @@ class UserPublicKeyForm(forms.Form):
|
|||
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:
|
||||
model = User
|
||||
fields = ['username', 'email', 'enable_otp', 'role']
|
||||
fields = ['role', 'groups', 'date_expired', 'is_active', 'enable_otp']
|
||||
|
||||
|
||||
class UserGroupForm(forms.ModelForm):
|
||||
|
|
|
@ -23,6 +23,7 @@ class UserGroup(NoDeleteModelMixin):
|
|||
|
||||
def __unicode__(self):
|
||||
return self.name
|
||||
__str__ = __unicode__
|
||||
|
||||
def delete(self, using=None, keep_parents=False):
|
||||
self.group_ptr.delete()
|
||||
|
|
|
@ -1,37 +1,37 @@
|
|||
{% extends '_modal.html' %}
|
||||
{% load i18n %}
|
||||
{% load bootstrap3 %}
|
||||
{% 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 %}
|
||||
<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">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-2 col-lg-2 " for="id_role">{% trans "Role" %}</label>
|
||||
<div class=" col-sm-9 col-lg-9 ">
|
||||
<select class=" form-control" id="id_role" name="role">
|
||||
<option value="">---------</option>
|
||||
<option value="Admin">{% trans "Admin" %}</option>
|
||||
<option value="User">{% trans "User" %}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="groups" class="col-sm-2 control-label">{% trans 'Groups' %}</label>
|
||||
<div class="col-sm-9" id="select2-container">
|
||||
<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>
|
||||
{# {% for field in form %}#}
|
||||
{# <input type="checkbox">#}
|
||||
{# {% bootstrap_field field layout='horizontal' %}#}
|
||||
{# {% endfor %}#}
|
||||
{% bootstrap_form form layout='horizontal' %}
|
||||
|
||||
{# <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" disabled><label for="id_enable_otp">{% trans 'Enable-OTP' %}</label>#}
|
||||
{# </div>#}
|
||||
{# </div>#}
|
||||
{# </div>#}
|
||||
</form>
|
||||
{% endblock %}
|
||||
{% block modal_confirm_id %}btn_user_bulk_update{% endblock %}
|
||||
|
||||
|
|
|
@ -8,11 +8,12 @@
|
|||
{% csrf_token %}
|
||||
<div class="form-group">
|
||||
<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 class="form-group">
|
||||
<label class="control-label" for="id_users">{% trans "Users excel file" %}</label>
|
||||
<input id="id_users" type="file" name="file" />
|
||||
<span class="help-block">{% trans 'If set id, will use this id update existed' %}</span>
|
||||
</div>
|
||||
</form>
|
||||
<p>
|
||||
|
|
|
@ -55,8 +55,9 @@
|
|||
{% block custom_foot_js %}
|
||||
<script src="{% static 'js/jquery.form.min.js' %}"></script>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
var options = {
|
||||
|
||||
function renderTable() {
|
||||
var options = {
|
||||
ele: $('#user_list_table'),
|
||||
columnDefs: [
|
||||
{targets: 1, createdCell: function (td, cellData, rowData) {
|
||||
|
@ -91,7 +92,13 @@ $(document).ready(function(){
|
|||
op_html: $('#actions').html()
|
||||
};
|
||||
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 () {
|
||||
var users = [];
|
||||
var rows = table.rows('.selected').data();
|
||||
|
@ -242,7 +249,8 @@ $(document).ready(function(){
|
|||
$('#user_list_table').DataTable().ajax.reload();
|
||||
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');
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -52,7 +52,8 @@ class UserListView(AdminUserRequiredMixin, TemplateView):
|
|||
context.update({
|
||||
'app': _('Users'),
|
||||
'action': _('User list'),
|
||||
'groups': UserGroup.objects.all()
|
||||
'groups': UserGroup.objects.all(),
|
||||
'form': forms.UserBulkUpdateForm(),
|
||||
})
|
||||
return context
|
||||
|
||||
|
@ -122,16 +123,16 @@ class UserDetailView(AdminUserRequiredMixin, DetailView):
|
|||
return super(UserDetailView, self).get_context_data(**kwargs)
|
||||
|
||||
|
||||
USER_ATTR_MAPPING = (
|
||||
('name', 'Name'),
|
||||
('username', 'Username'),
|
||||
('email', 'Email'),
|
||||
('groups', 'User groups'),
|
||||
('role', 'Role'),
|
||||
('phone', 'Phone'),
|
||||
('wechat', 'Wechat'),
|
||||
('comment', 'Comment'),
|
||||
)
|
||||
# USER_ATTR_MAPPING = (
|
||||
# ('name', 'Name'),
|
||||
# ('username', 'Username'),
|
||||
# ('email', 'Email'),
|
||||
# ('groups', 'User groups'),
|
||||
# ('role', 'Role'),
|
||||
# ('phone', 'Phone'),
|
||||
# ('wechat', 'Wechat'),
|
||||
# ('comment', 'Comment'),
|
||||
# )
|
||||
|
||||
|
||||
@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[_('User groups')] = 'groups'
|
||||
attr = [mapping_reverse.get(n, None) for n in header_]
|
||||
print(attr)
|
||||
if None in attr:
|
||||
data = {'valid': False,
|
||||
'msg': 'Must be same format as '
|
||||
|
|
Loading…
Reference in New Issue