lims: email notification enhancements

- changed the notify field in the request table to JSONType to store recipient email address and other config details
  - notification of specific sample state changes
     - changes made to barcode scan AMQP handler to update sample state to also send email when required
  - notification to multiple recipients
  - request events history records notifications
  - UI enhancements to the edit request page to allow users to change notification configurations
 UI enhancements to the request page to show the request type state, user & notification details
This commit is contained in:
Ramkrishna Chakrabarty
2010-08-26 11:17:49 -04:00
parent 94f3489952
commit 25dd565340
13 changed files with 515 additions and 169 deletions
@@ -16,11 +16,18 @@ import xml.dom.minidom
import subprocess
from galaxydb_interface import GalaxyDbInterface
new_path = [ os.path.join( os.getcwd(), "scripts/galaxy_messaging/server" ) ]
new_path.extend( sys.path[1:] ) # remove scripts/ from the path
sys.path = new_path
from galaxyweb_interface import GalaxyWebInterface
assert sys.version_info[:2] >= ( 2, 4 )
new_path = [ os.path.join( os.getcwd(), "lib" ) ]
new_path.extend( sys.path[1:] ) # remove scripts/ from the path
sys.path = new_path
from galaxy import eggs
import pkg_resources
pkg_resources.require( "amqplib" )
@@ -66,6 +73,7 @@ def get_value_index(dom, tag_name, index):
def recv_callback(msg):
global config
global webconfig
# check the meesage type.
msg_type = msg.properties['application_headers'].get('msg_type')
log.debug('\nMESSAGE RECVD: '+str(msg_type))
@@ -88,12 +96,20 @@ def recv_callback(msg):
log.debug('Barcode: '+barcode)
log.debug('State: '+state)
# update the galaxy db
galaxy = GalaxyDbInterface(dbconnstr)
sample_id = galaxy.get_sample_id(field_name='bar_code', value=barcode)
galaxydb = GalaxyDbInterface(dbconnstr)
sample_id = galaxydb.get_sample_id(field_name='bar_code', value=barcode)
if sample_id == -1:
log.debug('Invalid barcode.')
return
galaxy.change_state(sample_id, state)
galaxydb.change_state(sample_id, state)
# update the request state
galaxyweb = GalaxyWebInterface(webconfig.get("universe_wsgi_config", "host"),
webconfig.get("universe_wsgi_config", "port"),
webconfig.get("data_transfer_user_login_info", "email"),
webconfig.get("data_transfer_user_login_info", "password"),
config.get("app:main", "id_secret"))
galaxyweb.update_request_state(galaxydb.get_request_id(sample_id), sample_id)
galaxyweb.logout()
def main():
if len(sys.argv) < 2:
@@ -108,6 +124,15 @@ def main():
for option in config.options("galaxy_amqp"):
amqp_config[option] = config.get("galaxy_amqp", option)
log.debug(str(amqp_config))
# web server config
global webconfig
webconfig = ConfigParser.ConfigParser()
webconfig.read('transfer_datasets.ini')
conn = amqp.Connection(host=amqp_config['host']+":"+amqp_config['port'],
userid=amqp_config['userid'],
password=amqp_config['password'],
@@ -57,6 +57,12 @@ class GalaxyDbInterface(object):
#log.debug('Sample ID: %i' % sample_id)
return sample_id
return -1
def get_request_id(self, sample_id):
query = select(columns=[self.sample_table.c.request_id],
whereclause=self.sample_table.c.id==sample_id)
request_id = query.execute().fetchall()[0][0]
return request_id
def current_state(self, sample_id):
'''
@@ -105,3 +105,19 @@ class GalaxyWebInterface(object):
s = ( "!" * ( 8 - len(s) % 8 ) ) + s
# Encrypt
return id_cipher.encrypt( s ).encode( 'hex' )
def update_request_state(self, request_id, sample_id):
params = urllib.urlencode(dict( cntrller='requests_admin',
request_id=request_id,
sample_id=sample_id))
url = self.base_url + "/requests_admin/update_request_state"
f = self.opener.open(url, params)
print url
print params
x = f.read()