mirror of https://github.com/jumpserver/jumpserver
Update csv
parent
205c11dfba
commit
180af7e0bd
|
@ -4,6 +4,7 @@
|
|||
{% load common_tags %}
|
||||
{% block content_left_head %}
|
||||
<link href="{% static "css/plugins/footable/footable.core.css" %}" rel="stylesheet">
|
||||
<link href="{% static 'css/plugins/datepicker/datepicker3.css' %}" rel="stylesheet">
|
||||
<style>
|
||||
#search_btn {
|
||||
margin-bottom: 0;
|
||||
|
@ -91,6 +92,7 @@
|
|||
|
||||
{% block custom_foot_js %}
|
||||
<script src="{% static "js/plugins/footable/footable.all.min.js" %}"></script>
|
||||
<script src="{% static 'js/plugins/datepicker/bootstrap-datepicker.js' %}"></script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('.footable').footable();
|
||||
|
|
|
@ -40,4 +40,5 @@ urlpatterns = [
|
|||
name='user-group-asset-permission-create'),
|
||||
url(r'^user-group/(?P<pk>[0-9]+)/assets', views.UserGroupGrantedAssetView.as_view(),
|
||||
name='user-group-granted-asset'),
|
||||
url(r'down-csv/', views.down_csv),
|
||||
]
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
# ~*~ coding: utf-8 ~*~
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from io import BytesIO
|
||||
|
||||
import csv
|
||||
import unicodecsv as csv
|
||||
from django import forms
|
||||
from django.conf import settings
|
||||
from django.utils import timezone
|
||||
from django.contrib.auth import login as auth_login, logout as auth_logout
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.contrib.messages.views import SuccessMessageMixin
|
||||
|
@ -19,8 +20,7 @@ from django.views.decorators.csrf import csrf_protect
|
|||
from django.views.decorators.debug import sensitive_post_parameters
|
||||
from django.views.generic.base import TemplateView
|
||||
from django.views.generic.list import ListView
|
||||
from django.views.generic.edit import CreateView, DeleteView, UpdateView, FormView, SingleObjectMixin, \
|
||||
FormMixin
|
||||
from django.views.generic.edit import CreateView, DeleteView, UpdateView, FormView, SingleObjectMixin, FormMixin
|
||||
from django.views.generic.detail import DetailView
|
||||
from formtools.wizard.views import SessionWizardView
|
||||
|
||||
|
@ -533,12 +533,16 @@ class BulkImportUserView(AdminUserRequiredMixin, JSONResponseMixin, FormView):
|
|||
return self.render_json_response(data)
|
||||
|
||||
|
||||
def down_csv(request, xx):
|
||||
print(xx)
|
||||
def down_csv(request):
|
||||
response = HttpResponse(content_type='application/csv')
|
||||
response['Content-Disposition'] = 'attachment; filename="somefile.csv"'
|
||||
response['Content-Disposition'] = 'attachment; filename="users-%s.csv"' % \
|
||||
timezone.localtime(timezone.now()).strftime('%Y-%m-%d')
|
||||
writer = csv.writer(response)
|
||||
writer.writerow(['First row', 'Foo', 'Bar', 'Baz'])
|
||||
writer.writerow(['Second row', 'A', 'B', 'C', '"Testing"', "Here's a quote"])
|
||||
header = [u"你好", 'username', 'email',
|
||||
_('user group'), _('role'), _('phone'), _('wechat'), _('comment')]
|
||||
writer.writerow(header)
|
||||
for user in User.objects.all():
|
||||
writer.writerow([user.name, user.username, user.email, ','.join([group.name for group in user.groups.all()]),
|
||||
user.role, user.phone, user.wechat, user.comment])
|
||||
return response
|
||||
|
||||
|
|
|
@ -14,4 +14,5 @@ djangorestframework-bulk==0.2.1
|
|||
paramiko==2.0.2
|
||||
django-redis-cache==1.7.1
|
||||
requests==2.11.1
|
||||
itsdangerous==0.24
|
||||
itsdangerous==0.24
|
||||
unicodecsv==0.14.1
|
Loading…
Reference in New Issue