def create_participation_for_project(self, creation_time, project, student): participation = Participation() participation.set_creation_time(creation_time) participation.set_project(project) participation.set_student(student) participation.set_id(1) with ParticipationMapper() as mapper: mapper.find_participation_of_project(project)
def create_participation(self, module_id, project_id, student_id): """Teilnahme erstellen""" participation = Participation() participation.set_module_id(module_id) participation.set_project_id(project_id) participation.set_student_id(student_id) participation.set_id(1) with ParticipationMapper() as mapper: return mapper.insert(participation)
def find_all(self): result = [] cursor = self._cnx.cursor() cursor.execute( "SELECT id, creation_time, project, student FROM participation") tuples = cursor.fetchall() for (id, creation_time, project, student) in tuples: participation = Participation() participation.set_id(id) participation.set_creation_time(creation_time) participation.set_project(project) participation.set_student(student) result.append(participation) self._cnx.commit() cursor.close() return result
def post(self): """Teilnahme erstellen""" adm = ProjectAdministration() proposal = Participation.from_dict(api.payload) if proposal is not None: c = adm.create_participation(proposal.get_module_id(), proposal.get_project_id(), proposal.get_student_id()) return c, 200 else: return '', 500
def put(self, id): """Teilnahme wird aktualisiert""" adm = ProjectAdministration() participation = Participation.from_dict(api.payload) if participation is None: return "Teilnahme konnte nicht geändert werden", 500 else: participation.set_id(id) adm.save_participation(participation) return "Teilnahme wurde erfolgreich geändert", 200
def put(self, id): """Update eines bestimmten Participation-Objekts. """ adm = ProjectAdministration() p = Participation.from_dict(api.payload) if p is not None: p.set_id(id) adm.save_participation(p) return '', 200 else: return '', 500
def post(self): """Anlegen eines neuen Participation-Objekts. """ adm = ProjectAdministration() p = Participation.from_dict(api.payload) if p is not None: pa = adm.create_participation(p.get_id(), p.get_creation_time(), p.get_project(), p.get_student()) return pa, 200 else: return '', 500
def find_by_id(self, id): result = None cursor = self._cnx.cursor() command = "SELECT id, creation_time, project, student FROM participation WHERE id={}".format( id) cursor.execute(command) tuples = cursor.fetchall() if tuples[0] is not None: (id, creation_time, project, student) = tuples[0] participation = Participation() participation.set_id(id) participation.set_creation_time(creation_time) participation.set_project(project) participation.set_student(student) result = participation self._cnx.commit() cursor.close() return result
def create_particpation_for_student(self, student): """Für einen gegebenen Studenten einen neuen Teilnahme anlegen.""" with ParticipationMapper() as mapper: if student is not None: participation = Participation() participation.set_student_id(student.get_id()) participation.set_id(1) return mapper.insert(participation) else: return None
def create_participation(self, id, creation_time, project, student): """Einen Teilnahme anlegen""" participation = Participation() participation.set_creation_time(creation_time) participation.set_project(project) participation.set_student(student) participation.set_id(id) participation.set_id(1) with ParticipationMapper() as mapper: return mapper.insert(participation)