# Path: ethicsapplication/signals.py

# 
# Path: review/signals.py



from ethicsapplication.signals import application_created
from review.signals import application_accepted_by_reviewer,\
    application_rejected_by_reviewer
from django.conf import settings
import pika
import json
        with information about the lifecycle event.
        The mesage will only be sent if the settings.PUBLISH_LIFECYCLE 
        flag is set to True.
    '''
    
    host = settings.AMQP_HOST
    
    exchange_info = ('openethics_events', 'fanout')
    
    signal = kwargs['signal']
    
    if signal == application_created:
        event_type = 'created'
    elif signal == application_accepted_by_reviewer:
        event_type = 'accepted'
    elif signal == application_rejected_by_reviewer:
        event_type = 'rejected'
    else:
        raise AttributeError('An unkonwn signal triggered the receiver!')
    
    
    message = json.dumps({'application': kwargs['application'].id, 'event_type':event_type})
        
    if settings.PUBLISH_LIFECYCLE:   
        _send_message(host, exchange_info, message)
    
      
      
#connect to the signals of interest.  
application_created.connect(lifecycle_event_handler)

# Path: ethicsapplication/signals.py

# 
# Path: review/signals.py



# Path: publisher/signals.py
from ethicsapplication.signals import application_created
from review.signals import application_accepted_by_reviewer,\
    application_rejected_by_reviewer
from django.conf import settings
import pika
import json

        with information about the lifecycle event.
        The mesage will only be sent if the settings.PUBLISH_LIFECYCLE 
        flag is set to True.
    '''
    
    host = settings.AMQP_HOST
    
    exchange_info = ('openethics_events', 'fanout')
    
    signal = kwargs['signal']
    
    if signal == application_created:
        event_type = 'created'
    elif signal == application_accepted_by_reviewer:
        event_type = 'accepted'
    elif signal == application_rejected_by_reviewer:
        event_type = 'rejected'
    else:
        raise AttributeError('An unkonwn signal triggered the receiver!')
    
    
    message = json.dumps({'application': kwargs['application'].id, 'event_type':event_type})
        
    if settings.PUBLISH_LIFECYCLE:   
        _send_message(host, exchange_info, message)
    
      
      
#connect to the signals of interest.  
application_created.connect(lifecycle_event_handler)

application_accepted_by_reviewer.connect(lifecycle_event_handler)