Changeset 4729 for waeup/branches/ulif-layout
- Timestamp:
- 8 Jan 2010, 02:35:47 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/branches/ulif-layout/src/waeup/browser/pages.py
r4722 r4729 623 623 return 'Course: %s (%s)' % (self.context.title, self.context.code) 624 624 625 class CourseManageFormPage(WAeUPEditFormPage): 626 """Edit form page for courses. 627 """ 628 grok.context(ICourse) 629 grok.name('manage') 630 grok.require('waeup.manageUniversity') 631 title = u'Edit course settings' 632 pnav = 1 633 634 form_fields = grok.AutoFields(ICourse) 635 636 @grok.action('Save') 637 def save(self, **data): 638 self.applyData(self.context, **data) 639 return 640 641 @grok.action('Save and return') 642 def saveAndReturn(self, **data): 643 self.applyData(self.context, **data) 644 self.redirect(self.url(self.context)) 645 return 646 647 @grok.action('Cancel') 648 def cancel(self, **data): 649 self.redirect(self.url(self.context)) 650 return 651 652 # 653 # Certificate pages 654 # 655 class CertificatePage(WAeUPPage): 656 """Index page for certificates. 657 """ 658 grok.context(ICertificate) 659 grok.name('index') 660 grok.require('waeup.View') 661 pnav = 1 662 663 @property 664 def title(self): 665 return "%s (%s)" % (self.context.title, self.context.code) 666 667 def update(self): 668 if 'delcourse' in self.request.form: 669 code = self.request.form['code'] 670 level = self.request.form['level'] 671 self.context.delCourseRef(code, level=level) 672 return 673 674 def getCourseList(self): 675 def cmpCourses(a, b): 676 if a['level'] < b['level']: 677 return -1 678 if a['level'] > b['level']: 679 return 1 680 if a['mandatory'] != b['mandatory']: 681 if a['mandatory'] == False and b['mandatory'] == True: 682 return -1 683 return 1 684 if a['code'] < b['code']: 685 return -1 686 if a['code'] > b['code']: 687 return 1 688 return 0 689 690 entries = [] 691 levels = dict() 692 for key, course in self.context.items(): 693 certcourse = self.context[key] 694 course = certcourse.course 695 level = certcourse.level 696 mandatory = certcourse.core_or_elective 697 title = course.title 698 code = course.code 699 course_url = self.url(self.context[key]) 700 semester = course.semester 701 702 new_entry = dict( 703 level=level, mandatory=mandatory, url=course_url, 704 title=title, code=code, semester=semester) 705 if str(level) not in levels.keys(): 706 levels[str(level)] = dict() 707 if str(semester) not in levels[str(level)].keys(): 708 levels[str(level)][str(semester)] = [] 709 levels[str(level)][str(semester)].append(new_entry) 710 return levels
Note: See TracChangeset for help on using the changeset viewer.