Changeset 2500 for WAeUP_SRP


Ignore:
Timestamp:
2 Nov 2007, 07:51:45 (17 years ago)
Author:
joachim
Message:

put back in mass_create_course_result

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/base/WAeUPTool.py

    r2496 r2500  
    11341134    ###)
    11351135
     1136    security.declareProtected(ModifyPortalContent,'mass_create_course') ###(
     1137    def mass_create_course(self,mapping):
     1138        #import pdb;pdb.set_trace()
     1139        if getattr(self,'_v_course_list',None) is None:
     1140            self._v_course_list = []
     1141        if getattr(self,'_v_departments',None) is None:
     1142            res = self.portal_catalog(portal_type = "Department")
     1143            self._v_department_courses = {}
     1144            for d in res:
     1145                self._v_department_courses[d.getId] = getattr(d.getObject(),"courses",None)
     1146        did = mapping['department_code']
     1147        d = self._v_department_courses.get(did,None)
     1148        if d is None:
     1149            return '', "No Department with ID: %s" % did
     1150        course_id = mapping.get('code')
     1151        if course_id in self._v_course_list:
     1152            return '', "Duplicate Course ID: %s" % did
     1153        c = getattr(d,course_id,None)
     1154        if c is not None:
     1155            return '', "Duplicate Course ID: %s" % did
     1156        try:
     1157            d.invokeFactory('Course', course_id)
     1158        except BadRequest,E:
     1159            return '', "%s" % E
     1160        self._v_course_list.append(course_id)
     1161        c = getattr(d,course_id)
     1162        c.getContent().edit(mapping=mapping)
     1163        return course_id,''
     1164    ###)
     1165
     1166
     1167    security.declareProtected(ModifyPortalContent,'mass_edit_course_result') ###(
     1168    def mass_edit_course_result(self,mapping):
     1169        #import pdb;pdb.set_trace()
     1170        # if getattr(self,'_v_courses',None) is None:
     1171        #     res = self.courses_catalog()
     1172        #     self._v_courses = {}
     1173        #     for brain in res:
     1174        #         self._v_courses[brain.code] = brain
     1175        # course_id = mapping.get('code')
     1176        # if course_id not in self._v_courses.keys():
     1177        #     return '', "No course with ID: %s" % did
     1178        id_key = ''
     1179        for id_key in ('student_id','matric_no'):
     1180            id_field = mapping.get(id_key,None)
     1181            if id_field is not None:
     1182                student_id = id_field
     1183                break
     1184        query = Eq(id_key,id_field)
     1185        res = self.students_catalog.evalAdvancedQuery(query)
     1186        if not res:
     1187            return '', "No student with %(id_field)s: %(id_key)s" % vars()
     1188        if id_field != "student_id":
     1189            mapping['student_id'] = res[0].id
     1190        mapping['key'] = key = "%(student_id)s|%(level_id)s|%(code)s" % mapping
     1191        # for k in ('semester',):
     1192        #     mapping[k] = getattr(self._v_courses[course_id],k)
     1193        try:
     1194            self.course_results.modifyRecord(**mapping)
     1195        except KeyError:
     1196            return '', "No course result to edit: %s" % key
     1197        return key,''
     1198    ###)
     1199
    11361200    security.declareProtected(ModifyPortalContent,'mass_create_certificate_course') ###(
    11371201    def mass_create_certificate_course(self,mapping):
     
    15561620                filename = os.path.join(images_dir,"%(key)s_%(student_id)s.jpg" % vars())
    15571621                open(filename,"wb").write(str(image.data))
     1622    ###)
    15581623
    15591624    security.declareProtected(ModifyPortalContent,"movePassportToFS")###(
     
    15861651                filename = os.path.join(images_dir,"%(student_id)s.jpg" % vars())
    15871652                open(filename,"wb").write(str(image.data))
     1653    ###)
    15881654
    15891655InitializeClass(WAeUPTool)
Note: See TracChangeset for help on using the changeset viewer.