|
@@ -1,7 +1,9 @@
|
|
# -*- coding: utf-8 -*-
|
|
# -*- coding: utf-8 -*-
|
|
import time
|
|
import time
|
|
|
|
|
|
|
|
+import xlwt
|
|
from django.db.models import Count,Q
|
|
from django.db.models import Count,Q
|
|
|
|
+from django.http import HttpResponse
|
|
from django.views.decorators.csrf import csrf_exempt
|
|
from django.views.decorators.csrf import csrf_exempt
|
|
from django.views.generic import TemplateView
|
|
from django.views.generic import TemplateView
|
|
from django.utils.decorators import method_decorator
|
|
from django.utils.decorators import method_decorator
|
|
@@ -78,6 +80,8 @@ class AdminManage(TemplateView):
|
|
return self.getAppFrequency(userID, request_dict, response)
|
|
return self.getAppFrequency(userID, request_dict, response)
|
|
if operation == 'getHistoryAppFrequency':
|
|
if operation == 'getHistoryAppFrequency':
|
|
return self.getAllAppFrequency(userID, response)
|
|
return self.getAllAppFrequency(userID, response)
|
|
|
|
+ if operation == 'downloadSubscribeEmail':
|
|
|
|
+ return self.download_subscribe_email(userID, request_dict, response)
|
|
|
|
|
|
def resetUserPwd(self, request_dict, userID, response):
|
|
def resetUserPwd(self, request_dict, userID, response):
|
|
own_permission = ModelService.check_perm(userID=userID, permID=50)
|
|
own_permission = ModelService.check_perm(userID=userID, permID=50)
|
|
@@ -434,6 +438,29 @@ class AdminManage(TemplateView):
|
|
else:
|
|
else:
|
|
return response.json(0, [])
|
|
return response.json(0, [])
|
|
|
|
|
|
|
|
+ def download_subscribe_email(self, userID, request_dict, response):
|
|
|
|
+ own_permission = ModelService.check_perm(userID=userID, permID=30)
|
|
|
|
+ if own_permission is not True:
|
|
|
|
+ return response.json(404)
|
|
|
|
+
|
|
|
|
+ user_qs = Device_User.objects.filter(subscribe_email=1).values('userEmail')
|
|
|
|
+ print(user_qs)
|
|
|
|
+ response = HttpResponse(content_type='application/vnd.ms-excel')
|
|
|
|
+ response['Content-Disposition'] = 'attachment; filename=UID' + time.strftime('-%Y-%m-%d-%H-%M-%S', time.localtime()) + '.xls'
|
|
|
|
+ workbook = xlwt.Workbook(encoding='utf-8')
|
|
|
|
+ sheet1 = workbook.add_sheet('Email Address')
|
|
|
|
+
|
|
|
|
+ num = 1
|
|
|
|
+ sheet1.write(0, 0, 'Email Address')
|
|
|
|
+ for user in user_qs:
|
|
|
|
+ email = user['userEmail']
|
|
|
|
+ if email == '':
|
|
|
|
+ continue
|
|
|
|
+ sheet1.write(num, 0, email)
|
|
|
|
+ num += 1
|
|
|
|
+ workbook.save(response)
|
|
|
|
+ return response
|
|
|
|
+
|
|
|
|
|
|
@require_http_methods(["GET"])
|
|
@require_http_methods(["GET"])
|
|
def getUserIds(request):
|
|
def getUserIds(request):
|