Esempio n. 1
0
class IRICOrganization(model.Schema):

    citizen = schema.Int(
        title=_(u"Nombre d'habitants"),
        required=True,
        min=1
    )

    #servers = schema.TextLine(
    #    title=_(u"Serveurs"),
    #    required=True
    #)

    #softwares = schema.TextLine(
    #    title=_(u"Logiciels"),
    #    required=True
    #)

    subscriptions = schema.List(
        title=_(u"Cotisations"),
        value_type=DictRow(title=_(u"Cotisation"),
                           schema=ICotisationRow),
        required=False,
    )
    form.read_permission(subscriptions='RIC.ActualOrganizationMember')
    form.write_permission(subscriptions='RIC.Administrator')
    form.widget('subscriptions', DataGridField)
Esempio n. 2
0
class ICotisationRow(model.Schema):

    year = schema.Int(title=_(u"Année"),
                      required=True)

    payment = schema.Bool(title=_(u"Versement"),
                          required=True)
Esempio n. 3
0
class IRICPerson(model.Schema):

    functions = schema.List(
        title=_(u"Fonctions"),
        description=_(u"Vous pouvez sélectionner plusieurs fonctions en appuyant sur la touche CTRL"),
        required=True,
        value_type=schema.Choice(source=FunctionsList),
    )
    form.widget('functions', SelectFieldWidget, multiple='multiple', size=3)

    invalidmail = schema.Bool(title=_(u"E-mail invalide"),
                              required=True)

    form.read_permission(invalidmail='RIC.ActualPersonOwner')
    form.write_permission(invalidmail='RIC.Administrator')
    form.widget('invalidmail', RadioFieldWidget)

    multimail = schema.List(title=_(u"Envoi mail"),
                            required=False,
                            value_type=schema.Choice(source=MultimailTypes()),
                            )
    form.widget('multimail', SelectFieldWidget, multiple='multiple', size=2)

    userid = schema.TextLine(title=_(u"Identifiant de l'utilisateur"),
                             required=False)

    form.read_permission(userid='RIC.Administrator')
    form.write_permission(userid='RIC.Administrator')
Esempio n. 4
0
class RecipientsSubstitution(BaseSubstitution):
    adapts(IDublinCore)

    category = u'RIC'
    description = _(u'Destinataires')

    def safe_call(self):
        return ', '.join(self.context.recipients)
Esempio n. 5
0
 def _notify(event):
     """
     Notify event
     """
     try:
         notify(event)
     except:
         raise(Exception(_(u"Un problème est survenu lors de l'envoi de l'e-mail")))
Esempio n. 6
0
 def _notify(event):
     """
     Notify event
     """
     try:
         notify(event)
     except:
         raise (Exception(
             _(u"Un problème est survenu lors de l'envoi de l'e-mail")))
Esempio n. 7
0
    def update(self):
        filter = self.request.get('filter') or None
        if not filter:
            return

        recipients = self.send_mail(filter)
        message = _(u"E-mail envoyé à")
        message = '%s: %s' % (message, ', '.join(recipients))
        show_message(message, self.request, type='info')
Esempio n. 8
0
    def update(self):
        filter = self.request.get('filter') or None
        if not filter:
            return

        recipients = self.send_mail(filter)
        message = _(u"E-mail envoyé à")
        message = '%s: %s' % (message, ', '.join(recipients))
        show_message(message, self.request, type='info')
Esempio n. 9
0
# -*- coding: utf-8 -*-

from zope.interface import implements
from zope.schema.interfaces import IVocabularyFactory
from zope.schema.interfaces import IBaseVocabulary
from zope.schema.vocabulary import SimpleTerm
from zope.schema.vocabulary import SimpleVocabulary

from ric.core import RICMessageFactory as _


CONTENTS = {'organization': _('Une organisation'),
            'person': _('Une personne')}


class Contents(object):
    """
    Vocabulary of contents to search on
    """
    implements(IVocabularyFactory)

    def __call__(self, context):
        items = [SimpleTerm(key, key, item) for key, item in\
                 CONTENTS.items()]
        return SimpleVocabulary(items)

ContentsVocabularyFactory = Contents()
Esempio n. 10
0
class RICSearchForm(form.Form):

    fields = field.Fields(IRICSearch)
    label = _(u"Recherche dans l'annuaire du RIC")
    template = ViewPageTemplateFile('templates/search.pt')
    ignoreContext = True
    _data = None
    canSearch = 0
    # 0 : cannot search
    # 1 : cannot search, no profile
    # 2 : cannot search because contacts aren't completed
    # 3 : can search, all is good
    personsToComplete = []
    organizationsToComplete = []
    persons = []
    organizations = []

    def update(self):
        self.personsToComplete = []
        self.organizationsToComplete = []
        self.persons = []
        self.organizations = []

        if api.user.is_anonymous():
            self.request.response.redirect("%s/@@nosearch" %
                                           self.context.absolute_url())
            return ''
        user = api.user.get_current()
        if user.has_role('Manager') or api.user.has_permission(
                'RIC: Administer website', user=user):
            self.canSearch = 3
        else:
            self.persons = getMultiAdapter(
                (self.context, self.request),
                name="get_persons_for_user")(userName=user.getUserName())
            # if user has a profile
            if self.persons:
                for person in self.persons:
                    isCompleted = getMultiAdapter(
                        (person, self.request), name="is_profile_completed")()
                    if not isCompleted:
                        self.personsToComplete.append(person)

                self.organizations = getMultiAdapter(
                    (self.context, self.request),
                    name="get_organizations_for_user")()
                for organization in self.organizations:
                    isCompleted = getMultiAdapter(
                        (organization, self.request),
                        name="is_profile_completed")()
                    if not isCompleted:
                        self.organizationsToComplete.append(organization)

                if not self.personsToComplete and not self.organizationsToComplete:
                    self.canSearch = 3
                else:
                    self.canSearch = 2
            else:
                self.canSearch = 1

        super(RICSearchForm, self).update()

    @button.buttonAndHandler(_(u'Rechercher'))
    def handleSave(self, action):
        data, errors = self.extractData()
        if errors:
            return False
        self._data = data

    def getResults(self):
        if self._data is None:
            return None
        form = self._data
        contentType = form.get('contentType')
        contentName = form.get('contentName')
        contentName = '*%s*' % contentName
        catalog = api.portal.get_tool('portal_catalog')
        brains = catalog.searchResults(portal_type=contentType,
                                       Title=contentName)[:20]
        return brains
Esempio n. 11
0
# -*- coding: utf-8 -*-

from zope.interface import implements
from zope.schema.interfaces import IVocabularyFactory
from zope.schema.interfaces import IBaseVocabulary
from zope.schema.vocabulary import SimpleTerm
from zope.schema.vocabulary import SimpleVocabulary

from ric.core import RICMessageFactory as _

CONTENTS = {'organization': _('Une organisation'), 'person': _('Une personne')}


class Contents(object):
    """
    Vocabulary of contents to search on
    """
    implements(IVocabularyFactory)

    def __call__(self, context):
        items = [SimpleTerm(key, key, item) for key, item in\
                 CONTENTS.items()]
        return SimpleVocabulary(items)


ContentsVocabularyFactory = Contents()
Esempio n. 12
0
class IRICSearch(Interface):

    contentType = Choice(title=_(u"Rechercher"),
                         vocabulary="ric.search.contents")

    contentName = TextLine(title=_(u"Nom à rechercher"), required=True)