from django.shortcuts import render,redirect,HttpResponse
from app import models
import json,datetime,hashlib,uuid
# Create your views here.
from utils import call
from utils import query
from utils import user_page
from django.db import connection
import os
from django.db.models import Q
# '''初始化照片存放目录'''
query.creat_path()
def now_time():
n_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
return n_time
def uid():
uid = str (uuid.uuid1())
suid = ''.join (uid.split ('-'))
return suid
def login(request):
'''动态窗口'''
if request.method == 'POST':
dlfs = request.POST.get('key',None)
if dlfs == 'login':
data = call.dlfs_login(request)
return HttpResponse(json.dumps(data))
else:
return redirect ('/login.html')
session_key=request.session.session_key
request.session.delete(session_key)
date = call.login_select()
return render(request,'system/login.html',date)
def index(request):
if call.is_login (request):
user_id = request.session['user_id']
data = query.index_data(user_id)
count = user_page.dic_msg_num(user_id)
data['count'] = count
return render (request, 'system/index.html',data)
else:
return redirect ('/login.html')
def home(request):
if call.is_login(request):
return render(request,'system/home.html')
else:
return redirect ('/login.html')
def design(request):
'''登陆窗口页面'''
if call.is_login(request):
re_url = request.path_info
user_id = request.session['user_id']
if call.is_see_grant(request, re_url):
date = call.design_login(re_url,user_id)
return render(request, 'system/design.html', date)
else:
return render(request, 'system/403.html')
else:
return redirect ('/login.html')
def design_submit(request):
'''登陆窗口设置'''
if call.is_login(request):
re_url = request.POST.get('type', None)
re_date = request.POST
if call.is_see_grant(request, re_url):
if request.method == 'POST':
result = call.login_setting(request,re_date)
return HttpResponse(json.dumps(result))
else:
return HttpResponse(json.dumps(None))
else:
return HttpResponse(json.dumps(False))
else:
return redirect ('/login.html')
def theme(request):
'''桌面壁纸'''
if call.is_login(request):
re_url = request.path_info
if call.is_grant(request, re_url):
str_data = query.creat_theme(request,re_url)
menu_str = query.menu_theme(request, re_url)
return render(request,'system/theme.html',{'url_data': re_url,'data':str_data,'menu_str':menu_str})
else:
return render(request,'system/403.html')
else:
return redirect ('/login.html')
def theme_use(request):
'''桌面壁纸生效'''
if call.is_login(request) and request.method == 'POST':
re_url = request.POST.get('type', None)
if call.is_edit_grant(request, re_url):
theme_id = request.POST
models.SysTheme.objects.filter(id=theme_id['base']).update(state=1)
models.SysTheme.objects.exclude(id=theme_id['base']).update(state=0)
call.create_log(request, 'update', '修改了', '桌面壁纸')
return HttpResponse(json.dumps(True))
else:
return HttpResponse(json.dumps(False))
else:
return redirect ('/login.html')
def theme_detail(request):
'''桌面背景预览'''
if call.is_login(request):
re_url = request.GET.get('type', None)
user_id = request.session['user_id']
if call.is_see_grant(request, re_url):
date = call.theme_setting(request,re_url, user_id)
return render(request, 'system/theme_detail.html',date)
else:
return render(request, 'system/403.html')
else:
return redirect ('/login.html')
def theme_upload(request):
'''桌面壁纸上传接口'''
if call.is_login(request):
re_url = request.POST.get('type', None)
if call.is_edit_grant(request, re_url):
if call.upload_theme(request):
return HttpResponse(json.dumps(True))
else:
return HttpResponse(json.dumps(False))
else:
return HttpResponse(json.dumps(False))
else:
return redirect ('/login.html')
def theme_delete(request):
'''删除背景图片'''
if call.is_login(request) and request.method == 'POST':
re_url = request.POST.get('type', None)
if call.is_delete_grant(request, re_url):
theme_id = request.POST
image_path = models.SysTheme.objects.filter(id=theme_id['base'])
for path in image_path.values('full_path'):
if os.path.exists(path['full_path']):
os.remove(path['full_path'])
models.SysTheme.objects.filter(id=theme_id['base']).delete()
call.create_log(request, 'delete', '删除了', '一张桌面壁纸')
return HttpResponse(json.dumps(True))
else:
return HttpResponse(json.dumps(False))
else:
return redirect ('/login.html')
def information(request):
'''个人资料页面'''
if call.is_login(request):
return render(request,'system/information.html')
else:
return redirect ('/login.html')
def information_data(request):
if call.is_login(request):
base = []
user_id = request.session['user_id']
info_data=user_page.dic_msg(user_id)
for info in info_data.values('id','content','user_id','state','type'):
if info['state'] == 1:
info['state'] = '已读'
else:
info['state'] = '未读'
base.append(info)
data = {'code': 0, 'page_num': 1, 'bg_hs': 10, 'count': 0, 'data':base}
return HttpResponse(json.dumps(data))
else:
return redirect ('/login.html')
def information_del(request):
if call.is_login(request):
data = request.POST
try:
models.SysInformation.objects.filter(id=data['ID']).delete()
return HttpResponse(json.dumps(True))
except:
return HttpResponse(json.dumps(False))
else:
return redirect ('/login.html')
def information_update(request):
if call.is_login(request):
up_id = request.POST
if up_id['state'] == '未读':
models.SysInformation.objects.filter(id=up_id['ID']).update(state=1)
return HttpResponse(json.dumps(True))
else:
return HttpResponse(json.dumps(False))
else:
return redirect ('/login.html')
def role(request):
if call.is_login (request):
re_url = request.path_info
if call.is_grant(request,re_url):
sfkbj = call.see_grant(request, re_url)
return render (request, 'system/role.html',{'url_data': re_url,'anzs':sfkbj})
else:
return render(request,'system/403.html')
else:
return redirect ('/login.html')
def role_insert(request):
if call.is_login (request):
if request.method == 'POST':
re_url = request.POST.get('type', None)
if call.is_edit_grant(request, re_url):
temp = request.POST
models.SysRole.objects.create (id=call.uid(),caption = temp['base[name]'],abbreviation = temp['base[level]'],remark = temp['base[remark]'],pxh = temp['base[pxh]'])
call.create_log(request,'create','创建角色',temp['base[name]']
岛上程序猿
- 粉丝: 5818
- 资源: 4248
最新资源
- 飞剪测试程序,仿真模拟,比较实用,适合初学者 使用西门子博图V16版本 用于旋切机包装机切纸机等
- QT+VS写的TCP调试助手
- 车道线检测matlab工程文件,gui界面,图像处理,图像分割,实时视频检测,霍夫变,具体效果可看主页演示视频,程序包运行,欢迎打扰
- Java源码springboot+vue财务管理系统.zip
- 采用s函数编写的永磁同步电机矢量控制双闭环PMSM控制模型,利用matlab simulink搭建,可修改参数,增减负载均能恢复参考值正常运行
- PMSM 高频注入法HFI 无位置传感器 高频脉振注入仿真文件simulink仿真, matlab2018可以运行 另外附送详细公式推导
- 财务管理系统 源码+数据库+论文(JAVA+SpringBoot+Vue.JS+MySQL).zip
- 风光储互补系统直流微电网simulink仿真模型 1.光伏系统通过boost电路升压并入母线,采用扰动观察法实现最大功率跟踪控制; 2.风力系统永磁直驱同步电机通过三相电压型整流器并入母线,采用最佳
- 基于自适应对数映射的局部对比度增强技术研究与实现(图像处理)
- 基于springboot的中小企业财务管理系统源码数据库论文.docx
- Linux操作系统内核模块编程实践-添加与管理内核模块
- 永磁同步电机的MTPA最大转矩电流比控制算法的仿真模型,有详细的算法设计文档 1. 永磁同步电机的数学模型; 2. 永磁同步电机的矢量控制原理; 3. 最大转矩电流比控制; 4. 前馈补偿提高抗负载
- 动态时钟图片资源(包含表盘、时针、分针、秒针)
- TCP 多线程服务端调试助手(支持多客户端)
- MUC操作系统课程设计-块设备驱动程序实现与实验分析
- 基于麻雀搜索算法SSA优化LSTM的隐含层神经元个数,最佳学习率,最佳迭代次数,建立多特征输入,单因变量输出的拟合预测建模 程序内注释详细,直接替数据就可以用,可学习性强 直接运行可以出拟合预测图
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈