Skip to content

Commit

Permalink
Merge pull request #5 from se-curriculum-design-group/master
Browse files Browse the repository at this point in the history
同步源
  • Loading branch information
ruizi authored May 13, 2019
2 parents bae936c + 12d6dc7 commit d069371
Show file tree
Hide file tree
Showing 68 changed files with 26,587 additions and 917 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ __pycache__/
0001_initial.py
0002_auto*.py
*.pyc
EMS/graduationManagement/migrations/__pycache__/__init__.cpython-36.pyc
EMS/EMS/__pycache__/wsgi.cpython-36.pyc
Binary file modified EMS/EMS/__pycache__/wsgi.cpython-36.pyc
Binary file not shown.
1 change: 1 addition & 0 deletions EMS/EMS/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',

'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
Expand Down
Empty file.
542 changes: 464 additions & 78 deletions EMS/courseScheduling/Schedule.py

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions EMS/courseScheduling/Synchronize.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from courseSelection.models import CourseSelected as courseSelected
from courseScheduling.models import Schedule_result, Teacher_Schedule_result
from courseScheduling.Schedule import year as Schedule_year
from courseScheduling.Schedule import semester as Schedule_semester
year = Schedule_year
semester = Schedule_semester
def Sychronize_with_courseSelected():
rows_in_Schedule_result = Schedule_result.objects.filter(tno__mcno__year=year, tno__mcno__semester=semester)
for element in rows_in_Schedule_result:
if len(courseSelected.objects.filter(
cno__where=element.where,
cno__time=element.time,
cno__tno=element.tno,
sno=element.sno,
)) == 0:
Tsr = Teacher_Schedule_result.objects.get(tno=element.tno, where=element.where, time=element.time)
courseSelected.objects.create(sno=element.sno, cno=Tsr, score=0, common_score=0, final_score=0).save()

if __name__ == '__main__':
Sychronize_with_courseSelected()

Binary file not shown.
Binary file not shown.
Binary file not shown.
46 changes: 25 additions & 21 deletions EMS/courseScheduling/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@
from backstage.models import Student, Teacher, ClassRoom


class Schedule_result(models.Model):
"""
凡是被加在这里的数据,一定是有学生,老师,教室,时间地点已定。
第一次自动排完后,只有必修课在这里,选修不在,
选修的同步目前不同步更新
"""
sno = models.ForeignKey(to=Student, on_delete=models.CASCADE)
tno = models.ForeignKey(to=Teaching, on_delete=models.CASCADE)
where = models.ForeignKey(to=ClassRoom, on_delete=models.CASCADE)
time = models.CharField(max_length=128, null=False)
def __str__(self):
return "-".join([self.sno, self.tno, self.where, self.time, ])
class Meta:
db_table = 'Schedule_result'
unique_together = (
'sno', 'tno', 'where', 'time'
)
# class Schedule_result(models.Model):
# """
# 凡是被加在这里的数据,一定是有学生,老师,教室,时间地点已定。
# 第一次自动排完后,只有必修课在这里,选修不在,
# 选修的同步目前不同步更新
# """
# sno = models.ForeignKey(to=Student, on_delete=models.CASCADE)
# tno = models.ForeignKey(to=Teaching, on_delete=models.CASCADE)
# where = models.ForeignKey(to=ClassRoom, on_delete=models.CASCADE)
# time = models.CharField(max_length=128, null=False)
# def __str__(self):
# return "-".join([self.sno, self.tno, self.where, self.time, ])
# class Meta:
# db_table = 'Schedule_result'
# unique_together = (
# 'sno', 'tno', 'where', 'time'
# )


class Teacher_Schedule_result(models.Model):
Expand All @@ -30,7 +30,6 @@ class Teacher_Schedule_result(models.Model):
current_number = models.IntegerField()
MAX_number = models.IntegerField()
state = models.CharField(max_length=128)

def __str__(self):
return "-".join([str(self.tno),str(self.where),str(self.crtype),str(self.contain_num),str(self.time),
str(self.current_number),str(self.MAX_number),str(self.state)])
Expand All @@ -44,17 +43,22 @@ class Classroom_other_schedule (models.Model):
#外键教室
crno = models.ForeignKey(to=ClassRoom, on_delete=models.CASCADE)
#时间定义同上
time = models.CharField(max_length=128, null=False, default='')
time = models.CharField(max_length=128, default='')
statement = models.CharField(max_length=128, default='')
def __str__(self):
return "-".join([self.crno, self.time])
return "-".join([self.crno, self.time, self.statement])
class Meta:
db_table = 'Classroom_other_schedule'

class Exam_Schedule(models.Model):
sno = models.ForeignKey(to=Student, on_delete=models.CASCADE)
tno_mno_course = models.ForeignKey(to=Teacher_Schedule_result, on_delete=models.CASCADE)
time = models.CharField(max_length=128, null=False)
where = models.ForeignKey(to=ClassRoom, on_delete=models.CASCADE)
def __str__(self):
return "-".join([self.tno_mno, self.time, self.where])
return "-".join([self.sno, self.tno_mno, self.time, self.where])
class Meta:
db_table = 'Exam_Schedule'
unique_together = (
'sno', 'tno_mno_course',
)
37 changes: 37 additions & 0 deletions EMS/courseSelection/migrations/0002_auto_20190513_1539.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Generated by Django 2.1.3 on 2019-05-13 07:39

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
('backstage', '__first__'),
('scoreManagement', '0001_initial'),
('courseSelection', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='teacher_schedule_result',
name='tno',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='scoreManagement.Teaching'),
),
migrations.AddField(
model_name='courseselected',
name='cno',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='courseSelection.Teacher_Schedule_result'),
),
migrations.AddField(
model_name='courseselected',
name='sno',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='backstage.Student'),
),
migrations.AlterUniqueTogether(
name='teacher_schedule_result',
unique_together={('tno', 'time')},
),
]
6 changes: 3 additions & 3 deletions EMS/courseSelection/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ class CourseSelected(models.Model):
sno = models.ForeignKey(to=Student, on_delete=models.CASCADE)
cno = models.ForeignKey(to=Teacher_Schedule_result, on_delete=models.CASCADE)
score = models.FloatField()
common_score = models.FloatField(null=True)
final_score = models.FloatField(null=True)

common_score = models.FloatField(default = 0)
final_score = models.FloatField(default=0)
is_finish = models.BooleanField(default = False)
class Meta:
db_table = "course_selected"

16 changes: 10 additions & 6 deletions EMS/courseSelection/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,17 @@ def find_course(request):
course_time=[]#收集这些课程的上课时间
dic = {}
tmp = {}
for i in theCourse:
t_info = {}
t_place = {}
for i in theCourse:#每门课
tmp = i.cno.time.split(",")#同一门课程在一周内不同的时间上
t_info[i.cno.tno.mcno.cno.cname] = i.cno.tno.tno.name
t_place[i.cno.tno.mcno.cno.cname] = i.cno.where.crno
dic[i.cno.tno.mcno.cno.cname]=[]
for j in tmp:#一周内不同的天
tmp = {}
tp = {}
district = j.split("-")
tmp["周数"] = district[2]+"-"+district[3]
tmp["节次"] = district[0]+"-"+district[1]
dic[i.cno.tno.mcno.cno.cname].append(tmp)
return JsonResponse({"dic":dic})
tp["周数"] = district[2]+"-"+district[3]
tp["节次"] = district[0]+"-"+district[1]
dic[i.cno.tno.mcno.cno.cname].append(tp)
return JsonResponse({"dic":dic,"t_info":t_info, "t_place":t_place})
Loading

0 comments on commit d069371

Please sign in to comment.