Python script to hide ploneformgen form after user has filled it out. (For Plone-4.3.2-64.)

前端 未结 3 1027
失恋的感觉
失恋的感觉 2021-01-22 19:53

After a user has filled out a (ploneformgen) form , I would like to use a custom script adapter to call a python script to change the user’s local role so that they can’t see th

3条回答
  •  清酒与你
    2021-01-22 20:36

    Ugly ugly way to handle this may be to access to the data saver field's download method and parse its output to find data to check. For example, if username is the second pfg field added into form, a custom script adapter that prevents furthers fillings by a user may be

    alreadyInDB = False
    savedData = ploneformgen.savefield.getSavedFormInputForEdit()
    username = request.AUTHENTICATED_USER.getId()
    
    usersInDB = [x.split(',')[1] for x in savedData.split('\r\n') if len(x)>0]
    
    if username in usersInDB:
        alreadyInDB = True
    
    if alreadyInDB:
        return {'username': 'No way man!'}
    

提交回复
热议问题