new code
This commit is contained in:
@@ -103,6 +103,13 @@ DATABASES = {
|
||||
}
|
||||
}
|
||||
|
||||
# DATABASES = {
|
||||
# 'default': {
|
||||
# 'ENGINE': 'django.db.backends.sqlite3',
|
||||
# 'NAME': BASE_DIR / 'db.sqlite3',
|
||||
# }
|
||||
# }
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from django.db import models
|
||||
from server_auth.models import MindUser
|
||||
|
||||
import json
|
||||
class AbstractModel(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
create_time = models.DateTimeField(verbose_name='创建时间', auto_now_add=True)
|
||||
@@ -23,6 +24,7 @@ class CooperationMind(AbstractModel):
|
||||
data_format = models.CharField(verbose_name='数据格式化类型', max_length=32, null=False, blank=False)
|
||||
deleted = models.BooleanField(verbose_name='是否标记为软删除', default=False)
|
||||
class_id = models.IntegerField(verbose_name='脑图所属课程id', null=False, blank=False, default=1)
|
||||
belong_to = models.TextField(verbose_name='所属课程-小组', default=json.dumps({'belong': []}))
|
||||
|
||||
class Meta:
|
||||
db_table = 'cooperation_mind'
|
||||
|
||||
+14
-1
@@ -1,5 +1,9 @@
|
||||
import json
|
||||
|
||||
from django.shortcuts import render
|
||||
from server.models import Task,StudentandTercher
|
||||
from server_auth.models import MindUser
|
||||
|
||||
|
||||
def to_dashboard(request):
|
||||
"""
|
||||
@@ -48,8 +52,17 @@ def to_kecheng(request):
|
||||
"""
|
||||
课程列表
|
||||
"""
|
||||
user = request.user
|
||||
kechengs = StudentandTercher.objects.all() # 查询所有的任务
|
||||
return render(request, "html/kecheng.html", {'kechengs': kechengs})
|
||||
xiaozu = MindUser.objects.get(username=user).select_xiaozu
|
||||
kz = MindUser.objects.get(username=user).select_class
|
||||
xiaozu = json.loads(xiaozu)['xiaozu']
|
||||
kc = json.loads(kz)['class']
|
||||
test = zip(kc,xiaozu)
|
||||
it3 = []
|
||||
for it1,it2 in test:
|
||||
it3.append(str(it1) + "课程" + str(it2) + "小组")
|
||||
return render(request, "html/kecheng.html", {'kechengs': kechengs,"select":it3})
|
||||
|
||||
def to_write(request):
|
||||
"""
|
||||
|
||||
+67
-18
@@ -30,6 +30,9 @@ class JsMindView(LoginRequiredJSONMixin, ListAPIView):
|
||||
查询思维导图
|
||||
"""
|
||||
pk = request.GET.get('id')
|
||||
print("-----------------------------")
|
||||
print(pk)
|
||||
print("-----------------------------")
|
||||
# 页面源
|
||||
page_tag = request.GET.get('s_p')
|
||||
user = request.user
|
||||
@@ -39,29 +42,69 @@ class JsMindView(LoginRequiredJSONMixin, ListAPIView):
|
||||
select_id = json.loads(user.select_xiaozu)['xiaozu']
|
||||
print(select_id[0])
|
||||
print('list current user: %s' % user)
|
||||
if pk is not None:
|
||||
# 查询导图详细 查看用户是否有权限
|
||||
sql = """
|
||||
select * from cooperation_mind mind where id=%s and mind.class_id =%s
|
||||
|
||||
""" % (pk, select_id[0])
|
||||
# if pk is not None:
|
||||
# # 查询导图详细 查看用户是否有权限
|
||||
# sql = """
|
||||
# select * from cooperation_mind mind where id=%s and mind.class_id=%s
|
||||
# union all select m1.* from cooperation_mind m1 join cooperation_mind_share sh on sh.coop_mind_id = m1.id where m1.id=%s and sh.operator_user_id =%s
|
||||
# union all select m1.* from cooperation_mind m1 join cooperation_mind_star st on st.coop_mind_id = m1.id where m1.id=%s and st.operator_user_id =%s
|
||||
# """ % (pk, select_id, pk, select_id, pk, select_id)
|
||||
mind = CooperationMind.objects.raw(sql)
|
||||
if len(mind) is None:
|
||||
return build_response(code=CODE_FAILED, msg="无权限")
|
||||
# 序列化
|
||||
serializer = CooperationMindSerializer(mind[0])
|
||||
return build_response(data=serializer.data)
|
||||
# select * from cooperation_mind mind where id=%s and mind.class_id =%s
|
||||
#
|
||||
# """ % (pk, select_id[0])
|
||||
# # sql = """
|
||||
# # select * from cooperation_mind mind where id=%s and mind.class_id=%s
|
||||
# # union all select m1.* from cooperation_mind m1 join cooperation_mind_share sh on sh.coop_mind_id = m1.id where m1.id=%s and sh.operator_user_id =%s
|
||||
# # union all select m1.* from cooperation_mind m1 join cooperation_mind_star st on st.coop_mind_id = m1.id where m1.id=%s and st.operator_user_id =%s
|
||||
# # """ % (pk, select_id, pk, select_id, pk, select_id)
|
||||
# mind = CooperationMind.objects.raw(sql)
|
||||
# if len(mind) is None:
|
||||
# return build_response(code=CODE_FAILED, msg="无权限")
|
||||
# # 序列化
|
||||
# serializer = CooperationMindSerializer(mind[0])
|
||||
# print("--------------------------")
|
||||
# print("--------------------------")
|
||||
# print("--------------------------")
|
||||
# print("--------------------------")
|
||||
# print(serializer)
|
||||
# print("--------------------------")
|
||||
# print("--------------------------")
|
||||
# print("--------------------------")
|
||||
# print("--------------------------")
|
||||
# return build_response(data=serializer.data)
|
||||
|
||||
# 查询列表
|
||||
if 'b9b101e' == page_tag:
|
||||
# belong_to = []
|
||||
old_class = json.loads(user.select_class)['class']
|
||||
old_xiaozu = json.loads(user.select_xiaozu)['xiaozu']
|
||||
# for select_class,select_xiaozu in (old_class,old_xiaozu):
|
||||
# belong_to = ["class1","class2"]
|
||||
# ["class1"]
|
||||
# new_belong = json.dumps({'belong': belong_to})
|
||||
# 我的文件
|
||||
self.queryset = CooperationMind.objects.filter(class_id=select_id[0], deleted=0).values('id', 'coop_mind_name', "client_uuid", "data_format")
|
||||
aa = []
|
||||
zipped_lists = zip(old_class, old_xiaozu)
|
||||
for select_class,select_xiaozu in zipped_lists:
|
||||
belong_to = []
|
||||
belong_to.append(str(select_class + str(select_xiaozu)))
|
||||
new_belong = json.dumps({'belong': belong_to})
|
||||
print(new_belong)
|
||||
aa.append(CooperationMind.objects.filter(belong_to=new_belong, deleted=0).values('id', 'coop_mind_name',
|
||||
"client_uuid",
|
||||
"data_format"))
|
||||
# queryset.save()
|
||||
|
||||
# for i in range(len(aa) - 1):
|
||||
# if i == 0:
|
||||
# bb = str(aa[i])
|
||||
# bb = bb + "|" + str(aa[i + 1])
|
||||
if len(aa) -1 == 0:
|
||||
self.queryset = aa[0]
|
||||
else:
|
||||
for i in range(len(aa) -1):
|
||||
if i == 0:
|
||||
self.queryset = aa[i]
|
||||
self.queryset = self.queryset | aa[i + 1]
|
||||
print("=============================")
|
||||
print(self.queryset)
|
||||
print("=============================")
|
||||
elif 'share' == page_tag:
|
||||
# 我的分享
|
||||
share = CooperationMindShare.objects.filter(coop_mind_id=OuterRef('id'), operator_user_id=user.id)
|
||||
@@ -102,12 +145,18 @@ class JsMindView(LoginRequiredJSONMixin, ListAPIView):
|
||||
data_format = 'node_tree'
|
||||
test_id = 0
|
||||
for item1, item2 in zipped_lists:
|
||||
if (CooperationMind.objects.filter(coop_mind_name=str(item1 + "第" + str(item2) + "小组")).exists()):
|
||||
print("==========================================================")
|
||||
continue
|
||||
print("--------------------------------------------------")
|
||||
print(item1, item2)
|
||||
test = []
|
||||
test.append(item1+str(item2))
|
||||
# new_belong = json.dumps({'belong': belong_to})
|
||||
mind = CooperationMind(coop_mind_name=str(item1 + "第" + str(item2) + "小组"), client_uuid='',
|
||||
mind_log_id=-1,
|
||||
creator_user_id=user.id, snapshot_data=SNAPSHOT_JSON_DATA,
|
||||
data_format=data_format)
|
||||
data_format=data_format,belong_to=json.dumps({'belong':test}))
|
||||
mind.save()
|
||||
test_id = mind.id
|
||||
return build_response(data=test_id)
|
||||
|
||||
@@ -18,6 +18,7 @@ class MindUser(AbstractUser):
|
||||
select_class = models.TextField(verbose_name='选择的课程', default=json.dumps({'class': []}))
|
||||
select_xiaozu = models.TextField(verbose_name='选择的小组', default=json.dumps({'xiaozu': []}))
|
||||
is_zuzhang = models.CharField(verbose_name='是否是组长', max_length=64, null=True, blank=True)
|
||||
# display_naotu = models.ForeignKey(verbose_name="可查看脑图列表")
|
||||
|
||||
class Meta:
|
||||
db_table = 'mind_user'
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
a = []
|
||||
a.append("123")
|
||||
a.append("456")
|
||||
print(a)
|
||||
aa = [1,2,3,4,5,6,7,8]
|
||||
bb = ""
|
||||
for i in range(len(aa) - 1):
|
||||
if i == 0:
|
||||
bb = str(aa[i])
|
||||
bb = bb + "|" + str(aa[i + 1])
|
||||
|
||||
print(bb)
|
||||
|
||||
|
||||
@@ -634,7 +634,7 @@
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">
|
||||
<a class="nav-link" href="/2_recycle">
|
||||
<span data-feather="trash-2"></span>
|
||||
回收站
|
||||
</a>
|
||||
|
||||
@@ -646,6 +646,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
{% endfor %}
|
||||
{{ select }}
|
||||
</main>
|
||||
<!-- 右侧内容 start-->
|
||||
|
||||
|
||||
Reference in New Issue
Block a user