"keyword3": { "value": log.sn, "color": "#173177" }, "remark": { "value": u'感谢您的使用', "color": "#173177" } } wxcfg = WECHAT.get('MINIAPP', {}) appid = wxcfg.get('appID') sendtemplatemessage(openid=user.openid, template_id=settings.TEMPLATE_ID_COMPLEMENT, data=data, miniappid=appid, minipagepath='/pages/register/consumer/consumer?q={}&marketcode=1'.format(ciphertext)) return response(data={ 'ciphertext': ciphertext, }) return response() @check_admin @transaction.atomic def complement_code_contacted(request, administrator): log_id = request.POST.get('log_id', '') is_contacted = int(request.POST.get('is_contacted', 0)) # 0 未联系, 1 已联系 try: log = ComplementCodeLogInfo.objects.select_for_update().get(log_id=log_id, status=True) except ComplementCodeLogInfo.DoesNotExist: return response(ComplementCodeStatusCode.COMPLEMENT_CODE_NOT_FOUND) log.is_contacted = is_contacted log.save() return response() @check_admin def administrator_list(request, administrator): page = request.POST.get('page', 1) num = request.POST.get('num', 20) admin_type = request.POST.get('admin_type', '') logs = AdministratorInfo.objects.filter(status=True).order_by('-created_at') if admin_type: logs = logs.filter(admin_type=admin_type) count = logs.count() logs, left = pagination(logs, page, num) logs = [log.admindata for log in logs] return response(200, 'Get Admin List Success', u'获取后台管理员成功', data={ 'logs': logs, 'left': left, 'count': count }) @check_admin def administrator_create(request, administrator): admin_type = request.POST.get('admin_type', '') phone = request.POST.get('phone', '') name = request.POST.get('name', '') password = request.POST.get('password', '') brand_name = request.POST.get('brand_name', '') if administrator.admin_type != AdministratorInfo.ADMINISTRATOR: return response(AdministratorStatusCode.ADMINISTRATOR_PERMISSION_DENIED) encryption = make_password(strip(password), settings.MAKE_PASSWORD_SALT, settings.MAKE_PASSWORD_HASHER) AdministratorInfo.objects.create( brand_id=administrator.brand_id, brand_name=brand_name or administrator.brand_name, admin_type=admin_type, phone=phone, name=name, password='', encryption=encryption, ) return response(200, 'Create Admin Success', u'创建后台管理员成功') @check_admin def administrator_update(request, administrator): target_admin_id = request.POST.get('target_admin_id', '') admin_type = int(request.POST.get('admin_type', -1)) phone = request.POST.get('phone', '') name = request.POST.get('name', '') password = request.POST.get('password', '') if administrator.admin_type != AdministratorInfo.ADMINISTRATOR: return response(AdministratorStatusCode.ADMINISTRATOR_PERMISSION_DENIED) target_admin = AdministratorInfo.objects.get(admin_id=target_admin_id, status=True) if admin_type != -1: target_admin.admin_type = admin_type if phone: target_admin.phone = phone if name: target_admin.name = name AdministratorLoginLogInfo.objects.filter(admin_id=target_admin_id).update(admin_name=name) if password: encryption = make_password(strip(password), settings.MAKE_PASSWORD_SALT, settings.MAKE_PASSWORD_HASHER) target_admin.encryption = encryption target_admin.save() return response(200, 'Update Admin Success', u'更新后台管理员成功') @check_admin def administrator_delete(request, administrator): target_admin_id = request.POST.get('target_admin_id', '') if administrator.admin_type != AdministratorInfo.ADMINISTRATOR: return response(AdministratorStatusCode.ADMINISTRATOR_PERMISSION_DENIED) AdministratorInfo.objects.filter(admin_id=target_admin_id).update(status=False) return response(200, 'Delete Admin Success', u'删除后台管理员成功') @check_admin def administrator_login_list(request, administrator): page = request.POST.get('page', 1) num = request.POST.get('num', 20) target_admin_id = request.POST.get('target_admin_id', '') if administrator.admin_type != AdministratorInfo.ADMINISTRATOR: return response(AdministratorStatusCode.ADMINISTRATOR_PERMISSION_DENIED) logs = AdministratorLoginLogInfo.objects.filter(status=True).order_by('-login_at') if target_admin_id: logs = logs.filter(admin_id=target_admin_id) count = logs.count() logs, left = pagination(logs, page, num) logs = [log.admindata for log in logs] return response(200, 'Get Administrator Login List Success', u'获取后台管理员登录日志成功', data={ 'logs': logs, 'left': left, 'count': count }) pai2 - Gogs: Go Git Service

拍爱

tests.py 61B

    from django.test import TestCase # Create your tests here.