It workses! Except the semesters. I'm getting there.
This commit is contained in:
parent
016cdcfd54
commit
d50b7af349
250
egon.py
250
egon.py
|
@ -40,6 +40,9 @@ class MainWindow(QMainWindow):
|
||||||
# The program name
|
# The program name
|
||||||
self.title = "Egon"
|
self.title = "Egon"
|
||||||
|
|
||||||
|
# The days
|
||||||
|
self.days = [self.trUtf8("Monday"), self.trUtf8("Tuesday"), self.trUtf8("Wednesday"), self.trUtf8("Thursday"), self.trUtf8("Friday")]
|
||||||
|
|
||||||
# The tabs
|
# The tabs
|
||||||
self.assignment = AssignmentTab()
|
self.assignment = AssignmentTab()
|
||||||
self.reading = ReadingTab()
|
self.reading = ReadingTab()
|
||||||
|
@ -223,7 +226,30 @@ class MainWindow(QMainWindow):
|
||||||
self.asdlg.show()
|
self.asdlg.show()
|
||||||
|
|
||||||
def deleteLesson(self):
|
def deleteLesson(self):
|
||||||
pass
|
table, row, column = self.getScheduleTableRowAndColumn()
|
||||||
|
day, course, time = self.getDayCourseAndTime()
|
||||||
|
removeLessonFromDB(day, course, time)
|
||||||
|
table.setItem(row, column, QTableWidgetItem())
|
||||||
|
|
||||||
|
def getDayCourseAndTime(self):
|
||||||
|
table, row, column = self.getScheduleTableRowAndColumn()
|
||||||
|
item = table.item(row, column)
|
||||||
|
text = item.text()
|
||||||
|
textlist = text.split('\n')
|
||||||
|
courseFull = textlist[0]
|
||||||
|
coursecode = getCourseCode(courseFull)
|
||||||
|
day = self.getDayFromTable(column)
|
||||||
|
time = row + 8
|
||||||
|
return day, coursecode, time
|
||||||
|
|
||||||
|
def getScheduleTableRowAndColumn(self):
|
||||||
|
table = self.schedule.scheduleTable
|
||||||
|
row = table.currentRow()
|
||||||
|
column = table.currentColumn()
|
||||||
|
return table, row, column
|
||||||
|
|
||||||
|
def getDayFromTable(self, column):
|
||||||
|
return self.days[column]
|
||||||
|
|
||||||
def helpAbout(self):
|
def helpAbout(self):
|
||||||
QMessageBox.about(self, "About %s" % self.title, u"""
|
QMessageBox.about(self, "About %s" % self.title, u"""
|
||||||
|
@ -861,13 +887,12 @@ class ScheduleTab(QWidget):
|
||||||
self.scheduleTable.verticalHeader().setResizeMode(QHeaderView.ResizeToContents)
|
self.scheduleTable.verticalHeader().setResizeMode(QHeaderView.ResizeToContents)
|
||||||
|
|
||||||
def addLessonToTable(self, lesson):
|
def addLessonToTable(self, lesson):
|
||||||
rows = self.getRows(lesson.getFromTime(), lesson.getToTime())
|
row = lesson.getTime() - 8
|
||||||
column = self.getColumn(lesson.getDay())
|
column = self.getColumn(lesson.getDay())
|
||||||
course = lesson.getCourse().getFull()
|
course = lesson.getCourse().getFull()
|
||||||
type = lesson.getType()
|
type = lesson.getType()
|
||||||
room = lesson.getRoom()
|
room = lesson.getRoom()
|
||||||
for row in rows:
|
item = QTableWidgetItem(QString("%s\n%s\n%s" % (course, type, room)))
|
||||||
item = QTableWidgetItem(QString("%s\n %s\n %s" % (course, type, room)))
|
|
||||||
item.setBackground(self.getBackground(QString("%s" % type), lesson.getCourse()))
|
item.setBackground(self.getBackground(QString("%s" % type), lesson.getCourse()))
|
||||||
self.scheduleTable.setItem(row, column, item)
|
self.scheduleTable.setItem(row, column, item)
|
||||||
|
|
||||||
|
@ -886,13 +911,6 @@ class ScheduleTab(QWidget):
|
||||||
else:
|
else:
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
def getRows(self, fromtime, totime):
|
|
||||||
rows = []
|
|
||||||
for i in range(fromtime, totime):
|
|
||||||
rows.append(i-8)
|
|
||||||
return rows
|
|
||||||
|
|
||||||
|
|
||||||
def getBackground(self, type, course):
|
def getBackground(self, type, course):
|
||||||
if type.compare(QString(self.trUtf8("Lecture"))) == 0:
|
if type.compare(QString(self.trUtf8("Lecture"))) == 0:
|
||||||
brush = QBrush(Qt.HorPattern)
|
brush = QBrush(Qt.HorPattern)
|
||||||
|
@ -926,8 +944,7 @@ class ScheduleDlg(QDialog):
|
||||||
self.roomLabel = QLabel(self.trUtf8("&Room"))
|
self.roomLabel = QLabel(self.trUtf8("&Room"))
|
||||||
|
|
||||||
self.dayEdit = QComboBox()
|
self.dayEdit = QComboBox()
|
||||||
days = [self.trUtf8("Monday"), self.trUtf8("Tuesday"), self.trUtf8("Wednesday"), self.trUtf8("Thursday"), self.trUtf8("Friday")]
|
self.dayEdit.addItems(getMain().days)
|
||||||
self.dayEdit.addItems(days)
|
|
||||||
self.fromEdit = QSpinBox()
|
self.fromEdit = QSpinBox()
|
||||||
self.fromEdit.setRange(08.15, 18.15)
|
self.fromEdit.setRange(08.15, 18.15)
|
||||||
self.fromEdit.setSingleStep(01.00)
|
self.fromEdit.setSingleStep(01.00)
|
||||||
|
@ -984,18 +1001,19 @@ class AddScheduleDlg(ScheduleDlg):
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
day = unicode(self.dayEdit.currentText())
|
day = unicode(self.dayEdit.currentText())
|
||||||
fromTime = self.fromEdit.value()
|
fromtime = self.fromEdit.value()
|
||||||
toTime = self.toEdit.value()
|
totime = self.toEdit.value()
|
||||||
courseFull = unicode(self.courseEdit.currentText())
|
courseFull = unicode(self.courseEdit.currentText())
|
||||||
type = unicode(self.typeEdit.currentText())
|
type = unicode(self.typeEdit.currentText())
|
||||||
room = unicode(self.roomEdit.text())
|
room = unicode(self.roomEdit.text())
|
||||||
|
|
||||||
self.close()
|
|
||||||
|
|
||||||
course = getCourseFromDB(getCourseCode(courseFull))
|
course = getCourseFromDB(getCourseCode(courseFull))
|
||||||
|
|
||||||
addNewLessonToDB(day, fromTime, toTime, course, type, room)
|
for t in range(fromtime, totime):
|
||||||
getMain().schedule.addLessonToTable(ScheduleModel(day, fromTime, toTime, course, type, room))
|
addNewLessonToDB(SemesterModel("fall", 2008), day, t, course, type, room)
|
||||||
|
getMain().schedule.addLessonToTable(ScheduleModel(day, t, course, type, room))
|
||||||
|
|
||||||
|
self.close()
|
||||||
|
|
||||||
|
|
||||||
class EditScheduleDlg(ScheduleDlg):
|
class EditScheduleDlg(ScheduleDlg):
|
||||||
|
@ -1019,16 +1037,14 @@ class EditScheduleDlg(ScheduleDlg):
|
||||||
class ScheduleModel():
|
class ScheduleModel():
|
||||||
|
|
||||||
day = ""
|
day = ""
|
||||||
fromTime = 0
|
time = 0
|
||||||
toTime = 0
|
|
||||||
course = None
|
course = None
|
||||||
type = ""
|
type = ""
|
||||||
room = ""
|
room = ""
|
||||||
|
|
||||||
def __init__(self, day, fromTime, toTime, course, type, room):
|
def __init__(self, day, time, course, type, room):
|
||||||
self.day = day
|
self.day = day
|
||||||
self.fromTime = fromTime
|
self.time = time
|
||||||
self.toTime = toTime
|
|
||||||
self.course = course
|
self.course = course
|
||||||
self.type = type
|
self.type = type
|
||||||
self.room = room
|
self.room = room
|
||||||
|
@ -1039,17 +1055,11 @@ class ScheduleModel():
|
||||||
def setDay(self, day):
|
def setDay(self, day):
|
||||||
self.day = day
|
self.day = day
|
||||||
|
|
||||||
def getFromTime(self):
|
def getTime(self):
|
||||||
return self.fromTime
|
return self.time
|
||||||
|
|
||||||
def setFromTime(self, fromTime):
|
def setTime(self, fromTime):
|
||||||
self.fromTime = fromTime
|
self.time = time
|
||||||
|
|
||||||
def getToTime(self):
|
|
||||||
return self.toTime
|
|
||||||
|
|
||||||
def setToTime(self, toTime):
|
|
||||||
self.toTime = toTime
|
|
||||||
|
|
||||||
def getCourse(self):
|
def getCourse(self):
|
||||||
return self.course
|
return self.course
|
||||||
|
@ -1085,17 +1095,13 @@ class CourseDlg(QDialog):
|
||||||
self.codeEdit = QLineEdit()
|
self.codeEdit = QLineEdit()
|
||||||
self.titleEdit = QLineEdit()
|
self.titleEdit = QLineEdit()
|
||||||
self.shortEdit = QLineEdit()
|
self.shortEdit = QLineEdit()
|
||||||
self.bookList = QListWidget()
|
self.booksEdit = QListWidget()
|
||||||
self.booksEdit = QPushButton(self.trUtf8("Add new book"))
|
self.updateList()
|
||||||
self.bookMenu = QMenu()
|
self.booksEdit.setSelectionMode(QAbstractItemView.ExtendedSelection)
|
||||||
booksDB = getBooksFromDB()
|
|
||||||
actions = []
|
self.newBook = QPushButton("Add new book")
|
||||||
for book in booksDB:
|
self.connect(self.newBook, SIGNAL("pressed()"), getMain().addBook)
|
||||||
actions.append(QAction(QString(book.getTitle()), self.bookMenu))
|
self.connect(getMain(), SIGNAL("newBook"), self.updateList)
|
||||||
for action in actions:
|
|
||||||
self.bookMenu.addAction(action)
|
|
||||||
self.connect(action, SIGNAL("triggered()"), self.addNewBookToCourse)
|
|
||||||
self.booksEdit.setMenu(self.bookMenu)
|
|
||||||
|
|
||||||
self.codeLabel.setBuddy(self.codeEdit)
|
self.codeLabel.setBuddy(self.codeEdit)
|
||||||
self.titleLabel.setBuddy(self.titleEdit)
|
self.titleLabel.setBuddy(self.titleEdit)
|
||||||
|
@ -1110,10 +1116,19 @@ class CourseDlg(QDialog):
|
||||||
self.layout.addWidget(self.codeEdit, 0, 1)
|
self.layout.addWidget(self.codeEdit, 0, 1)
|
||||||
self.layout.addWidget(self.titleEdit, 1, 1)
|
self.layout.addWidget(self.titleEdit, 1, 1)
|
||||||
self.layout.addWidget(self.shortEdit, 2, 1)
|
self.layout.addWidget(self.shortEdit, 2, 1)
|
||||||
self.layout.addWidget(self.bookList, 3, 1)
|
self.layout.addWidget(self.booksEdit, 3, 1)
|
||||||
self.layout.addWidget(self.booksEdit, 4, 1)
|
self.layout.addWidget(self.newBook, 4, 0)
|
||||||
self.setLayout(self.layout)
|
self.setLayout(self.layout)
|
||||||
|
|
||||||
|
def updateList(self):
|
||||||
|
self.booksEdit.clear()
|
||||||
|
booksDB = getBooksFromDB()
|
||||||
|
booksStringList = QStringList()
|
||||||
|
for book in booksDB:
|
||||||
|
booksStringList.append(book.getTitle())
|
||||||
|
self.booksEdit.addItems(booksStringList)
|
||||||
|
self.booksEdit.sortItems()
|
||||||
|
|
||||||
def addNewBookToCourse(self):
|
def addNewBookToCourse(self):
|
||||||
book = getBookWithTitleFromDB(booktitle)
|
book = getBookWithTitleFromDB(booktitle)
|
||||||
self.books.append(book)
|
self.books.append(book)
|
||||||
|
@ -1126,7 +1141,7 @@ class AddCourseDlg(CourseDlg):
|
||||||
|
|
||||||
buttonBox = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Cancel)
|
buttonBox = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Cancel)
|
||||||
|
|
||||||
self.layout.addWidget(buttonBox, 5, 0, 1, 2)
|
self.layout.addWidget(buttonBox, 4, 1, 1, 2)
|
||||||
|
|
||||||
self.connect(buttonBox, SIGNAL("accepted()"), self, SLOT("accept()"))
|
self.connect(buttonBox, SIGNAL("accepted()"), self, SLOT("accept()"))
|
||||||
self.connect(buttonBox, SIGNAL("rejected()"), self, SLOT("reject()"))
|
self.connect(buttonBox, SIGNAL("rejected()"), self, SLOT("reject()"))
|
||||||
|
@ -1137,21 +1152,18 @@ class AddCourseDlg(CourseDlg):
|
||||||
courseCode = unicode(self.codeEdit.text())
|
courseCode = unicode(self.codeEdit.text())
|
||||||
courseTitle = unicode(self.titleEdit.text())
|
courseTitle = unicode(self.titleEdit.text())
|
||||||
courseShort = unicode(self.shortEdit.text())
|
courseShort = unicode(self.shortEdit.text())
|
||||||
courseBooks = self.books
|
courseBooks = self.booksEdit.selectedItems()
|
||||||
color = getRandomColor()
|
color = getRandomColor()
|
||||||
global colors
|
global colors
|
||||||
while color in colors:
|
while color in colors:
|
||||||
color = getRandomColor()
|
color = getRandomColor()
|
||||||
colors.append(color)
|
colors.append(color)
|
||||||
course = CourseModel(courseCode, courseTitle, courseShort, color, courseBooks)
|
books = []
|
||||||
self.close()
|
|
||||||
for book in courseBooks:
|
for book in courseBooks:
|
||||||
self.addNewBookCourse(book)
|
books.append(getBookWithTitleFromDB("%s" % book.text()))
|
||||||
addNewCourseToDB(courseCode, courseTitle, courseShort, color, courseBooks)
|
course = CourseModel(courseCode, courseTitle, courseShort, color, books)
|
||||||
|
addNewCourseToDB(courseCode, courseTitle, courseShort, color, books)
|
||||||
def addNewBookCourse(self, book):
|
self.close()
|
||||||
self.books.append(book)
|
|
||||||
self.bookList.addItem(book.getTitle())
|
|
||||||
|
|
||||||
|
|
||||||
class CourseModel():
|
class CourseModel():
|
||||||
|
@ -1247,8 +1259,9 @@ class AddBookDlg(BookDlg):
|
||||||
bookAuthor = unicode(self.authorEdit.text())
|
bookAuthor = unicode(self.authorEdit.text())
|
||||||
bookEdition = self.editionEdit.value()
|
bookEdition = self.editionEdit.value()
|
||||||
bookIsbn = unicode(self.isbnEdit.text())
|
bookIsbn = unicode(self.isbnEdit.text())
|
||||||
self.close()
|
|
||||||
addNewBookToDB(bookIsbn, bookTitle, bookAuthor, bookEdition)
|
addNewBookToDB(bookIsbn, bookTitle, bookAuthor, bookEdition)
|
||||||
|
getMain().emit(SIGNAL("newBook"))
|
||||||
|
self.close()
|
||||||
|
|
||||||
|
|
||||||
class BookModel():
|
class BookModel():
|
||||||
|
@ -1277,6 +1290,22 @@ class BookModel():
|
||||||
return self.edition
|
return self.edition
|
||||||
|
|
||||||
|
|
||||||
|
class SemesterModel():
|
||||||
|
|
||||||
|
term = ""
|
||||||
|
year = 0
|
||||||
|
|
||||||
|
def __init__(self, term, year):
|
||||||
|
self.term = term
|
||||||
|
self.year = year
|
||||||
|
|
||||||
|
def getTerm(self):
|
||||||
|
return self.term
|
||||||
|
|
||||||
|
def getYear(self):
|
||||||
|
return self.year
|
||||||
|
|
||||||
|
|
||||||
class CalendarTab(QWidget):
|
class CalendarTab(QWidget):
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
|
@ -1297,14 +1326,27 @@ def initDB():
|
||||||
|
|
||||||
def initNewDB():
|
def initNewDB():
|
||||||
cursor, conn = initDB()
|
cursor, conn = initDB()
|
||||||
|
initSemesterDB(cursor)
|
||||||
initAssignmentDB(cursor)
|
initAssignmentDB(cursor)
|
||||||
initReadingDB(cursor)
|
initReadingDB(cursor)
|
||||||
initScheduleDB(cursor)
|
initScheduleDB(cursor)
|
||||||
initBookDB(cursor)
|
initBookDB(cursor)
|
||||||
initCourseDB(cursor)
|
initCourseDB(cursor)
|
||||||
|
initAssignmentInSemester(cursor)
|
||||||
|
initReadingInSemester(cursor)
|
||||||
|
initScheduleInSemester(cursor)
|
||||||
initCourseUsesBook(cursor)
|
initCourseUsesBook(cursor)
|
||||||
exitDB(conn)
|
exitDB(conn)
|
||||||
|
|
||||||
|
def initSemesterDB(cursor):
|
||||||
|
cursor.execute('''
|
||||||
|
CREATE TABLE Semester (
|
||||||
|
term TEXT,
|
||||||
|
year INT,
|
||||||
|
PRIMARY KEY (term, year)
|
||||||
|
)
|
||||||
|
''')
|
||||||
|
|
||||||
def initAssignmentDB(cursor):
|
def initAssignmentDB(cursor):
|
||||||
cursor.execute('''
|
cursor.execute('''
|
||||||
CREATE TABLE Assignment (
|
CREATE TABLE Assignment (
|
||||||
|
@ -1320,7 +1362,7 @@ def initAssignmentDB(cursor):
|
||||||
def initReadingDB(cursor):
|
def initReadingDB(cursor):
|
||||||
cursor.execute('''
|
cursor.execute('''
|
||||||
CREATE TABLE Reading (
|
CREATE TABLE Reading (
|
||||||
week TEXT,
|
week INT,
|
||||||
course TEXT,
|
course TEXT,
|
||||||
book INT,
|
book INT,
|
||||||
chapter TEXT,
|
chapter TEXT,
|
||||||
|
@ -1334,12 +1376,11 @@ def initScheduleDB(cursor):
|
||||||
cursor.execute('''
|
cursor.execute('''
|
||||||
CREATE TABLE Lesson (
|
CREATE TABLE Lesson (
|
||||||
day TEXT,
|
day TEXT,
|
||||||
fromtime INT,
|
time INT,
|
||||||
totime INT,
|
|
||||||
course TEXT,
|
course TEXT,
|
||||||
type TEXT,
|
type TEXT,
|
||||||
room TEXT,
|
room TEXT,
|
||||||
PRIMARY KEY (course, day, fromtime)
|
PRIMARY KEY (course, day, time)
|
||||||
)
|
)
|
||||||
''')
|
''')
|
||||||
|
|
||||||
|
@ -1365,6 +1406,41 @@ def initCourseDB(cursor):
|
||||||
)
|
)
|
||||||
''')
|
''')
|
||||||
|
|
||||||
|
def initAssignmentInSemester(cursor):
|
||||||
|
cursor.execute('''
|
||||||
|
CREATE TABLE AssignmentInSemester (
|
||||||
|
course TEXT,
|
||||||
|
number INT,
|
||||||
|
term TEXT,
|
||||||
|
year INT,
|
||||||
|
PRIMARY KEY (course, number, term, year)
|
||||||
|
)
|
||||||
|
''')
|
||||||
|
|
||||||
|
def initReadingInSemester(cursor):
|
||||||
|
cursor.execute('''
|
||||||
|
CREATE TABLE ReadingInSemester (
|
||||||
|
week INT,
|
||||||
|
course TEXT,
|
||||||
|
book TEXT,
|
||||||
|
term TEXT,
|
||||||
|
year INT,
|
||||||
|
PRIMARY KEY (week, course, book, term, year)
|
||||||
|
)
|
||||||
|
''')
|
||||||
|
|
||||||
|
def initScheduleInSemester(cursor):
|
||||||
|
cursor.execute('''
|
||||||
|
CREATE TABLE ScheduleInSemester (
|
||||||
|
course TEXT,
|
||||||
|
day TEXT,
|
||||||
|
time INT,
|
||||||
|
term TEXT,
|
||||||
|
year INT,
|
||||||
|
PRIMARY KEY (course, day, time, term, year)
|
||||||
|
)
|
||||||
|
''')
|
||||||
|
|
||||||
def initCourseUsesBook(cursor):
|
def initCourseUsesBook(cursor):
|
||||||
cursor.execute('''
|
cursor.execute('''
|
||||||
CREATE TABLE CourseUsesBook (
|
CREATE TABLE CourseUsesBook (
|
||||||
|
@ -1374,7 +1450,7 @@ def initCourseUsesBook(cursor):
|
||||||
)
|
)
|
||||||
''')
|
''')
|
||||||
|
|
||||||
def addNewAssignmentToDB(datetime, course, number, description, complete):
|
def addNewAssignmentToDB(semester, datetime, course, number, description, complete):
|
||||||
cursor, conn = initDB()
|
cursor, conn = initDB()
|
||||||
|
|
||||||
day = datetime.date().day()
|
day = datetime.date().day()
|
||||||
|
@ -1389,11 +1465,14 @@ def addNewAssignmentToDB(datetime, course, number, description, complete):
|
||||||
VALUES (datetime(?), ?, ?, ?, ?)
|
VALUES (datetime(?), ?, ?, ?, ?)
|
||||||
''', (timestring, course.getCode(), number, description, complete))
|
''', (timestring, course.getCode(), number, description, complete))
|
||||||
|
|
||||||
|
cursor.execute('''
|
||||||
|
INSERT INTO AssignmentInSemester (course, number, term, year)
|
||||||
|
VALUES (?, ?, ?, ?)
|
||||||
|
''', (course.getCode(), number, semester.getTerm(), semester.getYear()))
|
||||||
|
|
||||||
exitDB(conn)
|
exitDB(conn)
|
||||||
|
|
||||||
return 'ok'
|
def addNewReadingToDB(semester, week, course, book, chapter, pages, done):
|
||||||
|
|
||||||
def addNewReadingToDB(week, course, book, chapter, pages, done):
|
|
||||||
cursor, conn = initDB()
|
cursor, conn = initDB()
|
||||||
|
|
||||||
cursor.execute('''
|
cursor.execute('''
|
||||||
|
@ -1401,15 +1480,25 @@ def addNewReadingToDB(week, course, book, chapter, pages, done):
|
||||||
VALUES (?, ?, ?, ?, ?, ?)
|
VALUES (?, ?, ?, ?, ?, ?)
|
||||||
''', (week, course.getCode(), book.getIsbn(), chapter, pages, done))
|
''', (week, course.getCode(), book.getIsbn(), chapter, pages, done))
|
||||||
|
|
||||||
|
cursor.execute('''
|
||||||
|
INSERT INTO ReadingInSemester (week, course, book, term, year)
|
||||||
|
VALUES (?, ?, ?, ?, ?)
|
||||||
|
''', (week, course, book, semester.getTerm(), semester.getYear()))
|
||||||
|
|
||||||
exitDB(conn)
|
exitDB(conn)
|
||||||
|
|
||||||
def addNewLessonToDB(day, fromtime, totime, course, type, room):
|
def addNewLessonToDB(semester, day, time, course, type, room):
|
||||||
cursor, conn = initDB()
|
cursor, conn = initDB()
|
||||||
|
|
||||||
cursor.execute('''
|
cursor.execute('''
|
||||||
INSERT INTO Lesson (day, fromtime, totime, course, type, room)
|
INSERT INTO Lesson (day, time, course, type, room)
|
||||||
VALUES (?, ?, ?, ?, ?, ?)
|
VALUES (?, ?, ?, ?, ?)
|
||||||
''', (day, fromtime, totime, course.getCode(), type, room))
|
''', (day, time, course.getCode(), type, room))
|
||||||
|
|
||||||
|
cursor.execute('''
|
||||||
|
INSERT INTO ScheduleInSemester (course, day, time, term, year)
|
||||||
|
VALUES (?, ?, ?, ?, ?)
|
||||||
|
''', (course.getCode(), day, time, semester.getTerm(), semester.getYear()))
|
||||||
|
|
||||||
exitDB(conn)
|
exitDB(conn)
|
||||||
|
|
||||||
|
@ -1503,7 +1592,7 @@ def getLessonsFromDB():
|
||||||
|
|
||||||
lessons = []
|
lessons = []
|
||||||
for row in cursor.fetchall():
|
for row in cursor.fetchall():
|
||||||
lessons.append(ScheduleModel(row[0], row[1], row[2], getCourseFromDB(row[3]), row[4], row[5]))
|
lessons.append(ScheduleModel(row[0], row[1], getCourseFromDB(row[2]), row[3], row[4]))
|
||||||
|
|
||||||
exitDB(conn)
|
exitDB(conn)
|
||||||
|
|
||||||
|
@ -1548,6 +1637,8 @@ def getCourseFromDB(courseCode):
|
||||||
WHERE code = ?
|
WHERE code = ?
|
||||||
''', (courseCode,))
|
''', (courseCode,))
|
||||||
|
|
||||||
|
course = None
|
||||||
|
|
||||||
for row in cursor.fetchall():
|
for row in cursor.fetchall():
|
||||||
course = CourseModel(row[0], row[1], row[2], QColor(row[3], row[4], row[5]), [])
|
course = CourseModel(row[0], row[1], row[2], QColor(row[3], row[4], row[5]), [])
|
||||||
|
|
||||||
|
@ -1683,6 +1774,23 @@ def removeReadingFromDB(week, coursecode, bookisbn):
|
||||||
|
|
||||||
exitDB(conn)
|
exitDB(conn)
|
||||||
|
|
||||||
|
def removeLessonFromDB(daystring, coursecode, fromTime):
|
||||||
|
cursor, conn = initDB()
|
||||||
|
|
||||||
|
day = "%s" % daystring
|
||||||
|
course = "%s" % coursecode
|
||||||
|
time = "%s" % fromTime
|
||||||
|
|
||||||
|
cursor.execute('''
|
||||||
|
DELETE
|
||||||
|
FROM Lesson
|
||||||
|
WHERE day = ?
|
||||||
|
AND course = ?
|
||||||
|
AND time = ?
|
||||||
|
''', (day, course, time))
|
||||||
|
|
||||||
|
exitDB(conn)
|
||||||
|
|
||||||
def exitDB(conn):
|
def exitDB(conn):
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
Reference in New Issue