def notifyActionSucceededPlumiVideo(obj,event):
    """This gets called on IActionSucceededEvent - called whenever the object is transistioned thru workflow states."""
    workflow = getToolByName(obj,'portal_workflow')
    state = workflow.getInfoFor(obj,'review_state','')
    request = getSite().REQUEST
    wf_action = request.get('workflow_action','')
    log = logging.getLogger('plumi.content.subscribers')
    log.info("notifyActionSuceededPlumiVideo... %s in state (%s) with event %s " % (obj.Title(), state,  event))
    settings = get_settings()

    #decide what to do , based on workflow of object
    #PUBLISHED
    log.info(state)
    if wf_action == 'retract':
        log.info('video retracted')
        if settings.notifyReviewers:
            IPlumiWorkflow(obj).notifyOwnerVideoRetracted()
            IPlumiWorkflow(obj).notifyReviewersVideoRetracted()
    elif wf_action == 'reject':
        log.info('video rejected')
        if settings.notifyReviewers:
            IPlumiWorkflow(obj).notifyOwnerVideoRejected()
            IPlumiWorkflow(obj).notifyReviewersVideoRejected()
    elif state == 'pending' and not request.has_key('form.button.save'):
        log.info('video submitted for review')
        if settings.notifyReviewers:
            IPlumiWorkflow(obj).notifyReviewersVideoSubmitted()
            IPlumiWorkflow(obj).notifyOwnerVideoSubmitted()
    elif state == 'published':
        log.info('doing published tasks')
        obj.reindexObject()

        #emails
        IPlumiWorkflow(obj).notifyOwnerVideoPublished()
def notifyModifiedPlumiVideo(obj ,event):
    """This gets called on IObjectEditedEvent - called whenever the object is edited."""
    workflow = getToolByName(obj,'portal_workflow')
    state = workflow.getInfoFor(obj,'review_state','')
    log = logging.getLogger('plumi.content.subscribers')
    log.info("notifyModifiedPlumiVideo... %s in state (%s) with event %s " % (obj.Title(), state,  event))
    if getSite():
        request = getSite().REQUEST
        #VISIBLE
        if state in ['private','visible'] and request.has_key('form.button.save'):
            #call IPlumiWorkflow API to decide if its ready to publish or needs hiding.
            # The adapter object will implement the logic for various content types
            if IPlumiWorkflow(obj).autoPublishOrHide():
                settings = get_settings()
                if settings.notifyReviewers:
                    IPlumiWorkflow(obj).notifyReviewersVideoSubmitted()
                    IPlumiWorkflow(obj).notifyOwnerVideoSubmitted()
        #PENDING , other states..
        if request.has_key('video_file_file'): #new video uploaded
            log.info('notifyModifiedPlumiVideo: video replaced;')
            async = getUtility(IAsyncService)
            temp_time = datetime.datetime.now(pytz.UTC) + datetime.timedelta(seconds=2)
            try:
                job = async.queueJobWithDelay(None, temp_time, setup_metadata, obj)
                log.info("job queued: %s" % job)
            except Exception as e:
                log.error('failed to queue setup_metadata job: %s' % e)
def notifyInitPlumiVideo(obj ,event):
    """This gets called on IObjectInitializedEvent - which occurs when a new object is created."""
    workflow = getToolByName(obj,'portal_workflow')
    state = workflow.getInfoFor(obj,'review_state','')
    log = logging.getLogger('plumi.content.subscribers')
    log.info("notifyInitPlumiVideo... %s in state (%s) with event %s " % (obj.Title(), state,  event))
    #create thumbnails for audio and image
    if 'image' in obj.getContentType() and not obj.getThumbnailImage():
        obj.setThumbnailImage(obj.video_file.data)
    elif 'audio' in obj.getContentType() and not obj.getThumbnailImage():
        image_path = getSite().absolute_url() + '/++resource++plumi.content.images/clip_default.png'
        f = urlopen(image_path)
        obj.setThumbnailImage(f.read())
        f.close()

    #decide what to do , based on workflow of object
    try:
        state = workflow.getInfoFor(obj,'review_state')
    except WorkflowException:
        log.info('failed to get workflow state for %s' % obj)
        state = None
    request = getSite().REQUEST
    #VISIBLE
    #works with the old and new publish video forms
    if state in ['private','visible'] and (request.has_key('form.button.save') or \
        request.form.has_key('form.buttons.apply')):
        #state in ['private','visible'] and request.['form.buttons.53617665206368616e676573']:
        #call IPlumiWorkflow API to decide if its ready to publish or needs hiding.
        # The adapter object will implement the logic for various content types
        if IPlumiWorkflow(obj).autoPublishOrHide():
            settings = get_settings()
            if settings.notifyReviewers:
                IPlumiWorkflow(obj).notifyOwnerVideoSubmitted()
                IPlumiWorkflow(obj).notifyReviewersVideoSubmitted()

    async = getUtility(IAsyncService)
    temp_time = datetime.datetime.now(pytz.UTC) + datetime.timedelta(seconds=2)
    try:
        job = async.queueJobWithDelay(None, temp_time, setup_metadata, obj)
        log.info("job queued: %s" % job)
    except Exception as e:
        log.error('failed to queue setup_metadata job: %s' % e)
def notify_reviewers(obj):
    """Tell the reviewers when an item was submited.

       This method sends an email to the site admin (mail control panel setting)
       when a new object has been submitted
    """
    settings = get_settings()
    if settings.notifyReviewers:
        obj_title = obj.Title()
        obj_url= obj.absolute_url()
        creator = obj.Creator()
        membr_tool = getToolByName(getSite(),'portal_membership')
        member=membr_tool.getMemberById(creator)
        creator_info = {'fullname':member.getProperty('fullname', 'Fullname missing'),
                        'email':member.getProperty('email', None)}
        #search for reviewers
        reviewers = membr_tool.searchForMembers(roles=['Reviewer'])
        for reviewer in reviewers:
            memberId = reviewer.id
            try:
                mTo = reviewer.getProperty('email', None)
                urltool = getToolByName(getSite(), 'portal_url')
                portal = urltool.getPortalObject()
                mFrom = portal.getProperty('email_from_address')
                mSubj = '%s -- submitted for your review' % obj_title
                mMsg = 'To: %s\n' % mTo
                mMsg += 'From: %s\n' % mFrom
                mMsg += 'Content-Type: text/plain; charset=utf-8\n\n'
                mMsg += _('Item has been submitted for your review').encode('utf-8','ignore') + '\n'
                mMsg += _('Please review the submitted content. ').encode('utf-8','ignore') + '\n\n'
                mMsg += 'Title: %s\n\n' % obj_title
                mMsg += '%s/view \n\n' % obj_url
                mMsg += 'The contributor was %s\n\n' % creator_info['fullname']
                mMsg += 'Email: %s\n\n' % creator_info['email']
                logger.info('notifyReviewersVideoSubmitted , im %s . sending email to %s from %s ' % (getSite(), mTo, mFrom) )
                async = getUtility(IAsyncService)
                job = async.queueJobWithDelay(None, temp_time, sendMail, obj, mMsg, mSubj)
            except Exception, e:
                logger.error('Didnt actually send email to reviewer! Something amiss with SecureMailHost. %s' % e)
Example #5
0
 def __init__(self, context, request):
     super(VideoView, self).__init__(context, request)
     self.portal_url = getToolByName(self.context, "portal_url")()
     self.vocab_tool = getToolByName(self.context, "portal_vocabularies")
     self.settings = get_settings()