Пример #1
0
 def __call__(self, context):
     TYPES = {
         _(u"Summer Semester"): 'summer-semester',
         _(u"Winter Semester"): 'winter-semester'
     }
     return SimpleVocabulary([SimpleTerm(value, title=title)
                             for title, value
                             in TYPES.iteritems()])
Пример #2
0
def degree_courses_tokens():
    courses = {
        'ba': _(u"BA"),
        'macon': _(u"MAcons"),
        'ma-ethic': _(u"MA-Ethics"),
        'ma-ib': _(u"MA-IE")
    }
    return courses
Пример #3
0
def degree_courses():
    courses = {
        _(u"BA (Bachelor)"): 'ba',
        _(u"MAcons (Consecutive Master)"): 'macon',
        _(u"MA-Ethics (Continuing Master Ethics)"): 'ma-ethic',
        _(u"MA-IE (Continuing Master Intercultural Education)"): 'ma-ib',
    }
    return courses
Пример #4
0
 def __call__(self, context):
     module_studies = {
         _(u"Philosophicum"): 'philosophicum',
         _(u"Economic Ethics"): 'economic-ethics'
     }
     return SimpleVocabulary([SimpleTerm(value, title=title)
                              for title, value
                              in module_studies.iteritems()])
Пример #5
0
 def __call__(self, context):
     TYPES = {
         _(u"1 hour"): '1-hour',
         _(u"2 hour"): '2-hour',
         _(u"3 hour"): '3-hour',
         _(u"4 hour"): '4-hour'
     }
     return SimpleVocabulary([SimpleTerm(value, title=title)
                             for title, value
                             in TYPES.iteritems()])
Пример #6
0
 def _update_query(self, form_data):
     context = aq_inner(self.context)
     i18n_service = api.portal.get_tool(name="translation_service")
     name = 'course-filter'
     filter_data = form_data
     tool = getUtility(ICourseFilterTool)
     if not self.has_active_session():
         session_token = self.generate_session_token()
         filter_data['token'] = session_token
         stored_data = tool.create_record(session_token, filter_data)
     else:
         session_data = tool.get()
         stored_data = session_data[name]
     updated_filters = stored_data['filter']
     for key, value in form_data.items():
         if key == 'degree-course':
             # Clean possible duplicates
             if not isinstance(value, basestring):
                 updated_filters[key] = list(set(value))
         else:
             updated_filters[key] = value
     if updated_filters:
         stored_data['filter'] = updated_filters
         tool.add(name, stored_data)
     success_message = _(u"Filter successfully updated")
     message = i18n_service.translate(
         success_message,
         'hph.lectures',
         target_language=api.portal.get_default_language()
     )
     api.portal.show_message(message=message,
                             request=self.request,
                             type='info')
     return self.request.response.redirect(context.absolute_url())
Пример #7
0
 def render(self):
     context = aq_inner(self.context)
     tool = getUtility(ICourseFilterTool)
     tool.destroy()
     api.portal.show_message(
         message=_(u"Session cleared"), request=self.request)
     return self.request.response.redirect(context.absolute_url())
Пример #8
0
 def update(self):
     context = aq_inner(self.context)
     self.errors = {}
     unwanted = ('_authenticator', 'form.button.Submit')
     required = ('field-name')
     if 'form.button.Submit' in self.request:
         authenticator = getMultiAdapter((context, self.request),
                                         name=u"authenticator")
         if not authenticator.verify():
             raise Unauthorized
         form = self.request.form
         form_data = {}
         form_errors = {}
         errorIdx = 0
         for value in form:
             if value not in unwanted:
                 form_data[value] = safe_unicode(form[value])
                 if not form[value] and value in required:
                     error = {}
                     error['active'] = True
                     error['msg'] = _(u"This field is required")
                     form_errors[value] = error
                     errorIdx += 1
                 else:
                     error = {}
                     error['active'] = False
                     error['msg'] = form[value]
                     form_errors[value] = error
         if errorIdx > 0:
             self.errors = form_errors
         else:
             self._store_data(form)
Пример #9
0
def course_core_theme_names():
    """
    Core themes for each degree course
    :return: dictionary
    """
    themes = {
        'gn': _('Spirit and Nature (GN)'),
        'rv': _('Religion and Reason (RV)'),
        'eg': _('Ethics and Society (EG)'),
        'wir': _('Business Ethics (WIR)'),
        'med': _('Media Ethics (MED)'),
        'mez': _('Medicine Ethics (MEZ)'),
        'ie': _('Intercultural Education (IE)'),
        'vv': _('International Understanding (VV)'),
        'sc': _('Spiritual Care (SC)'),
        'pb': _('Personal Development (PB)')
    }
    return themes
Пример #10
0
 def prettify_degree(self, value):
     context = aq_inner(self.context)
     vr = getVocabularyRegistry()
     vocab = vr.get(context, 'hph.lectures.CourseDegree')
     title = _(u"undefined")
     if value is not None:
         for term in vocab:
             if term.value == value:
                 title = term.title
     return title
Пример #11
0
 def render(self):
     context = aq_inner(self.context)
     tool = getUtility(ICourseFilterTool)
     session = tool.get()
     session_data = session['course-filter']
     session_data['filters'] = list()
     tool.add('course-filter', session_data)
     api.portal.show_message(
         message=_(u"Session reset"), request=self.request)
     return self.request.response.redirect(context.absolute_url())
Пример #12
0
 def _store_data(self, data):
     item = self.content_item()
     fieldname = self.getFieldname()
     new_value = data['content-editable-form-body']
     setattr(item, fieldname, new_value)
     modified(item)
     item.reindexObject(idxs='modified')
     api.portal.show_message(_(u"The item has successfully been updated"),
                             self.request,
                             type='info')
     return self.request.response.redirect(self.next_url())
Пример #13
0
def module_studies_vocabulary(context):
    """Vocabulary with all available module studies recommendations.
    """
    module_studies_recommendations = {
        _(u"Philosophicum"): 'philosophicum',
        _(u"Module Studies Economic Ethics"): 'economic-ethics',
        _(u"Module Studies Adult Education"): 'adult-education',
        _(u"Module Studies Personal Development"): 'personal-development',
        _(u"Philosophy & Leadership Certificate"):
            'philosophy-leadership-certificate',
        _(u"Module Studies Media Ethics"): 'media-ethics',
        _(u"Module Studies International Understanding"):
            'international-understanding',
        _(u"Global Solidarity"): 'global-solidarity',
        _(u"Module Studies Medicine Ethics"): 'medicine-ethics',
        _(u"Module Studies Spiritual Care"): 'spiritual-care',
    }
    terms = [
        SimpleTerm(value, title=title)
        for title, value in module_studies_recommendations.iteritems()
    ]
    return SimpleVocabulary(terms)
Пример #14
0
def learning_modules_master():
    modules = {
        'I': _(u"I"),
        'II': _(u"II"),
        'III': _(u"III"),
        'IV': _(u"IV"),
        'V': _(u"V"),
        'VI': _(u"VI"),
        'VII': _(u"VII")
    }
    return modules
Пример #15
0
 def applyChanges(self, data):
     container = self.content_item()
     item = api.content.create(
         type='File',
         title=data['title'],
         container=container
     )
     setattr(item, 'description', data['description'])
     setattr(item, 'image', data['image'])
     modified(item)
     item.reindexObject(idxs='modified')
     msg = _(u"The attachment has successfully been added"),
     api.portal.show_message(message=msg, request=self.request)
     return self.request.response.redirect(self.next_url())
Пример #16
0
 def __call__(self, context):
     DEGREES = {
         _(u"BA"): 'ba',
         _(u"MA Ethics"): 'ma-ethics',
         _(u"MA kons"): 'ma-kons',
         _(u"BA"): 'ba',
         _(u"Mag"): 'magister',
         _(u"ZEP"): 'zep',
         _(u"MA-IB"): 'ma-ib'
     }
     return SimpleVocabulary([SimpleTerm(value, title=title)
                             for title, value
                             in DEGREES.iteritems()])
Пример #17
0
 def __call__(self, context):
     TYPES = {
         _(u"Lecture"): 'lecture',
         _(u"Introductory seminar source"): 'introductory-seminar-course',
         _(u"Advanced seminar"): 'advanced',
         _(u"Exercise"): 'exercise',
         _(u"Colloquium"): 'colloquium',
         _(u"Basic module"): 'basic',
         _(u"Reading course"): 'reading'
     }
     return SimpleVocabulary([SimpleTerm(value, title=title)
                             for title, value
                             in TYPES.iteritems()])
Пример #18
0
def course_core_themes():
    """
    Core themes for each degree course
    :return: dictionary
    """
    themes = {
        'macon': {
            'gn': _('GN'),
            'rv': _('RV'),
            'eg': _('EG')
        },
        'ma-ethic': {
            'wir': _('WIR'),
            'med': _('MED'),
            'mez': _('MEZ')
        },
        'ma-ib': {
            'ie': _('IE'),
            'vv': _('VV'),
            'sc': _('SC'),
            'pb': _('PB')
        }
    }
    return themes
Пример #19
0
 def handleApply(self, action):
     data, errors = self.extractData()
     if errors:
         self.status = self.formErrorsMessage
         return
     item = self.content_item()
     schema = ILectureBase
     fields = getFieldsInOrder(schema)
     for key, value in fields:
         try:
             new_value = data[key]
             setattr(item, key, new_value)
         except KeyError:
             continue
     modified(item)
     item.reindexObject(idxs='modified')
     api.portal.show_message(_(u"The item has successfully been updated"),
                             self.request,
                             type='info')
     return self.request.response.redirect(self.next_url())
Пример #20
0
 def render(self):
     context = aq_inner(self.context)
     authenticator = getMultiAdapter((context, self.request),
                                     name=u"authenticator")
     if not authenticator.verify():
         raise Unauthorized
     context_uid = api.content.get_uuid(obj=context)
     item_index_string = self.traverse_subpath[0]
     item_index = int(item_index_string)
     tool = getUtility(ICourseModuleTool)
     stored_data = tool.read(context_uid)
     updated_data = stored_data['items']
     del updated_data[item_index]
     tool.update(context_uid, updated_data)
     next_url = '{0}/@@module-editor?_authenticator={1}'.format(
         context.absolute_url(),
         authenticator.token()
     )
     api.portal.show_message(
         message=_(u"Course module successfully removed"),
         request=self.request)
     return self.request.response.redirect(next_url)
Пример #21
0
 def update(self):
     translation_service = api.portal.get_tool(name="translation_service")
     unwanted = ('_authenticator', 'form.button.Submit')
     required = ('selector_degree_courses', )
     if 'form.button.Submit' in self.request:
         authenticator = getMultiAdapter((self.context, self.request),
                                         name=u"authenticator")
         if not authenticator.verify():
             raise Unauthorized
         form = self.request.form
         form_data = {}
         form_errors = {}
         errorIdx = 0
         for value in form:
             if value not in unwanted:
                 form_data[value] = safe_unicode(form[value])
                 if not form[value] and value in required:
                     error = {}
                     error_msg = _(u"This field is required")
                     error['active'] = True
                     error['msg'] = translation_service.translate(
                         error_msg,
                         'hph.lectures',
                         target_language=api.portal.get_default_language()
                     )
                     form_errors[value] = error
                     errorIdx += 1
                 else:
                     error = {}
                     error['active'] = False
                     error['msg'] = form[value]
                     form_errors[value] = error
         if errorIdx > 0:
             self.errors = form_errors
         else:
             self.add_module_information(form_data)
Пример #22
0
 def render(self):
     context = aq_inner(self.context)
     authenticator = getMultiAdapter((context, self.request),
                                     name=u"authenticator")
     catalog = api.portal.get_tool('portal_catalog')
     obj_provides = ILecture.__identifier__
     courses = catalog(
         object_provides=obj_provides,
         path=dict(query='/'.join(context.getPhysicalPath()),
                   depth=1),
         sort_on='courseNumber'
     )
     for course in courses:
         context_uid = api.content.get_uuid(obj=course.getObject())
         tool = getUtility(ICourseModuleTool)
         stored_data = tool.read(context_uid)
         learning_modules = self.learning_modules_bachelor()
         if 'items' in stored_data:
             updated_data = stored_data['items']
             for item in updated_data:
                 if 'degree-course' in item:
                     module_name = item['module']
                     for key, value in learning_modules.items():
                         if value == module_name:
                             item['module'] = key
                     if module_name == 'WP Culturel Admission':
                         item['module'] = 'wp-cultural-admission'
             tool.update(context_uid, updated_data)
     next_url = '{0}?_authenticator={1}'.format(
         context.absolute_url(),
         authenticator.token()
     )
     api.portal.show_message(
         message=_(u"Course module storages successfully cleaned"),
         request=self.request)
     return self.request.response.redirect(next_url)
Пример #23
0
def learning_modules_bachelor():
    """
    Vocabulary for learning module selection
    :return: dictionary of modules
    """
    modules = {
        'I/1':  _(u"I/1"),
        'I/2': _(u"I/2"),
        'I/3':  _(u"I/3"),
        'I/4':  _(u"I/4"),
        'I/5':  _(u"I/5"),
        'I/6':  _(u"I/6"),
        'II/1': _(u"II/1"),
        'II/2': _(u"II/2"),
        'II/3': _(u"II/3"),
        'II/4': _(u"II/4"),
        'II/5': _(u"II/5"),
        'II/6': _(u"II/6"),
        'III/1': _(u"III/1"),
        'III/2': _(u"III/2"),
        'IV/1': _(u"IV/1"),
        'IV/2': _(u"IV/2"),
        'wp-theology': _(u"WP Theology"),
        'wp-cultures': _(u"WP Cultures"),
        'wp-globalization': _(u"WP Globalization"),
        'wp-environmental-ethics': _(u"WP Environmental Ethics"),
        'wp-nature-philosophy': _(u"WP Nature Philosophy"),
        'wp-logic': _(u"WP Logic"),
        'wp-media': _(u"WP Media"),
        'wp-cultural-admission': _(u"WP Cultural Admission"),
        'wp-education': _(u"WP Education"),
        'wp-internship': _(u"WP Internship"),
    }
    return modules
Пример #24
0
 def handleCancel(self, action):
     msg = _(u"Attachement edit has been cancelled.")
     api.portal.show_message(message=msg, request=self.request)
     return self.request.response.redirect(self.next_url())
Пример #25
0
 def handleCancel(self, action):
     msg = _(u"Content item factory has been cancelled.")
     api.portal.show_message(msg, self.request, type='info')
     return self.request.response.redirect(self.next_url())