예제 #1
0
    def __call__(self):
        # http://localhost:8080/Plone/ca/eetac/organ/session/changeTitle?pk=OLD_ID&name=&value=NEW_ID
        try:
            origin_path = '/'.join(
                self.context.getPhysicalPath()) + '/' + self.request.form['pk']
            newvalue = self.request.form['value']
        except:
            return None

        try:
            entry = api.content.find(path=origin_path, depth=0)[0]
            old_id = entry.id
            entryobj = entry.getObject()
            container = entryobj.aq_parent
            chooser = INameChooser(container)
            new_id = chooser.chooseName(newvalue, entryobj)
            change_str = entryobj.absolute_url(
            ) + ' - [' + entry.Title + ' → ' + newvalue + ']'
            with api.env.adopt_roles(['OG1-Secretari']):
                container.manage_renameObject(old_id, new_id)

            newObject = api.content.find(id=new_id,
                                         path='/'.join(
                                             origin_path.split('/')[:-1]))[0]
            newobj = newObject.getObject()
            newobj.title = newvalue
            newobj.reindexObject()

            # transaction ok, then write log
            addEntryLog(self.context, None, _(u"Changed Title"), change_str)
            # This line is only to bypass the CSRF WARNING
            # WARNING plone.protect error parsing dom, failure to add csrf token to response for url ...
            return "Changed Title"
        except:
            pass
예제 #2
0
 def render(self):
     if self.context.estatVotacio == 'close':
         self.context.estatVotacio = 'open'
         self.context.reindexObject()
         transaction.commit()
         addEntryLog(self.context.__parent__.__parent__, None,
                     _(u'Reoberta votacio esmena'),
                     self.context.__parent__.absolute_url())
예제 #3
0
 def render(self):
     self.context.estatVotacio = 'close'
     self.context.horaFiVotacio = datetime.datetime.now().strftime(
         '%d/%m/%Y %H:%M')
     self.context.reindexObject()
     transaction.commit()
     addEntryLog(self.context.__parent__, None, _(u'Tancada votacio acord'),
                 self.context.absolute_url())
예제 #4
0
 def render(self):
     self.context.estatVotacio = 'open'
     self.context.tipusVotacio = 'public'
     self.context.horaIniciVotacio = datetime.datetime.now().strftime(
         '%d/%m/%Y %H:%M')
     self.context.reindexObject()
     transaction.commit()
     addEntryLog(self.context.__parent__, None, _(u'Oberta votacio acord'),
                 self.context.absolute_url())
예제 #5
0
    def render(self):
        estatSessio = utils.session_wf_state(self)
        if estatSessio not in ['realitzada', 'tancada', 'en_correccio']:
            sendRemoveVoteEmail(self.context)

        parent = self.context.aq_parent
        parent.manage_delObjects([self.context.getId()])
        transaction.commit()
        addEntryLog(self.context.__parent__.__parent__, None,
                    _(u'Eliminada votacio esmena'),
                    self.context.__parent__.absolute_url())
예제 #6
0
    def action_send(self, action):
        """ Send the email to the configured mail address
            in properties and redirect to the
            front page, showing a status message to say
            the message was received. """
        formData, errors = self.extractData()
        lang = self.context.language
        if 'recipients' not in formData or 'fromTitle' not in formData or 'message' not in formData:
            if lang == 'ca':
                message = "Falten camps obligatoris: "
            if lang == 'es':
                message = "Faltan campos obligatorios: "
            if lang == 'en':
                message = "Required fields missing: "
            IStatusMessage(self.request).addStatusMessage(message, type="error")
            return
        # replace hidden fields to maintain correct urls...
        body = formData['message'].replace('----@@----http:/', 'http://').replace('----@@----https:/', 'https://').encode('utf-8')

        root_url = api.portal.get().absolute_url() + "/" + lang
        body = body.replace('resolveuid/', root_url + "/resolveuid/")

        sender = self.context.aq_parent.fromMail
        try:
            self.context.MailHost.send(
                body,
                mto=formData['recipients'],
                mfrom=sender,
                subject=formData['fromTitle'],
                encode=None,
                immediate=False,
                charset='utf8',
                msg_type='text/html')

            api.content.transition(obj=self.context, transition='convocar')
            addEntryLog(self.context, None, _(u'Sending mail convocatoria'), formData['recipients'])
            self.context.plone_utils.addPortalMessage(
                _(u"Missatge enviat correctament"), 'info')
        except:
            addEntryLog(self.context, None, _(u'Missatge no enviat'), formData['recipients'])
            self.context.plone_utils.addPortalMessage(
                _(u"Missatge no enviat. Comprovi els destinataris del missatge"), 'error')

        session = self.context
        session.membresConvocats = formData['membresConvocats']
        session.membresConvidats = formData['membresConvidats']
        session.adrecaAfectatsLlista = formData['adrecaAfectatsLlista']
        session.adrecaLlista = formData['recipients']
        session.reindexObject()
        transaction.commit()

        return self.request.response.redirect(self.context.absolute_url())
예제 #7
0
    def render(self):
        estatSessio = utils.session_wf_state(self)
        if estatSessio not in ['realitzada', 'tancada', 'en_correccio']:
            sendRemoveVoteEmail(self.context)

        self.context.estatVotacio = None
        self.context.tipusVotacio = None
        self.context.infoVotacio = '{}'
        self.context.horaIniciVotacio = None
        self.context.horaFiVotacio = None
        self.context.reindexObject()
        transaction.commit()
        addEntryLog(self.context.__parent__, None,
                    _(u'Eliminada votacio acord'), self.context.absolute_url())
예제 #8
0
 def render(self):
     if 'title' in self.request.form and self.request.form[
             'title'] and self.request.form['title'] != '':
         item = createContentInContainer(self.context,
                                         "genweb.organs.votacioacord",
                                         title=self.request.form['title'])
         item.estatVotacio = 'open'
         item.tipusVotacio = 'public'
         item.horaIniciVotacio = datetime.datetime.now().strftime(
             '%d/%m/%Y %H:%M')
         item.reindexObject()
         transaction.commit()
         addEntryLog(self.context.__parent__, None,
                     _(u'Oberta votacio esmena'),
                     self.context.absolute_url())
예제 #9
0
def remove_subpunt(trans, obj=None, parent=None):
    portal_catalog = api.portal.get_tool(name='portal_catalog')
    items = portal_catalog.searchResults(
        portal_type=['genweb.organs.subpunt', 'genweb.organs.acord'],
        sort_on='getObjPositionInParent',
        path={
            'query': parent.absolute_url_path(),
            'depth': 1
        })
    index = 1
    # Assign proposalPoints to acord and subpunts
    if items:
        sufix = str(items[0].proposalPoint).split('.')[0]
        for item in items:
            newobjecte = item.getObject()
            newobjecte.proposalPoint = str(sufix) + str('.') + str(index)
            index = index + 1
        addEntryLog(obj.aq_parent.aq_parent, None, _(u'Deleted subpunt'),
                    str(obj.Title()))
        transaction.commit()
예제 #10
0
def sessio_changed(session, event):
    """ If organs.session change WF to convoque, sends email and
        shows the info in the template
    """
    # si passem estat a convocat cal enviar mail de convocatoria...
    try:
        # old = _GW(event.status['review_state'])
        new = _GW(event.transition.new_state_id)
        # message = (old) + ' →2 ' + (new)
        addEntryLog(session, None, _(u'Changed workflow state'), new)  # add log
    except:
        addEntryLog(session, None, _(u'New session created'), session.Title())  # add log

    if event.transition is None:
        # Quan crees element també executa aquesta acció, i ID no existeix
        # Fem el bypass
        pass
    else:
        """ Previ a l'enviament del missatge et troves en un estat intermig,
            creat només per això, que es diu Convocant (no es veu enlloc)
        """
        if event.transition.id == 'convocant':
            raise Redirect(session.absolute_url() + '/mail_convocar')

        if event.transition.id == 'tancar':
            member = api.user.get(username='******')
            user = member.getUser()
            session.changeOwnership(user, recursive=False)
            owners = session.users_with_local_role("Owner")
            session.manage_delLocalRoles(owners)
            if user.getId() == 'admin':
                session.manage_setLocalRoles(user.getId(), ["Owner"])
            else:
                session.manage_setLocalRoles(user._id, ["Owner"])
            session.reindexObjectSecurity()
            transaction.commit()
예제 #11
0
def remove_punt_acord(trans, obj=None, parent=None):
    """ Removing punt i subpunt is the same """
    portal_catalog = api.portal.get_tool(name='portal_catalog')
    items = portal_catalog.searchResults(portal_type=[
        'genweb.organs.punt', 'genweb.organs.acord', 'genweb.organs.subpunt'
    ],
                                         sort_on='getObjPositionInParent',
                                         path={
                                             'query':
                                             parent.absolute_url_path(),
                                             'depth': 1
                                         })
    index = 1
    sufix = None
    # check if second level to assign index value
    if obj.aq_parent.portal_type == 'genweb.organs.punt' or obj.aq_parent.portal_type == 'genweb.organs.acord':
        sufix = obj.aq_parent.proposalPoint

    for item in items:
        objecte = item.getObject()
        if sufix:
            objecte.proposalPoint = str(sufix) + str('.') + str(index)
        else:
            objecte.proposalPoint = index

        if len(objecte.items()) > 0:
            search_path = '/'.join(objecte.getPhysicalPath())
            values = portal_catalog.searchResults(
                portal_type=[
                    'genweb.organs.punt', 'genweb.organs.subpunt',
                    'genweb.organs.acord'
                ],
                sort_on='getObjPositionInParent',
                path={
                    'query': search_path,
                    'depth': 1
                })
            subvalue = 1
            for value in values:
                newobjecte = value.getObject()
                if sufix:
                    newobjecte.proposalPoint = str(sufix) + str('.') + str(
                        subvalue)
                else:
                    newobjecte.proposalPoint = str(index) + str('.') + str(
                        subvalue)
                subvalue = subvalue + 1
        index = index + 1

    if obj.aq_parent.portal_type == 'genweb.organs.punt':
        if obj.portal_type == 'genweb.organs.acord':
            addEntryLog(obj.aq_parent.aq_parent, None, _(u'Deleted acord'),
                        str(obj.Title()))
    else:
        if obj.portal_type == 'genweb.organs.acord':
            addEntryLog(obj.aq_parent, None, _(u'Deleted acord'),
                        str(obj.Title()))
        else:
            addEntryLog(obj.aq_parent, None, _(u'Deleted punt'),
                        str(obj.Title()))
    transaction.commit()
예제 #12
0
def puntAdded(content, event):
    """ Punt added handler """
    addEntryLog(content.__parent__, None, _(u'Created punt'), str(content.Title()))
예제 #13
0
def subpuntAdded(content, event):
    """ Punt added handler """
    addEntryLog(content.aq_parent.aq_parent, None, _(u'Created subpunt'), str(content.Title()))
예제 #14
0
def actaAdded(content, event):
    """ Acta added handler """
    addEntryLog(content.__parent__, None, _(u'Created acta'), str(content.Title()))
예제 #15
0
def subpuntModified(content, event):
    """ Subpunt modify handler """
    if event.descriptions != ():
        addEntryLog(content.aq_parent.aq_parent, None, _(u'Modified subpunt'), content.absolute_url())
예제 #16
0
def puntModified(content, event):
    """ Punt modify handler """
    if event.descriptions != ():
        addEntryLog(content.__parent__, None, _(u'Modified punt'), content.absolute_url())
예제 #17
0
def actaModified(content, event):
    """ Acta modify handler """
    addEntryLog(content.__parent__, None, _(u'Modified acta'), content.absolute_url())
예제 #18
0
def actaDeleted(content, event):
    """ Acta delete handler
    """
    addEntryLog(content.__parent__, None, _(u'Deleted acta'), content.absolute_url())