Esempio n. 1
0
def set_document_permissions(m, perm_spec):
	from anzsm.payment.utils import setResourceLicenseAgreement
	from anzsm.payment.utils import setPaymentOptions
	setResourceLicenseAgreement ( m , perm_spec)
	setPaymentOptions (m, perm_spec)
	if "authenticated" in perm_spec:
		m.set_gen_level(AUTHENTICATED_USERS, perm_spec['authenticated'])
	if "anonymous" in perm_spec:
		m.set_gen_level(ANONYMOUS_USERS, perm_spec['anonymous'])
	users = [n for (n, p) in perm_spec['users']]
	m.get_user_levels().exclude(user__username__in = users + [m.owner]).delete()
	for username, level in perm_spec['users']:
		user = User.objects.get(username=username)
		m.set_user_level(user, level)
Esempio n. 2
0
def set_document_permissions(m, perm_spec):
    from anzsm.payment.utils import setResourceLicenseAgreement, setResourceViewMode
    from anzsm.payment.utils import setPaymentOptions
    setResourceLicenseAgreement(m, perm_spec)
    setResourceViewMode(m, perm_spec)
    setPaymentOptions(m, perm_spec)
    if "authenticated" in perm_spec:
        m.set_gen_level(AUTHENTICATED_USERS, perm_spec['authenticated'])
    if "anonymous" in perm_spec:
        m.set_gen_level(ANONYMOUS_USERS, perm_spec['anonymous'])
    users = [n for (n, p) in perm_spec['users']]
    m.get_user_levels().exclude(user__username__in=users + [m.owner]).delete()
    for username, level in perm_spec['users']:
        user = User.objects.get(username=username)
        m.set_user_level(user, level)
Esempio n. 3
0
    saved_layer.save_to_geonetwork()

    # Step 11. Set default permissions on the newly created layer
    # FIXME: Do this as part of the post_save hook
    logger.info('>>> Step 11. Setting default permissions for [%s]', name)
    if permissions is not None:
        from geonode.maps.views import set_layer_permissions
        set_layer_permissions(saved_layer, permissions)

    # Step 12. Insert the payment options
    logger.info('>>> Step 12. Setting payment options [%s]', name)
    if permissions is not None:
        payment_options = [n for (n, p) in permissions['payment_options']]
        if payment_options is not None:
            from anzsm.payment.utils import setPaymentOptions
            setPaymentOptions(saved_layer, permissions)    
    
  
    # Step 13. Verify the layer was saved correctly and clean up if needed
    logger.info('>>> Step 13. Verifying the layer [%s] was created correctly' % name)

    # Verify the object was saved to the Django database
    try:
        Layer.objects.get(name=name)
    except Layer.DoesNotExist, e:
        msg = ('There was a problem saving the layer %s to GeoNetwork/Django. Error is: %s' % (layer, str(e)))
        logger.exception(msg)
        logger.debug('Attempting to clean up after failed save for layer [%s]', name)
        # Since the layer creation was not successful, we need to clean up
        cleanup(name, layer_uuid)
        raise GeoNodeException(msg)