new code
This commit is contained in:
+23
-11
@@ -104,22 +104,34 @@ class StudentandTercher(AbstractModel):
|
|||||||
class_info = models.CharField(verbose_name='课程信息', max_length=128, null=False, blank=False)
|
class_info = models.CharField(verbose_name='课程信息', max_length=128, null=False, blank=False)
|
||||||
class_status = models.CharField(verbose_name='课程状态', max_length=128, null=False, blank=False)
|
class_status = models.CharField(verbose_name='课程状态', max_length=128, null=False, blank=False)
|
||||||
|
|
||||||
# 1,定义用户模型类
|
class Task(models.Model):
|
||||||
|
title = models.CharField(max_length=200)
|
||||||
|
description = models.TextField()
|
||||||
|
deadline = models.CharField(max_length=200)
|
||||||
|
createline = models.CharField(max_length=200) # 开始时间
|
||||||
|
publisher = models.CharField(max_length=200)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.title
|
||||||
|
|
||||||
class User_Teacher(AbstractModel):
|
class User_Teacher(AbstractModel):
|
||||||
|
"""
|
||||||
|
<td>kecheng.id</td>
|
||||||
|
<td>kecheng.education</td>
|
||||||
|
<td>kecheng.name</td>
|
||||||
|
<td>kecheng.create</td>
|
||||||
|
<td>kecheng.depart</td>
|
||||||
|
<td>kecheng.status</td>
|
||||||
|
"""
|
||||||
|
|
||||||
#1, 增加额外的属性
|
#1, 增加额外的属性
|
||||||
number = models.SmallIntegerField(verbose_name="教师编号",null=True, blank=True,)
|
kecheng_id = models.SmallIntegerField(verbose_name="课程id",null=True, blank=True)
|
||||||
name = models.CharField(verbose_name="教师姓名",max_length=32,null=True, blank=True,)
|
name = models.CharField(verbose_name="教师姓名",max_length=32,null=True, blank=True,)
|
||||||
sex_choices = (
|
|
||||||
(1, "男"),
|
|
||||||
(2, "女"),
|
|
||||||
)
|
|
||||||
sex = models.SmallIntegerField(verbose_name="性别", choices=sex_choices,null=True, blank=True)
|
|
||||||
|
|
||||||
education = models.CharField(verbose_name="课程名称",max_length=128,null=True, blank=True)
|
education = models.CharField(verbose_name="课程名称",max_length=128,null=True, blank=True)
|
||||||
|
create = models.CharField(verbose_name="课程创建时间",max_length=128,null=True, blank=True)
|
||||||
depart = models.CharField(verbose_name="课程信息",max_length=64,default="暂未设定")
|
depart = models.CharField(verbose_name="课程信息",max_length=64,default="暂未设定")
|
||||||
mobile = models.CharField(verbose_name="手机号",max_length=11,unique=True)
|
kecheng_status = models.CharField(verbose_name="课程状态", max_length=128, null=True, blank=True)
|
||||||
# department = models.ForeignKey(verbose_name="部门名称", to="Department", to_field="id", null=True, blank=True, on_delete=models.SET_NULL)
|
|
||||||
#2, 指定表名信息
|
#2, 指定表名信息
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = "tb_users"
|
db_table = "tb_users"
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
from django import forms
|
||||||
|
from .models import Task
|
||||||
|
|
||||||
|
|
||||||
|
class TaskForm(forms.ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = Task
|
||||||
|
fields = ['title', 'description', 'deadline', 'publisher']
|
||||||
@@ -48,4 +48,7 @@ urlpatterns = [
|
|||||||
|
|
||||||
path('tercher_upload_somthings',TeacherView.as_view()), # 老师端上传一些文件
|
path('tercher_upload_somthings',TeacherView.as_view()), # 老师端上传一些文件
|
||||||
|
|
||||||
|
# ---------------------------------------------------
|
||||||
|
path('post_task/', post_task, name='post_task'),
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
from server.models import Task,StudentandTercher
|
||||||
|
|
||||||
def to_dashboard(request):
|
def to_dashboard(request):
|
||||||
"""
|
"""
|
||||||
@@ -38,18 +39,17 @@ def to_chat_room(request):
|
|||||||
return render(request, "html/wechat_2.html", param)
|
return render(request, "html/wechat_2.html", param)
|
||||||
def to_rengwu(request):
|
def to_rengwu(request):
|
||||||
"""
|
"""
|
||||||
聊天室页面
|
任务列表
|
||||||
"""
|
"""
|
||||||
param = {"page": "chat_room"}
|
tasks = Task.objects.all() # 查询所有的任务
|
||||||
return render(request, "html/rengwu.html", param)
|
return render(request, "html/rengwu.html", {'tasks': tasks})
|
||||||
|
|
||||||
def to_kecheng(request):
|
def to_kecheng(request):
|
||||||
"""
|
"""
|
||||||
聊天室页面
|
课程列表
|
||||||
"""
|
"""
|
||||||
|
kechengs = StudentandTercher.objects.all() # 查询所有的任务
|
||||||
param = {"page": "chat_room"}
|
return render(request, "html/kecheng.html", {'kechengs': kechengs})
|
||||||
return render(request, "html/kecheng.html", param)
|
|
||||||
|
|
||||||
def to_write(request):
|
def to_write(request):
|
||||||
"""
|
"""
|
||||||
|
|||||||
+17
-1
@@ -10,6 +10,7 @@ from server.util.constant_util import *
|
|||||||
from server.util.mix_util import build_response
|
from server.util.mix_util import build_response
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
|
||||||
|
from server.taskform import TaskForm
|
||||||
|
|
||||||
class AuthBackend(ModelBackend):
|
class AuthBackend(ModelBackend):
|
||||||
"""
|
"""
|
||||||
@@ -121,4 +122,19 @@ class TeacherView(LoginRequiredJSONMixin,APIView):
|
|||||||
return build_response(code=CODE_FAILED, msg="用户未登录或对当前页无权限")
|
return build_response(code=CODE_FAILED, msg="用户未登录或对当前页无权限")
|
||||||
else:
|
else:
|
||||||
print("用户已登录")
|
print("用户已登录")
|
||||||
return render(request, "html/jiaoshi1.html")
|
return render(request, "html/jiaoshi1.html")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def post_task(request):
|
||||||
|
if request.method == 'POST':
|
||||||
|
form = TaskForm(request.POST)
|
||||||
|
if form.is_valid():
|
||||||
|
task = form.save(commit=False)
|
||||||
|
task.publisher = request.user
|
||||||
|
task.save()
|
||||||
|
return http.JsonResponse({'code': CODE_SUCCESS, 'msg': '发布成功'})
|
||||||
|
else:
|
||||||
|
form = TaskForm()
|
||||||
|
return render(request, 'html/post_task.html', {'form': form})
|
||||||
|
|
||||||
|
|||||||
@@ -610,7 +610,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="#">
|
<a class="nav-link" href="/reng_wu">
|
||||||
<span data-feather="star"></span>
|
<span data-feather="star"></span>
|
||||||
任务详情
|
任务详情
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
+24
-22
@@ -588,29 +588,31 @@
|
|||||||
</nav>
|
</nav>
|
||||||
<!-- 左侧菜单 end-->
|
<!-- 左侧菜单 end-->
|
||||||
<main class="col-md-10 ml-sm-auto col-lg-10 px-md-4">
|
<main class="col-md-10 ml-sm-auto col-lg-10 px-md-4">
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>课程id</th>
|
<th>课程id</th>
|
||||||
<th>课程名字</th>
|
<th>课程名字</th>
|
||||||
<th>老师</th>
|
<th>老师</th>
|
||||||
<th>添加时间</th>
|
<th>添加时间</th>
|
||||||
<th>课程介绍</th>
|
<th>课程介绍</th>
|
||||||
<th>课程状态</th>
|
<th>课程状态</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
{% for kecheng in kechengs %}
|
||||||
<tr>
|
<tbody>
|
||||||
<td>ADG3232</td>
|
<tr>
|
||||||
<td>计算机操作系统</td>
|
<td>{{kecheng.class_id}}</td>
|
||||||
<td>小安</td>
|
<td>{{kecheng.class_name}}</td>
|
||||||
<td>2024-02-25 21:13:29</td>
|
<td>{{kecheng.tercher_name}}</td>
|
||||||
<td>这是一门关于计算机操作系统的课程</td>
|
<td>{{kecheng.add_time}}</td>
|
||||||
<td>上课</td>
|
<td>{{kecheng.class_info}}</td>
|
||||||
</tr>
|
<td>{{kecheng.class_status}}</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
{% endfor %}
|
||||||
</main>
|
</main>
|
||||||
<!-- 右侧内容 start-->
|
<!-- 右侧内容 start-->
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Title</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{% if form.errors %}
|
||||||
|
<p>请修正表中的错误.</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<form method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{ form.as_p }}
|
||||||
|
<button type="submit">发布任务</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<h2>任务列表</h2>
|
||||||
|
<ul>
|
||||||
|
{% for task in tasks %}
|
||||||
|
<li>{{ task.title }} - {{ task.deadline }}</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user