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]']
程序猿阿存
- 粉丝: 1244
- 资源: 1805
最新资源
- C#基于EF架构生产管理糸统源码
- PMSM电机负载观测转矩前馈simulink 基于Luenberger降阶状态观测器,包含PMSM数学模型,PMSM双闭环PI矢量控制,并添加了前馈控制,采用SVPWM调制
- C#上位机,台达DVP系列modbus485通信例子 例子简单易看懂 自己写的程序
- Linux命令大全.docx
- 三菱FX3U与3台欧姆龙E5CC温控器 通讯控制程序功能:通过昆仑通态触摸屏,三菱FX3U 485BD板,实现对3台欧姆龙E5CC温控器 设定温度值,读取实际温度,设定探头类型,设定报警值,设定报警类
- 历史古典古籍资讯类PbootCMS模板(支持手机端和宽屏).zip
- 常用开发语言的正则表达式提取邮箱实例代码.docx
- python3.12.2版本
- Windows App Beta for Mac v11.0.9
- 基于网络的Modbus TCP通讯控制,通过网线连接以太网,本电路板可以控制四路继电器,一路温度,一路湿度,一路烟雾浓度,温湿度测量基于sht30 通过Modbus TCP上传的上位机或手机app
- Alfred 5 for Mac v5.5.1
- 医疗小程序音视频问诊门诊医院药房系统开发源码
- 程序设计代码 (1).zip
- iDownerGo for Mac v9.2.5
- S7-1200控制5轴伺服程序案例 1.PTO伺服轴脉冲定位控制功能应用+速度模式应用+扭矩模式应用 2.程序为结构化编程,每一功能为模块化设计,具有一个项目都有的功能:自动-手动-单步-暂停
- 内点法最优潮流程序matlab 采用内点法对14标准节点系统进行最优潮流计算,程序运行稳定,注释清楚,通用性强
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈