Changeset 2609 for WAeUP_SRP/base/skins


Ignore:
Timestamp:
9 Nov 2007, 15:38:22 (17 years ago)
Author:
joachim
Message:

ti_391 now uses students_catalog, use levels vocabulary for study-level in academics

Location:
WAeUP_SRP/base/skins
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/base/skins/waeup_academics/getLevelInfo.py

    r2281 r2609  
    3232info['choosen_ids'] = request.get('ids',[])
    3333info['doc'] = context.getContent()
    34 brain = context.portal_catalog(meta_type="Certificate",id = cert_id)[-1]
    35 cp = brain.getPath()
    36 info['container_path'] = cp
     34# brain = context.portal_catalog(meta_type="Certificate",id = cert_id)[-1]
     35# cp = brain.getPath()
     36# info['container_path'] = cp
    3737info['dep_id'] = dep_id
    3838info['cert_id'] = cert_id
    3939
    40 res = context.portal_catalog(meta_type="CertificateCourse", container_path="%s/%s" % (cp,level_id))
     40# res = context.portal_catalog(meta_type="CertificateCourse", container_path="%s/%s" % (cp,level_id))
     41# first = []
     42# second = []
     43# for r in res:
     44#     row = {}
     45#     ro = r.getObject()
     46#     rd = ro.getContent()
     47#     course_id = r.getId
     48#     row = context.getCourseInfo(course_id)
     49#     row['id'] = course_id
     50#     # row['title'] = rd.Title()
     51#     # row['semester'] = rd.semester
     52#     row['core'] = rd.core_or_elective
     53#     row['url'] = ro.absolute_url()
     54#     row['review_state'] = wf.getInfoFor(ro,'review_state','None')
     55#     editable = row['is_editable'] = mtool.checkPermission('Modify portal content', ro)
     56#     if editable:
     57#         row['real_course_path'] = "%s/%s/%s/courses/%s" % (academics_path,
     58#                                                            row['faculty'],
     59#                                                            row['department'],
     60#                                                            course_id)
     61#     if row['semester'] == 1:
     62#         first.append(row)
     63#     else:
     64#         second.append(row)
    4165first = []
    4266second = []
    43 for r in res:
     67for course_id,course in context.objectItems():
    4468    row = {}
    45     ro = r.getObject()
    46     rd = ro.getContent()
    47     course_id = r.getId
     69    # ro = r.getObject()
     70    course_doc = course.getContent()
     71    # course_id = r.getId
    4872    row = context.getCourseInfo(course_id)
    4973    row['id'] = course_id
    50     # row['title'] = rd.Title()
    51     # row['semester'] = rd.semester
    52     row['core'] = rd.core_or_elective
    53     row['url'] = ro.absolute_url()
    54     row['review_state'] = wf.getInfoFor(ro,'review_state','None')
    55     editable = row['is_editable'] = mtool.checkPermission('Modify portal content', ro)
     74    # row['title'] = course_doc.Title()
     75    # row['semester'] = course_doc.semester
     76    row['core'] = course_doc.core_or_elective
     77    row['url'] = course.absolute_url()
     78    row['review_state'] = wf.getInfoFor(course,'review_state','None')
     79    editable = row['is_editable'] = mtool.checkPermission('Modify portal content', course)
    5680    if editable:
    5781        row['real_course_path'] = "%s/%s/%s/courses/%s" % (academics_path,
  • WAeUP_SRP/base/skins/waeup_utilities/ti_391_resolve.py

    r2605 r2609  
    2828from Products.AdvancedQuery import Eq, Between, Le,In
    2929aq_portal = context.portal_catalog_real.evalAdvancedQuery
     30students_folder = context.portal_url.getPortalObject().campus.students
    3031
    3132request = context.REQUEST
     
    3940#logger.info('')
    4041
    41 query = Eq('portal_type','StudentPersonal')
    42 #brains = context.students_catalog()
    43 brains = aq_portal(query)
     42#query = Eq('portal_type','StudentPersonal')
     43#brains = aq_portal(query)
     44brains = context.students_catalog()
    4445total = len(brains)
    4546#rwrite("found %d " % total)
     
    4748edited = 0
    4849count = 0
     50commit_after = 50
    4951logger.info('started for %d' % total)
    5052for brain in brains:
    5153    count += 1
    52     doc = brain.getObject().getContent()
    53     if doc.email and doc.email.find('@') < 0:
     54    if no_email and not no_email % commit_after:
     55        context.waeup_tool.doCommit()
     56        logger.info("Committing %s transactions, total %s" % (commit_after,count))
     57    if not brain.email or brain.email.find('@') < 0:
    5458        no_email += 1
    55         #rwrite ("%s email = %s" % (brain.getId,doc.email))
    5659        try:
    57             app_doc = getattr(brain.getObject().aq_parent,'application').getContent()
    58             logger.info("setting email of %s from %s to %s" % (brain.getPath().split('/')[-2],
    59                                                                doc.email,
    60                                                                app_doc.app_email))
    61             doc.edit(mapping={'email': app_doc.app_email})
    62             edited += 1
     60            app_doc = getattr(getattr(students_folder,brain.id),'application').getContent()
     61            #rwrite ("%s email = %s" % (brain.getId,doc.email))
    6362        except:
    64             logger.info("failed to set email of %s from %s" % (brain.getPath().split('/')[-2],
    65                                                                doc.email,
    66                                                                ))
    67             pass
     63            logger.info("failed to get application object of %s" % (brain.id,))
     64            continue
     65        if not app_doc.app_email or app_doc.app_email.find('@') < 0:
     66            logger.info("%s both emails %s/%s are invalid" % (brain.id,
     67                                                              app_doc.app_email,
     68                                                              brain.email))
     69            continue
     70        try:
     71            per_doc = getattr(getattr(students_folder,brain.id),'personal').getContent()
     72            #rwrite ("%s email = %s" % (brain.getId,doc.email))
     73        except:
     74            logger.info("failed to get personal object of %s" % (brain.id,))
     75            continue
     76        logger.info("setting email of %s from %s to %s" % (brain.id,
     77                                                            per_doc.email,
     78                                                            app_doc.app_email))
     79        per_doc.edit(mapping={'email': app_doc.app_email})
     80        edited += 1
    6881    else:
    6982        #rwrite ("%s email = %s" % (brain.getPath(),doc.email))
Note: See TracChangeset for help on using the changeset viewer.