示例#1
0
def _addEmailUser(event, wavelet, gadgetWrapper, user, request):
    '''
    Adds an email particpant to the wave and updates the gadget to reflect
    @param event: the event that triggered the changed gadget
    @param wavelet: the wavelet where the request originated from
    @param user: the user that made the request
    @param gadgetWrapper: the object that wraps this gadgets state
    @param request: the request to process
    '''
    logging.info("Add email user request")
    email = request.get('params').get("email") or None
    message = request.get('params').get('message') or ""
    
    if email:
        logging.info("Creating new session for " + email)
        url = sessionCreation.generateNewUser(  wavelet.wave_id,
                                                wavelet.wavelet_id,
                                                email,
                                                pt_raw.RW['READ_WRITE'])
        deferred.defer(
            emailInterface.sendFirstNotificationEmail,
            url,
            wavelet.wave_id,
            wavelet.wavelet_id,
            email,
            event.modified_by,
            wavelet.title,
            message=message)

        wavelet.add_proxying_participant(utils.getProxyForFromEmail(email))
        gadgetWrapper.addEmailParticipant(email)
        gadgetWrapper.deleteIncomingRequest(user)
示例#2
0
def _changePublicSettings(wavelet, gadgetWrapper, user, request):
    '''
    Changes the public settings for the wave and updates the gadget to reflect
    @param wavelet: the wavelet where the request originated from
    @param user: the user that made the request
    @param gadgetWrapper: the object that wraps this gadgets state
    @param request: the request to process
    '''
    logging.info("Change public settings request")
    #Extract values from the incoming json
    isPublic = None
    isReadOnly = None
    params = request.get("params", None)
    if params:
        isPublic = params.get("isPublic", None)
        isReadOnly = params.get("isReadOnly", None)
    if isPublic == None:
        isPublic = False
    if isReadOnly == None:
        isReadOnly = True
    
    #Convert values into permissions
    if isReadOnly:
        rw_permission = pt_raw.RW['READ']
    else:
        rw_permission = pt_raw.RW['READ_WRITE']
    if not isPublic:
        rw_permission = pt_raw.RW['DELETED']
    url = sessionCreation.generateNewUser(  wavelet.wave_id,
                                            wavelet.wavelet_id,
                                            config.PUBLIC_EMAIL,
                                            rw_permission)
    gadgetWrapper.changePublicSettings(isPublic, isReadOnly, url)
    gadgetWrapper.deleteIncomingRequest(user)
示例#3
0
def onAddParticipantsChangedV1(event, wavelet, add_gadget):
    '''
    Deals with the add participants gadget changing, subscribes wave users etc
    @param event: the event that triggered the gadget state change
    @param wavelet: the wavelet the gadget lives in
    @param add_gadget: the add participants gadget retrieved from the wave
    '''

    #Fetch the values from the gadget
    participants_json = add_gadget.get("EMAIL-PARTICIPANTS", None)
    if participants_json:
        participants_json = base64.b64decode(participants_json)
    else:
        participants_json = "[]"
    participants = simplejson.loads(participants_json)
    new_participant = add_gadget.get("ADD-PARTICIPANT", None)

    if new_participant:
        logging.info("Subscribing new e-mail user: "******" not subscribed. E-mail address not valid")
            return

        #Only update if the user is new
        if not new_participant in participants:
            deferred.defer(
                    emailInterface.sendFirstNotificationEmail,
                    sessionCreation.generateNewUser(wavelet.wave_id,
                                                    wavelet.wavelet_id,
                                                    new_participant,
                                                    pt_raw.RW['READ_WRITE']),
                    wavelet.wave_id,
                    wavelet.wavelet_id,
                    new_participant,
                    event.modified_by,
                    wavelet.title)

            participants.append(new_participant)
            wavelet.add_proxying_participant(utils.getProxyForFromEmail(new_participant))

        #Update the gadget
        participants_json = simplejson.dumps(participants)
        add_gadget.update_element({ "ADD-PARTICIPANT": None,
                                    "EMAIL-PARTICIPANTS": base64.b64encode(participants_json)})