def delete(self):
     id_del_orga = self.request.form.get('del')
     if not delete_orga(self.session, id_del_orga):
         msg = _(u'no id fund for delete a organization')
         self.logger.info(msg)
         IStatusMessage(self.request).add(msg, type="error")
         return self.request.response.redirect("{0}/organizations_manage".format(self.context.absolute_url()))
     msg = _(u"The organization is deleted")
     IStatusMessage(self.request).add(msg, type="info")
     return self.request.response.redirect("{0}/organizations_manage".format(self.context.absolute_url()))
예제 #2
0
    def get_list(self):
        """ return a list with the true attributes (without other attribut.)"""
        categories = []
        for attribut in self.attributes:
            attr = getattr(self, attribut, False)
            if attr is True:
                categories.append(attribut)
        if getattr(self, 'education') is True:
            categories.append(_(u'education'))
        if getattr(self, 'training') is True:
            categories.append(_(u'training'))
        if getattr(self, 'tutoring') is True:
            categories.append(_(u'tutoring'))

        return categories
    def handleSubmit(self, action):
        data, errors = self.extractData()
        if not errors:
            session = Session()
            searched_categories = data.get('categories')
            search = data.get('search')
            if search == None:
                search = u""
            request = session.query(Organization)
            if search:
                additionalinformations = session.query(AdditionalInformation).filter(func.lower(AdditionalInformation.objectif).like(u'%{0}%'.format(search).lower())).all()
                request = request.filter(or_
                        (func.lower(Organization.name).like(u'%{0}%'.format(search).lower()),
                        (Organization.organization_id.in_([addit.organization_id for addit in additionalinformations]))))

            for categorie in searched_categories:
                if categorie == 'enseignement_formation':
                    request = request.filter(
                                    or_(Organization.category.has(getattr(Category, 'tutoring') == True),
                                    Organization.category.has(getattr(Category, 'training') == True),
                                    Organization.category.has(getattr(Category, 'education') == True)))
                else:
                    request = request.filter(Organization.category.has(getattr(Category, categorie) == True))
            request = request.filter(Organization.language == self.context.Language())
            request = request.order_by(Organization.name)
            self.searched_categories = searched_categories
            self.results = request.all()
            if len(self.results) == 0:
                self.status = _(u"No organization found.")
            else:
                self.request.SESSION.set(SESSION_SEARCH, self.results)
                self.request.SESSION.set(SESSION_CATEGORIES, self.searched_categories)
                self.request.response.redirect('organizations_search?search_term={0}'.format(search.encode('utf8')))
 def search_name(self, search):
     session = Session()
     request = session.query(Organization)
     request = request.filter(func.lower(Organization.name).like(u'{0}'.format(search).lower()))
     request = request.filter(Organization.language == self.context.Language())
     request = request.order_by(Organization.name)
     self.results = request.all()
     if len(self.results) == 0:
         self.status = _(u"No organization found.")
def renderCategoryButton(context, name, selected=None):
    render = []
    render.append(u'<div class="categorie-inputs')
    if selected:
        render.append(u' selected')
    render.append(u'">\n<input id="form-buttons-{0}" name="form.buttons.{0}" class="image-widget categorybutton-field'.format(name))
    if selected:
        render.append(u' selected" src="{1}/++resource++{0}-select.png"'.format(str(name), context.portal_url()))
    else:
        render.append(u'" src="{1}/++resource++{0}.png"'.format(name, context.portal_url()))
    render.append(u'" value="{0}" type="image"'.format(context.translate(name)))

    if name == "enseignement_formation":
        msgid = _(u"alt_enseignement_formation")
        render.append(u' title="{0}"'.format(context.translate(msgid)))
    elif name == "health":
        msgid = _(u"alt_health")
        render.append(u' title="{0}"'.format(context.translate(msgid)))
    else:
        render.append(u' title="{0}"'.format(context.translate(name)))
    render.append(u' alt="{0}" /><div class="bottominputcategory">{0}</div></div>\n\n'.format(context.translate(name)))
    return "".join(render)
    def handleCategoriesButton(self, form, action):
        form.widgets.get('search').value = u""
        session = Session()
        self.searched_categories = action.value
        if action.value == 'enseignement_formation':
            self.results = session.query(Organization).filter(or_(Organization.category.has(getattr(Category, 'tutoring') == True),
                                                   Organization.category.has(getattr(Category, 'training') == True),
                                                   Organization.category.has(getattr(Category, 'education') == True) )).filter(Organization.language == self.context.Language()).order_by(Organization.name).all()

        else:
            self.results = session.query(Organization).filter(Organization.category.has(getattr(Category, action.value) == True)).filter(Organization.language == self.context.Language()).order_by(Organization.name).all()
        if len(self.results) == 0:
            self.status = _(u"No organization found.")
    def input_categories(self):
        categories = []
        already_enseignement_formation = False
        for cat in self.context.get_categories_without_other():
            attr = getattr(Category, cat, False)
            if attr:
                if cat == "education" or cat == "training" or cat == "tutoring":
                    if not already_enseignement_formation:
                        categories.append(renderCategoryButton(self.context, _(u'enseignement_formation')))
                        already_enseignement_formation = True
                else:
                    categories.append(renderCategoryButton(self.context, cat))

        return categories
    def search(self, search):
        session = Session()
        request = session.query(Organization)
        additionalinformations = session.query(AdditionalInformation).filter(func.lower(AdditionalInformation.objectif).like(u'{0}'.format(search).lower())).all()

        request = request.filter(or_
                (func.lower(Organization.name).like(u'{0}'.format(search).lower()),
                (Organization.organization_id.in_([addit.organization_id for addit in additionalinformations]))))

        request = request.filter(Organization.language == self.context.Language())
        request = request.order_by(Organization.name)

        self.results = request.all()
        if len(self.results) == 0:
            self.status = _(u"No organization found.")
예제 #9
0
    search = schema.TextLine(title=_(u'Search'), description=_(u"Search with organization name, objectif, activity type or tagert public."), required=False)
    categories = schema.List(
            title=_(u"Categories"),
            description=_(u"Catégories d'activité"),
            value_type=schema.Choice(values=categories()),
            required=False)


class Terms(vocabulary.SimpleVocabulary):
    zope.interface.implements(interfaces.ITerms)

    def getValue(self, token):
        return self.getTermByToken(token).value

STATUS = Terms([
    Terms.createTerm('asbl', 'asbl', _(u'ASBL')),
    Terms.createTerm('sprl', 'sprl', _(u'SPRL')),
    Terms.createTerm('pouvoirpublique', 'pouvoirpublique', _(u'Pouvoir Publique')),
    Terms.createTerm('other', 'autres', _(u'Autres')),
    ])

LANG = Terms([
    Terms.createTerm('fr', 'fr', _(u'Français')),
    Terms.createTerm('nl', 'nl', _(u'Néerlandais')),
    ])


class IOrganizations(Interface):
    """
    Organizations view interface
    """