Improve scripts javascript to support groups
Added ability to change fields when copying (component, cc)
Index: datamover/htdocs/scripts.js
===================================================================
--- datamover/htdocs/scripts.js (revision 4992)
+++ datamover/htdocs/scripts.js (revision 5000)
@@ -1,8 +1,8 @@
-selected_suboptions = [];
+selected_suboptions = new Array();
-function show_suboptions(suboption_list) {
- for (i = 0; i < window.selected_suboptions.length; i++) {
- opt = document.getElementById(selected_suboptions[i]);
+function show_suboptions(group, suboption_list) {
+ for (i = 0; i < window.selected_suboptions[group].length; i++) {
+ opt = document.getElementById(selected_suboptions[group][i]);
if (opt) {
opt.style.display = 'none';
}
@@ -15,13 +15,13 @@
}
}
- selected_suboptions = suboption_list;
+ selected_suboptions[group] = suboption_list;
}
-function add_suboption_set(option, suboption_list) {
- addEvent(document.getElementById(option), 'click', function() { show_suboptions(suboption_list);});
+function add_suboption_set(group, option, suboption_list) {
+ addEvent(document.getElementById(option), 'click', function() { show_suboptions(group, suboption_list);});
}
-function set_selected_suboptions(suboption_list) {
- selected_suboptions = suboption_list;
+function set_selected_suboptions(group, suboption_list) {
+ selected_suboptions[group] = suboption_list;
}
\ No newline at end of file
Index: datamover/templates/datamover_ticket.cs
===================================================================
--- datamover/templates/datamover_ticket.cs (revision 4992)
+++ datamover/templates/datamover_ticket.cs (revision 5000)
@@ -64,6 +64,17 @@
+
+
+
+
+
+
+
@@ -75,11 +86,11 @@
Index: datamover/templates/datamover_attachment.cs
===================================================================
--- datamover/templates/datamover_attachment.cs (revision 4992)
+++ datamover/templates/datamover_attachment.cs (revision 5000)
@@ -77,11 +77,11 @@
Index: datamover/util.py
===================================================================
--- datamover/util.py (revision 4992)
+++ datamover/util.py (revision 5000)
@@ -16,7 +16,7 @@
'VALUES (' + ', '.join(['%s']*len(data)) + ')'
return (sql, data.values())
-def copy_ticket(source_env, dest_env, source_id, dest_db=None, include_attachments=False, action='copy'):
+def copy_ticket(source_env, dest_env, source_id, dest_db=None, include_attachments=False, action='copy', **kwargs):
"""Copy a ticket from {{{source_env}}} #{{{source_id}}} to {{{dest_env}}}."""
# In case a string gets passed in
@@ -37,6 +37,8 @@
source_cursor.execute('SELECT * FROM ticket WHERE id=%s',(source_id,))
ticket_data = dict(zip([d[0] for d in source_cursor.description], source_cursor.fetchone()))
del ticket_data['id']
+ for key, value in kwargs.iteritems():
+ ticket_data[key] = value
q = make_query(ticket_data, 'ticket')
dest_cursor.execute(*q)
dest_id = dest_db.get_last_id(dest_cursor, 'ticket')
Index: datamover/ticket.py
===================================================================
--- datamover/ticket.py (revision 4992)
+++ datamover/ticket.py (revision 5000)
@@ -56,6 +56,14 @@
'query': source,
}[source_type]
+ kwargs = {}
+
+ # possibly change some of the fields when copying
+ if req.args.get('dest_component'):
+ kwargs['component'] = req.args.get('dest_component')
+ if req.args.get('dest_cc'):
+ kwargs['cc'] = req.args.get('dest_cc')
+
try:
# Find the ids we want
ids = None
@@ -68,7 +76,7 @@
dest_db = open_environment(dest).get_db_cnx()
for id in ids:
- copy_ticket(self.env, dest, id, dest_db, include_attachments, action)
+ copy_ticket(self.env, dest, id, dest_db, include_attachments, action, **kwargs)
dest_db.commit()
if action == 'move':