Changeset 3529 for waeup/trunk
- Timestamp:
- 30 Jun 2008, 16:24:45 (16 years ago)
- Location:
- waeup/trunk/src/waeup
- Files:
-
- 1 deleted
- 7 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
waeup/trunk/src/waeup/app_templates/index.pt
r3526 r3529 21 21 </div> 22 22 23 <div>24 <a href="@@importstudents">Import Students</a>25 </div>26 23 </body> 27 24 </html> -
waeup/trunk/src/waeup/basecontainer.py
r3527 r3529 1 1 import grok 2 from baseitem import BaseItem 2 3 3 class BaseContainer( grok.Container):4 class BaseContainer(BaseItem, grok.Container): 4 5 """ 5 6 The base container. This is a stub for now. It can have … … 9 10 name = u"BaseContainer" 10 11 childClass = None 12 specialActions = [] 11 13 12 14 class Index(grok.View): -
waeup/trunk/src/waeup/basecontainer_templates/index.pt
r3527 r3529 17 17 </table> 18 18 <a href="" tal:attributes="href python:view.url(context, 'add')">Add</a> 19 <a href="" 20 tal:repeat="action context/specialActions" 21 tal:attributes="href python:view.url(context, action)" 22 tal:content="action">Add</a> 19 23 </body> 20 24 </html> -
waeup/trunk/src/waeup/hostel/hostel.py
r3527 r3529 1 import grok 1 from waeup.baseitem import BaseItem 2 2 3 class Hostel( grok.Model):3 class Hostel(BaseItem): 4 4 pass -
waeup/trunk/src/waeup/students/student.py
r3528 r3529 5 5 from waeup.baseitem import BaseItem 6 6 7 def fromCsv(a): 8 #Factory method 9 student = Student("Dummy") 10 student.entry_mode, student.end_level, student.name, student.jamb_reg_no, student.level, student.id, student.lga, student.entry_session, student.matric_no, student.sex, student.phone, student.session, student.course, student.mode, student.faculty, student.department, student.verdict, student.review_state, student.perm_address, student.email = a 11 return student 12 7 13 class Student(BaseItem): 8 14 """This is a student record. 9 15 """ 10 16 grok.implements(IStudent) 17 18 #TODO: REFACTOR TO SCHEMA 19 fields = [ "entry_mode", 20 "end_level", 21 "name", 22 "jamb_reg_no", 23 "level", 24 "id", 25 "lga", 26 "entry_session", 27 "matric_no", 28 "sex", 29 "phone", 30 "session", 31 "course", 32 "mode", 33 "faculty", 34 "department", 35 "verdict", 36 "review_state", 37 "perm_address", 38 "email" 39 ] 11 40 12 41 def __init__(self, name): … … 38 67 self.name = name 39 68 40 def fromCsv(self, a):41 self.entry_mode, self.end_level, self.name, self.jamb_reg_no, self.level, self.id, self.lga, self.entry_session, self.matric_no, self.sex, self.phone, self.session, self.course, self.mode, self.faculty, self.department, self.verdict, self.review_state, self.perm_address, self.email = a42 69 43 70 def getCsv(self): 44 return self.entry_mode, self.end_level, self.name, self.jamb_reg_no, self.level, self.id, self.lga, self.entry_session, self.matric_no, self.sex, self.phone, self.session, self.course, self.mode, self.faculty, self.department, self.verdict, self.review_state, self.perm_address, self.email 71 #return self.entry_mode, self.end_level, self.name, self.jamb_reg_no, self.level, self.id, self.lga, self.entry_session, self.matric_no, self.sex, self.phone, self.session, self.course, self.mode, self.faculty, self.department, self.verdict, self.review_state, self.perm_address, self.email 72 return [getattr(self, field, u"") for field in self.fields] 73 -
waeup/trunk/src/waeup/students/studentcontainer.py
r3527 r3529 1 1 import grok 2 import os 2 3 3 4 from waeup.basecontainer import BaseContainer 4 from student import Student 5 from waeup.utils import csv5 from student import Student, fromCsv 6 from waeup.utils import importexport as csv 6 7 7 8 class StudentContainer(BaseContainer): … … 11 12 name = u"Students" 12 13 childClass = Student 13 14 specialActions = [u"import", u"export"] 14 15 15 16 class Import(grok.View): 16 17 def render(self): 17 18 t = [0] 18 src = os.path.join(os.path.dirname(__file__), ' tests',19 src = os.path.join(os.path.dirname(__file__), '..', 'tests', 19 20 'results2.csv') 20 21 inputfile = file(src, "r") … … 22 23 headers, rows = csv.readFile(inputfile) 23 24 for i in rows: 24 s = Student(i)25 s = fromCsv(i) 25 26 self.context[str(num)] = s 26 27 num += 1 28 if num > 100: 29 break 27 30 return "%s new Students added in %s" % (num, t[0]) 28 31 -
waeup/trunk/src/waeup/university/faculty.py
r3526 r3529 1 1 import grok 2 from waeup.basecontainer import BaseContainer 2 3 from interfaces import IFaculty 3 4 4 class Faculty( grok.Container):5 class Faculty(BaseContainer): 5 6 grok.implements(IFaculty) 6 7
Note: See TracChangeset for help on using the changeset viewer.