# -*- coding: utf-8 # -*- Mode: Python; py-indent-offset: 4 -*- """ Students Object """ __version__ = "$Revision:33$"[11:-2] import Globals from Globals import Acquisition, Persistent from Acquisition import aq_base, aq_inner, aq_parent, Explicit from AccessControl import ClassSecurityInfo from OFS.SimpleItem import SimpleItem from zope.interface import implements from interfaces import IStudents class Students(SimpleItem, Persistent, Explicit): """ """ security = ClassSecurityInfo() security.declareObjectPublic() implements(IStudents) manage_options = SimpleItem.manage_options id = 'students' def __init__(self): self.students=[] def _checkStudent(self, email): students = self.getAllStudents() for s in students: if s.get('email')==email: return s.get('uid') return None def _addStudent(self, minfo): students = self.getAllStudents() students.append(minfo) self.setAllStudents(students) def _changeStudentInfo2(self, m_uid, fname, lname, email=''): students = self.getAllStudents() for s in students: if s.get('uid') == m_uid: # kui olemasoleva tegelase maili ei muudetud, siis vaja muuta ainult nime if s.get('email') == email: s['firstname'] = fname s['lastname'] = lname else: # kui muudan ka olemasoleva uid maili uid = self._checkStudent(email) #kontrolli, ega uus mail olemas pole if uid == None: #kui ei ole s['firstname'] = fname s['lastname'] = lname s['email'] = email # kui on siis muuta ei saa #siis tuleks teavitada, et teise aadressiga tegelane juba olemas ja muuta ei saa self.setAllStudents(students) def _changeStudentInfo(self, m_uid, fname, lname, email): students = self.getAllStudents() for s in students: if s.get('uid') == m_uid: s['firstname'] = fname s['lastname'] = lname s['email'] = email self.setAllStudents(students) def _changeStudentFolders(self, m_uid, folders): students = self.getAllStudents() for s in students: if s.get('uid') == m_uid: s['ans_containers'] = folders self.setAllStudents(students) def setAllStudents(self, val): self.students = val def getAllStudents(self): return self.students Globals.InitializeClass(Students) #EOF