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