import json
import time
from django.core.paginator import Paginator
from .models import Notice, BuyList
from django.http import JsonResponse
from django.shortcuts import render
# from tools.loggin_check import logging_check
# Create your views here.
from django.views import View
from tools.baseview import BaseView
# from . tasks import send_notice
class EachNoticeView(BaseView):
def get(self, request, id):
try:
apply = Notice.objects.get(id=id)
except Exception as e:
return JsonResponse({"code": 10105, 'error': "no message!"})
apply_dict = {}
apply_dict["id"] = apply.id
# apply_dict["name"] = apply.name
apply_dict["part"] = apply.part
apply_dict["username"] = apply.username
apply_dict["userid"] = apply.userid
# apply_dict["price"] = apply.price
apply_dict["title"] = apply.title
apply_dict["notice"] = apply.notice
# apply_dict["states"] = apply.states
createtime=apply.create_time.strftime("%Y-%m-%d %H:%M")
apply_dict['create_time'] = createtime
print("---->", apply_dict)
return JsonResponse({"code": 200, "apply": apply_dict})
def put(self, request, id):
json_obj = json.loads(request.body)
print(json_obj.get('username'))
try:
notice = Notice.objects.get(id=json_obj['id'])
except Exception as e:
return JsonResponse({"code": 10102, 'error': "change id error!"})
try:
notice.username = json_obj['username']
notice.part = json_obj['part']
notice.title = json_obj['title']
notice.userid = json_obj['userid']
notice.notice = json_obj['notice']
notice.save()
except Exception as e:
return JsonResponse({"code": 10200, 'error': "change error!"})
# show_notice=send_notice(notice)
# data = {"notice": notice, "username": username, "create_time": notice.create_time}
return JsonResponse({'code': 200, })
def delete(self, request, id):
user = request.myuser
if user.department.dname != "行政部":
return JsonResponse({"code": 10101, 'error': "非本部门无法删除"})
try:
notice = Notice.objects.get(id=id, is_active=True)
except Exception as e:
return JsonResponse({"code": 10102, 'error': "no message!"})
notice.is_active = False
notice.save()
return JsonResponse({'code': 200, })
class NoticeView(BaseView):
def post(self, request):
user = request.myuser
if user.department.dname != "行政部":
return JsonResponse({"code": 10101, 'error': "非本部门无法发布"})
json_obj = json.loads(request.body)
print(json_obj.get('username'))
try:
username = json_obj['username']
part = json_obj['part']
title = json_obj['title']
userid = user.eid
print(userid)
notice = json_obj['notice']
except Exception as e:
print("%%%%%%%%%%%%%%%%%",e)
return JsonResponse({"code": 10101, 'error': "no message!"})
try:
notice = Notice.objects.create(username=username, part=part,
title=title, userid=userid,
notice=notice)
except Exception as e:
print("%%%%%%%%%%%%%%%%%",e)
return JsonResponse({"code": 10102, 'error': "create notice error!"})
return JsonResponse({'code': 200, })
def get(self, request):
try:
all_notice = Notice.objects.filter(is_active=True)
print(all_notice)
except Exception as e:
return JsonResponse({"code": 10101, 'error': "no message!"})
print(all_notice)
reslut = []
for each in all_notice:
each_notice = {}
each_notice["id"] = each.id
each_notice["title"] = each.title
each_notice["username"] = each.username
each_notice["create_time"] = each.create_time
each_notice["part"] = each.part
reslut.append(each_notice)
paginator = Paginator(reslut, 3)
num_current_page = 1
page = paginator.page(num_current_page)
page_info = {
'num_pages': paginator.num_pages,
'num_current_page': page.number,
}
return JsonResponse({"code": 200, "notice_list": page.object_list, 'page': page_info})
class BuyListView(View):
def post(self, request, id):
try:
apply = BuyList.objects.get(id=id)
apply.states = True
apply.save()
except Exception as e:
return JsonResponse({"code": 10105, 'error': "审批失败"})
return JsonResponse({'code': 200, 'data': "审批成功"})
def get(self, request, id):
try:
apply = BuyList.objects.get(id=id)
except Exception as e:
return JsonResponse({"code": 10105, 'error': "no message!"})
apply_dict = {}
apply_dict["id"] = apply.id
apply_dict["name"] = apply.name
apply_dict["part"] = apply.part
apply_dict["username"] = apply.username
apply_dict["userid"] = apply.userid
apply_dict["price"] = apply.price
apply_dict["count"] = apply.count
apply_dict["notice"] = apply.notice
# apply_dict["states"] = apply.states
createtime=apply.create_time.strftime("%Y-%m-%d %H:%M")
apply_dict['create_time'] = createtime
print("---->", apply_dict)
return JsonResponse({"code": 200, "apply": apply_dict})
def put(self, request, id):
json_obj = json.loads(request.body)
print(json_obj.get('username'))
try:
apply = BuyList.objects.get(id=json_obj['id'])
except Exception as e:
return JsonResponse({"code": 10102, 'error': "change id error!"})
try:
apply.name = json_obj['goods']
apply.username = json_obj['username']
apply.part = json_obj['part']
apply.count = json_obj['count']
apply.price = json_obj['price']
apply.userid = json_obj['userid']
apply.notice = json_obj['h_bz']
apply.save()
except Exception as e:
return JsonResponse({"code": 10200, 'error': "change error!"})
# show_notice=send_notice(notice)
# data = {"notice": notice, "username": username, "create_time": notice.create_time}
return JsonResponse({'code': 200, })
def delete(self, request, id):
try:
apply = BuyList.objects.get(id=id, is_active=True)
except Exception as e:
return JsonResponse({"code": 10102, 'error': "no message!"})
if apply.states == '1' and apply.userid.department.dname != "行政部":
return JsonResponse({"code": 10203, 'error': "已审批,请联系行政部人员删除申请!"})
apply.is_active = False
apply.save()
return JsonResponse({'code': 200, 'data': "删除成功"})
class AllApplyView(BaseView):
def get(self, request, ):
user = request.myuser
if user.department.dname == "行政部":
print("111111111111111")
try:
all_apply = BuyList.objects.filter(is_active=True)
except Exception as e:
return JsonResponse({"code": 10101, 'error': "没有公告!"})
print(all_apply)
else:
try:
all_apply = BuyList.objects.filter(userid=user.userid, is_active=True)
except Exception as e:
return JsonResponse({"code": 10101, 'error': "无公告!"})
print(all_apply)
reslut = []
for each in all_apply:
each_apply = {}
eac
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
大作业基于django开发的线上云办公系统源码大作业基于django开发的线上云办公系统源码大作业基于django开发的线上云办公系统源码大作业基于django开发的线上云办公系统源码大作业基于django开发的线上云办公系统源码大作业基于django开发的线上云办公系统源码大作业基于django开发的线上云办公系统源码大作业基于django开发的线上云办公系统源码大作业基于django开发的线上云办公系统源码大作业基于django开发的线上云办公系统源码大作业基于django开发的线上云办公系统源码大作业基于django开发的线上云办公系统源码大作业基于django开发的线上云办公系统源码大作业基于django开发的线上云办公系统源码大作业基于django开发的线上云办公系统源码大作业基于django开发的线上云办公系统源码大作业基于django开发的线上云办公系统源码
资源推荐
资源详情
资源评论
收起资源包目录
python大作业基于django开发的线上云办公系统源码.zip (301个子文件)
pintuer.css 111KB
admin.css 4KB
index.css 2KB
navigationbar.css 2KB
recruit.css 2KB
human_resources.css 2KB
.gitignore 38B
xichioa.iml 402B
bg.jpg 137KB
公司组织架构.jpg 14KB
jquery-1.11.3.js 278KB
jquery-3.3.1.js 265KB
jquery.js 94KB
jquery-3.1.1.min.js 85KB
pintuer.js 16KB
recruit.js 605B
human_resources.js 525B
log.json 28KB
db.json 12KB
courier.json 3KB
empinfo2.json 3KB
empinfo.json 2KB
paper-clip.png 19KB
views.py 10KB
views.py 10KB
views.py 8KB
views.py 6KB
settings.py 5KB
views.py 5KB
views.py 4KB
views.py 4KB
0001_initial.py 4KB
views.py 3KB
views.py 3KB
views.py 3KB
0001_initial.py 3KB
0001_initial.py 3KB
models.py 2KB
0002_auto_20210816_0830.py 2KB
0001_initial.py 2KB
models.py 2KB
models.py 2KB
models.py 2KB
urls.py 2KB
0001_initial.py 1KB
0001_initial.py 1KB
0001_initial.py 1KB
0006_auto_20210817_0829.py 1KB
0001_initial.py 1KB
admin.py 1KB
models.py 1KB
models.py 1KB
0002_auto_20210817_0829.py 1KB
0001_initial.py 1KB
0001_initial.py 1018B
models.py 1000B
loggin_check.py 955B
baseview.py 931B
0004_auto_20210820_0920.py 809B
views.py 663B
manage.py 627B
0007_auto_20210814_0930.py 612B
email_task.py 610B
models.py 603B
0002_auto_20210821_1146.py 595B
0002_auto_20210821_1146.py 595B
models.py 560B
0005_auto_20210821_1113.py 553B
models.py 513B
0004_auto_20210812_1531.py 509B
urls.py 484B
0006_auto_20210812_2057.py 476B
0008_auto_20210814_0940.py 470B
0002_auto_20210817_1150.py 468B
urls.py 448B
urls.py 448B
0002_auto_20210811_1957.py 446B
urls.py 430B
0002_clients_gname.py 414B
0005_auto_20210812_1754.py 412B
0004_reimburseprofiles_is_active.py 403B
0007_auto_20210817_0910.py 399B
0003_auto_20210812_1710.py 395B
wsgi.py 391B
0003_auto_20210817_1155.py 389B
urls.py 369B
0004_auto_20210812_1716.py 361B
0003_auto_20210820_0918.py 348B
0003_auto_20210811_2004.py 343B
0005_remove_empprofile_salary.py 334B
celery.py 333B
0002_remove_resigninfo_resign_type.py 327B
urls.py 303B
urls.py 286B
urls.py 272B
urls.py 246B
urls.py 184B
pwd_SHA256.py 166B
tasks.py 111B
apps.py 103B
共 301 条
- 1
- 2
- 3
- 4
资源评论
- m0_588248152023-07-01怎么能有这么好的资源!只能用感激涕零来形容TAT...
- luogangPH2022-09-22这个资源对我启发很大,受益匪浅,学到了很多,谢谢分享~
- Casillaq2023-05-11内容与描述一致,超赞的资源,值得借鉴的内容很多,支持!
程序员张小妍
- 粉丝: 1w+
- 资源: 2577
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功