def create_note(self, author, incident, title, content): note = Note(title, author, content) self.database.insert_note(incident, note) self.create_notification( incident, author.forename + ' ' + author.surname + ' added a note to ' + incident.title) note.date_created = self.database.get_note_date_created(note) incident.notes.append(note) self.notes[note.id] = note self.database.commit() return note
def load_incidents(self): incident_rows = self.database.get_incidents() for incident_row in incident_rows: author = self.get_user(incident_row[1]) status = self.get_stage(incident_row[6]) system = self.get_system_class(incident_row[7]) impact = self.get_impact(incident_row[8]) severity = self.get_severity(incident_row[9]) priority = self.get_priority(incident_row[10]) sla_identification_deadline = TimeUtil.sqlite_to_datetime( incident_row[4]) sla_implementation_deadline = TimeUtil.sqlite_to_datetime( incident_row[5]) incident = Incident(self, incident_row[2], incident_row[3], author, \ sla_identification_deadline, sla_implementation_deadline, status, system, \ impact, priority, severity) incident.id = incident_row[0] incident.date_created = TimeUtil.sqlite_to_datetime( incident_row[11]) incident.date_identified = incident_row[12] incident.date_implemented = incident_row[13] note_rows = self.database.get_notes(incident) for note_row in note_rows: note_id = note_row[0] note_title = note_row[1] note_author = self.get_user(note_row[2]) date_created = note_row[3] note_content = note_row[4] note = Note(note_title, note_author, note_content) note.id = note_id note.date_created = date_created incident.notes.append(note) self.notes[note.id] = note question_rows = self.database.get_questions(incident) for question_row in question_rows: question_id = question_row[0] question_title = question_row[1] question_issuer = self.get_user(question_row[2]) date_asked = question_row[3] question_content = question_row[4] question = Question(question_title, question_issuer, question_content) question.id = question_id question.date_asked = date_asked answer_rows = self.database.get_answers(question) for answer_row in answer_rows: answer_id = answer_row[0] answer_answerer = self.get_user(answer_row[1]) answer_content = answer_row[2] date_answered = answer_row[3] answer = Answer(question, answer_answerer, answer_content) answer.id = answer_id answer.date_answered = date_answered question.answers.append(answer) incident.questions.append(question) self.questions[question.id] = question task_rows = self.database.get_tasks(incident) for task_row in task_rows: task_id = task_row[0] task_name = task_row[1] task_author = self.get_user(task_row[2]) date_created = task_row[3] task_content = task_row[4] task_status = task_row[5] task = Task(task_name, task_author, task_content, task_status) task.id = task_id task.date_created = date_created task_team_rows = self.database.get_task_team_assignment_requests( task) for task_team_row in task_team_rows: task_team = self.get_team(task_team_row[0]) assigner = self.get_user(task_team_row[1]) status = task_team_row[2] date_issued = task_team_row[3] assigned_team = AssignedTeam(task_team, task) assigned_team.status = status assigned_team.date_issued = date_issued task.teams.append(assigned_team) incident.tasks.append(task) self.tasks[task.id] = task self.incidents[incident.id] = incident