Changeset 3527 for waeup/trunk
- Timestamp:
- 30 Jun 2008, 15:30:23 (16 years ago)
- Location:
- waeup/trunk/src/waeup
- Files:
-
- 9 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/trunk/src/waeup/basecontainer.py
r3526 r3527 6 6 base methods and templates attached to it 7 7 """ 8 9 name = u"BaseContainer" 10 childClass = None 11 12 class Index(grok.View): 13 """ 14 Base view 15 """ 16 17 class Add(grok.AddForm): 18 #form_fields = grok.AutoFields(self.context.childClass) 19 #DOESN'T WORK grok.template("../basecontainer_templates/add.pt") 20 21 def update(self): 22 self.form_fields = grok.AutoFields(self.context.childClass) 23 grok.AddForm.update(self) 24 25 @grok.action('Add Item') 26 def addItem(self, name, *args, **kw): 27 item = self.context.childClass(name=name) 28 self.context[name] = item 29 self.redirect(self.url(item)) -
waeup/trunk/src/waeup/catalog.py
r3526 r3527 35 35 return result 36 36 37 class ImportStudents(grok.View):38 grok.context(University)39 40 def render(self):41 t = [0]42 src = os.path.join(os.path.dirname(__file__), 'tests',43 'results2.csv')44 inputfile = file(src, "r")45 num = 046 headers, rows = readFile(inputfile)47 for i in rows:48 s = Student(i)49 self.context[str(num)] = s50 num += 151 return "%s new Students added in %s" % (num, t[0])52 53 class ListView(grok.View):54 grok.context(University)55 56 def render(self):57 result = []58 for s in self.context.values():59 result.append(getattr(s,'name', 'Error'+str(type(s))))60 return "\n".join(result)61 62 class ExportStudents(grok.View):63 grok.context(University)64 65 def render(self):66 t = [0]67 result = []68 for s in self.context.values():69 result.append(s.getCsv())70 writeFile(result)71 return "yeah %s" % t[0]72 73 74 def readFile(f):75 """read a CSV file"""76 headers = []77 rows = []78 f = csv.reader(f)79 headers = f.next()80 for line in f:81 rows.append(line)82 return (headers, rows)83 84 def writeFile(data):85 writer = csv.writer(open("export.csv", "wb"))86 writer.writerows(data)87 -
waeup/trunk/src/waeup/hostel/hostel.py
r3526 r3527 1 import grok 2 3 class Hostel(grok.Model): 4 pass -
waeup/trunk/src/waeup/hostel/hostelcontainer.py
r3526 r3527 1 1 from waeup.basecontainer import BaseContainer 2 from hostel import Hostel 2 3 3 4 class HostelContainer(BaseContainer): 4 5 name = u"Hostels" 6 childClass = Hostel -
waeup/trunk/src/waeup/students/student.py
r3526 r3527 8 8 grok.implements(IStudent) 9 9 10 def __init__(self, a):10 def __init__(self, name): 11 11 """ 12 12 TODO: REFACTOR TO IMPORT METHOD … … 34 34 35 35 """ 36 self.name = name 37 38 def fromCsv(self, a): 36 39 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 = a 37 40 -
waeup/trunk/src/waeup/students/studentcontainer.py
r3526 r3527 2 2 3 3 from waeup.basecontainer import BaseContainer 4 from student import Student 5 from waeup.utils import csv 4 6 5 7 class StudentContainer(BaseContainer): … … 8 10 """ 9 11 name = u"Students" 12 childClass = Student 13 14 15 class Import(grok.View): 16 def render(self): 17 t = [0] 18 src = os.path.join(os.path.dirname(__file__), 'tests', 19 'results2.csv') 20 inputfile = file(src, "r") 21 num = 0 22 headers, rows = csv.readFile(inputfile) 23 for i in rows: 24 s = Student(i) 25 self.context[str(num)] = s 26 num += 1 27 return "%s new Students added in %s" % (num, t[0]) 28 29 class Export(grok.View): 30 def render(self): 31 t = [0] 32 result = [] 33 for s in self.context.values(): 34 result.append(s.getCsv()) 35 csv.writeFile(result) 36 return "yeah %s" % t[0] -
waeup/trunk/src/waeup/university/facultycontainer.py
r3526 r3527 2 2 from waeup.basecontainer import BaseContainer 3 3 from interfaces import IFaculty 4 from faculty import Faculty 4 5 5 6 class FacultyContainer(BaseContainer): 6 7 7 8 name = u'Faculties' 8 9 class AddFaculty(grok.AddForm): 10 form_fields = grok.AutoFields(IFaculty) 11 12 @grok.action('Add Faculty') 13 def addFaculty(self, name, *args, **kw): 14 new_fac = Faculty(name=name) 15 self.context[name] = new_fac 16 self.redirect(self.url(new_fac)) 9 childClass = Faculty
Note: See TracChangeset for help on using the changeset viewer.