You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@bloodhound.apache.org by Dammina Sahabandu <dm...@gmail.com> on 2014/08/03 13:41:57 UTC
Re: svn commit: r1615401 - in /bloodhound/branches/bep_0011_batch_create_tickets/bloodhound_theme/bhtheme:
htdocs/js/batchcreate.js theme.py
- The functionality that existed to remove rows does remove the last row
of the input table. Now it has been modified, so now the users will be able
to select the ticket rows(by checking the checkbox at the beginning) and
remove only those specified rows.
- Milestone and Component fields added to the input table. So now the
users will be able to add milestones and components to the tickets when
using the batch create functionality. But at the moment the batch create
functionality will be available only when self.env.product is not None.
(This will be fixed later by dynamically generating milestone/component
input fields using ajax requests.)
- The default(selected) value of 'ticket status' is set to 'new'.
- Users will not be able to create tickets without a summary value. If
they try to do so they will be notified that those tickets will not be
created if they don't add summary values. Then they have the choice of
adding summary values before going ahead or ignore the warning and create
the rest of the tickets.
On Sun, Aug 3, 2014 at 5:10 PM, <da...@apache.org> wrote:
> Author: dammina
> Date: Sun Aug 3 11:40:12 2014
> New Revision: 1615401
>
> URL: http://svn.apache.org/r1615401
> Log:
> Modified several components of the feature.
>
> Modified:
>
> bloodhound/branches/bep_0011_batch_create_tickets/bloodhound_theme/bhtheme/htdocs/js/batchcreate.js
>
> bloodhound/branches/bep_0011_batch_create_tickets/bloodhound_theme/bhtheme/theme.py
>
> Modified:
> bloodhound/branches/bep_0011_batch_create_tickets/bloodhound_theme/bhtheme/htdocs/js/batchcreate.js
> URL:
> http://svn.apache.org/viewvc/bloodhound/branches/bep_0011_batch_create_tickets/bloodhound_theme/bhtheme/htdocs/js/batchcreate.js?rev=1615401&r1=1615400&r2=1615401&view=diff
>
> ==============================================================================
> ---
> bloodhound/branches/bep_0011_batch_create_tickets/bloodhound_theme/bhtheme/htdocs/js/batchcreate.js
> (original)
> +++
> bloodhound/branches/bep_0011_batch_create_tickets/bloodhound_theme/bhtheme/htdocs/js/batchcreate.js
> Sun Aug 3 11:40:12 2014
> @@ -1,11 +1,16 @@
> -function emptyTable(products,href,token) {
> +function emptyTable(product,milestones,components,href,token) {
> +
> var numOfRows = document.getElementById("numOfRows").value;
> - form_token = token.split(";")[0].split("=")[1];//I'm not really
> sure about this method
> - if(numOfRows != "" && document.getElementById("empty-table") ==
> null){
> + var created_rows = document.getElementById("numOfRows").value;
> + form_token = token.split(";")[0].split("=")[1];
> + if(numOfRows == ""){
> + alert("Enter the ticket batch size.")
> + }
> + else if(numOfRows != "" && document.getElementById("empty-table")
> == null){
> var contentDiv = document.getElementById("content");
> //var headers =
> {"summary":"Summary","description":"Description","product":"Product","status":"Status","priority":"Priority","type":"Types","owner":"Owner","cc":"Cc","milestone":"Milestone","keywords":"Keywords"}
> - var headers =
> {"summary":"Summary","description":"Description","product":"Product","status":"Status","priority":"Priority"}
> - statuses = ["accepted", "assigned", "closed", "new", "reopened"];
> + var headers =
> {"ticket":"","summary":"Summary","description":"Description","product":"Product","priority":"Priority","milestone":"Milestone","component":"Component"}
> + //statuses = ["new", "accepted", "assigned", "closed", "reopened"];
> priorities = ["blocker", "critical", "major", "minor", "trivial"];
> types = ["defect", "enhancement", "task"];
>
> @@ -49,7 +54,17 @@ function emptyTable(products,href,token)
> for (i=0;i<numOfRows;i++){
> tr_rows = document.createElement("tr");
> for (header in headers){
> - if (header == "summary"){
> + if(header == "ticket"){
> + td_row = document.createElement("td");
> + input_ticket =
> document.createElement("input");
> +
> input_ticket.setAttribute("type","checkbox");
> +
> input_ticket.setAttribute("id","field-ticket"+i);
> +
> input_ticket.setAttribute("class","input-block-level");
> +
> input_ticket.setAttribute("name","field_ticket"+i);
> + td_row.appendChild(input_ticket);
> + tr_rows.appendChild(td_row);
> + }
> + else if (header == "summary"){
> td_row = document.createElement("td");
> input_summary =
> document.createElement("input");
> input_summary.setAttribute("type","text");
> @@ -70,7 +85,7 @@ function emptyTable(products,href,token)
> td_row.appendChild(input_description);
> tr_rows.appendChild(td_row);
> }
> - else if (header == "status") {
> + /*else if (header == "status") {
> td_row = document.createElement("td");
> input_status =
> document.createElement("select");
>
> input_status.setAttribute("id","field-status"+i);
> @@ -84,7 +99,7 @@ function emptyTable(products,href,token)
> }
> td_row.appendChild(input_status);
> tr_rows.appendChild(td_row);
> - }
> + }*/
> else if (header == "priority") {
> td_row = document.createElement("td");
> input_priority =
> document.createElement("select");
> @@ -121,10 +136,10 @@ function emptyTable(products,href,token)
>
> field_product.setAttribute("id","field-product"+i);
>
> field_product.setAttribute("class","input-block-level");
>
> field_product.setAttribute("name","field_product"+i);
> - for (product in products){
> + for (p in product){
> option =
> document.createElement("option");
> -
> option.setAttribute("value",(products[product])[0]);
> -
> option.appendChild(document.createTextNode((products[product])[1]));
> +
> option.setAttribute("value",(product[p])[0]);
> +
> option.appendChild(document.createTextNode((product[p])[1]));
> field_product.appendChild(option);
> }
> td_row.appendChild(field_product);
> @@ -150,16 +165,36 @@ function emptyTable(products,href,token)
> td_row.appendChild(input_cc);
> tr_rows.appendChild(td_row);
> }*/
> - /*else if (header == "milestone"){
> + else if (header == "milestone"){
> + td_row = document.createElement("td");
> + field_milestone =
> document.createElement("select");
> +
> field_milestone.setAttribute("id","field-milestone"+i);
> +
> field_milestone.setAttribute("class","input-block-level");
> +
> field_milestone.setAttribute("name","field_milestone"+i);
> + for (milestone in milestones){
> + option =
> document.createElement("option");
> +
> option.setAttribute("value",(milestones[milestone])[0]);
> +
> option.appendChild(document.createTextNode((milestones[milestone])[0]));
> +
> field_milestone.appendChild(option);
> + }
> + td_row.appendChild(field_milestone);
> + tr_rows.appendChild(td_row);
> + }
> + else if (header == "component"){
> td_row = document.createElement("td");
> - input_milestone =
> document.createElement("input");
> -
> input_milestone.setAttribute("type","text");
> -
> input_milestone.setAttribute("id","field-milestone"+i);
> -
> input_milestone.setAttribute("class","input-block-level");
> -
> input_milestone.setAttribute("name","field_milestone"+i);
> - td_row.appendChild(input_milestone);
> + field_component =
> document.createElement("select");
> +
> field_component.setAttribute("id","field-component"+i);
> +
> field_component.setAttribute("class","input-block-level");
> +
> field_component.setAttribute("name","field_component"+i);
> + for (component in components){
> + option =
> document.createElement("option");
> +
> option.setAttribute("value",(components[component])[0]);
> +
> option.appendChild(document.createTextNode((components[component])[0]));
> +
> field_component.appendChild(option);
> + }
> + td_row.appendChild(field_component);
> tr_rows.appendChild(td_row);
> - }*/
> + }
> /*else if (header == "keywords"){
> td_row = document.createElement("td");
> input_keywords =
> document.createElement("input");
> @@ -179,7 +214,10 @@ function emptyTable(products,href,token)
> remove_row_button = document.createElement("button");
> remove_row_button.setAttribute("class","btn pull-right");
> remove_row_button.setAttribute("type","button");
> -
> remove_row_button.setAttribute("onclick","remove_row_btn_action()");
> + remove_row_button.addEventListener("click", function(event) {
> +
> numOfRows=parseInt(numOfRows)-parseInt(remove_row_btn_action(numOfRows));
> + event.preventDefault();
> + });
> remove_row_button.setAttribute("id","bct-rmv-empty-row");
> remove_row_button.appendChild(document.createTextNode("-"));
> form.appendChild(remove_row_button);
> @@ -188,7 +226,9 @@ function emptyTable(products,href,token)
> add_row_button.setAttribute("class","btn pull-right");
> add_row_button.setAttribute("type","button");
> add_row_button.addEventListener("click", function(event) {
> - add_row_btn_action(products);
> +
> add_row_btn_action(product,milestones,components,created_rows);
> + numOfRows=parseInt(numOfRows)+1;
> + created_rows=parseInt(created_rows)+1;
> event.preventDefault();
> });
> add_row_button.setAttribute("id","bct-add-empty-row");
> @@ -198,7 +238,29 @@ function emptyTable(products,href,token)
> submit_button = document.createElement("button");
> submit_button.setAttribute("class","btn pull-right");
> submit_button.setAttribute("type","button");
> - submit_button.setAttribute("onclick","submit_btn_action()");
> + submit_button.addEventListener("click", function(event) {
> + var empty_row=false;
> + var cnt=0;
> + for (var k = 0; k <parseInt(numOfRows)+parseInt(cnt); k++)
> {
> + var element =
> document.getElementById("field-summary"+k);
> + if(element==null){
> + cnt=parseInt(cnt)+1;
> + continue;
> + }
> +
> + var
> summary_val=document.getElementById("field-summary"+k).value;
> + if(summary_val==""){
> + var line_number = parseInt(k)+1;
> + var confirmation = confirm("Summery field
> of one or more tickets are empty. They will not get created!");
> + empty_row=true;
> + break;
> + }
> + };
> + if(confirmation == true || !empty_row){
> + submit_btn_action();
> + event.preventDefault();
> + }
> + });
> submit_button.setAttribute("id","bct-create");
> submit_button.setAttribute("data-target",href);
> submit_button.appendChild(document.createTextNode("save"));
> @@ -239,8 +301,8 @@ function submit_btn_action() {
> function(ticket) {
> deleteForm();
> removeBatchCreate();
> -
> - var headers =
> {"id":"Ticket","summary":"Summary","product":"Product","status":"Status"}
> +
> + var headers =
> {"ticket":"Ticket","summary":"Summary","product":"Product","status":"Status","milestone":"Milestone","component":"Component"}
> var contentDiv =
> document.getElementById("content");
> var div = document.createElement("div");
> div.setAttribute("class","span12");
> @@ -266,7 +328,7 @@ function submit_btn_action() {
>
> for ( i=0 ; i<Object.keys(ticket.tickets).length ;
> i++ ){
> tr = document.createElement("tr");
> - for (j=0;j<4;j++){
> + for (j=0;j<6;j++){
> if(j==0){
> td =
> document.createElement("td");
> a =
> document.createElement("a");
> @@ -293,6 +355,16 @@ function submit_btn_action() {
> tkt =
> JSON.parse(ticket.tickets[i]);
>
> td.appendChild(document.createTextNode(tkt.status));
> }
> + else if(j==4){
> + td =
> document.createElement("td");
> + tkt =
> JSON.parse(ticket.tickets[i]);
> +
> td.appendChild(document.createTextNode(tkt.milestone));
> + }
> + else if(j==5){
> + td =
> document.createElement("td");
> + tkt =
> JSON.parse(ticket.tickets[i]);
> +
> td.appendChild(document.createTextNode(tkt.component));
> + }
> tr.appendChild(td);
> }
> table.appendChild(tr);
> @@ -302,18 +374,27 @@ function submit_btn_action() {
> });
> }
>
> -function add_row_btn_action(products){
> - // alert("1");
> +function add_row_btn_action(product,milestones,components,i){
>
> - var headers =
> {"summary":"Summary","description":"Description","product":"Product","status":"Status","priority":"Priority"}
> - var statuses = ["accepted", "assigned", "closed", "new",
> "reopened"];
> + var headers =
> {"ticket":"","summary":"Summary","description":"Description","product":"Product","priority":"Priority","milestone":"Milestone","component":"Component"}
> + //var statuses = ["new", "accepted", "assigned", "closed",
> "reopened"];
> var priorities = ["blocker", "critical", "major", "minor",
> "trivial"];
> var types = ["defect", "enhancement", "task"];
>
> tr_rows = document.createElement("tr");
>
> for (header in headers){
> - if (header == "summary"){
> + if(header == "ticket"){
> + td_row = document.createElement("td");
> + input_ticket = document.createElement("input");
> + input_ticket.setAttribute("type","checkbox");
> + input_ticket.setAttribute("id","field-ticket"+i);
> +
> input_ticket.setAttribute("class","input-block-level");
> + input_ticket.setAttribute("name","field_ticket"+i);
> + td_row.appendChild(input_ticket);
> + tr_rows.appendChild(td_row);
> + }
> + else if (header == "summary"){
> td_row = document.createElement("td");
> input_summary =
> document.createElement("input");
> input_summary.setAttribute("type","text");
> @@ -322,123 +403,105 @@ function add_row_btn_action(products){
>
> input_summary.setAttribute("name","field_summary"+i);
> td_row.appendChild(input_summary);
> tr_rows.appendChild(td_row);
> + }
> + else if (header == "description") {
> + td_row = document.createElement("td");
> + input_description =
> document.createElement("textarea");
> +
> input_description.setAttribute("id","field-description"+i);
> +
> input_description.setAttribute("class","input-block-level");
> +
> input_description.setAttribute("name","field_description"+i);
> + input_description.setAttribute("rows","2");
> + input_description.setAttribute("cols","28");
> + td_row.appendChild(input_description);
> + tr_rows.appendChild(td_row);
> + }
> + /*else if (header == "status") {
> + td_row = document.createElement("td");
> + input_status = document.createElement("select");
> + input_status.setAttribute("id","field-status"+i);
> +
> input_status.setAttribute("class","input-block-level");
> + input_status.setAttribute("name","field_status"+i);
> + for (status in statuses){
> + option = document.createElement("option");
> +
> option.setAttribute("value",statuses[status]);
> +
> option.appendChild(document.createTextNode(statuses[status]));
> + input_status.appendChild(option);
> + }
> + td_row.appendChild(input_status);
> + tr_rows.appendChild(td_row);
> + }*/
> + else if (header == "priority") {
> + td_row = document.createElement("td");
> + input_priority = document.createElement("select");
> +
> input_priority.setAttribute("id","field-priority"+i);
> +
> input_priority.setAttribute("class","input-block-level");
> +
> input_priority.setAttribute("name","field_priority"+i);
> + for (priority in priorities){
> + option = document.createElement("option");
> +
> option.setAttribute("value",priorities[priority]);
> +
> option.appendChild(document.createTextNode(priorities[priority]));
> + input_priority.appendChild(option);
> }
> - else if (header == "description") {
> - td_row = document.createElement("td");
> - input_description =
> document.createElement("textarea");
> -
> input_description.setAttribute("id","field-description"+i);
> -
> input_description.setAttribute("class","input-block-level");
> -
> input_description.setAttribute("name","field_description"+i);
> - input_description.setAttribute("rows","2");
> -
> input_description.setAttribute("cols","28");
> - td_row.appendChild(input_description);
> - tr_rows.appendChild(td_row);
> - }
> - else if (header == "status") {
> - td_row = document.createElement("td");
> - input_status =
> document.createElement("select");
> -
> input_status.setAttribute("id","field-status"+i);
> -
> input_status.setAttribute("class","input-block-level");
> -
> input_status.setAttribute("name","field_status"+i);
> - for (status in statuses){
> - option =
> document.createElement("option");
> -
> option.setAttribute("value",statuses[status]);
> -
> option.appendChild(document.createTextNode(statuses[status]));
> - input_status.appendChild(option);
> - }
> - td_row.appendChild(input_status);
> - tr_rows.appendChild(td_row);
> + td_row.appendChild(input_priority);
> + tr_rows.appendChild(td_row);
> + }
> + else if (header == "product") {
> + td_row = document.createElement("td");
> + field_product = document.createElement("select");
> + field_product.setAttribute("id","field-product"+i);
> +
> field_product.setAttribute("class","input-block-level");
> +
> field_product.setAttribute("name","field_product"+i);
> + for (p in product){
> + option = document.createElement("option");
> +
> option.setAttribute("value",(product[p])[0]);
> +
> option.appendChild(document.createTextNode((product[p])[1]));
> + field_product.appendChild(option);
> }
> - else if (header == "priority") {
> - td_row = document.createElement("td");
> - input_priority =
> document.createElement("select");
> -
> input_priority.setAttribute("id","field-priority"+i);
> -
> input_priority.setAttribute("class","input-block-level");
> -
> input_priority.setAttribute("name","field_priority"+i);
> - for (priority in priorities){
> - option =
> document.createElement("option");
> -
> option.setAttribute("value",priorities[priority]);
> -
> option.appendChild(document.createTextNode(priorities[priority]));
> - input_priority.appendChild(option);
> - }
> - td_row.appendChild(input_priority);
> - tr_rows.appendChild(td_row);
> + td_row.appendChild(field_product);
> + tr_rows.appendChild(td_row);
> + }
> + else if (header == "milestone"){
> + td_row = document.createElement("td");
> + field_milestone = document.createElement("select");
> +
> field_milestone.setAttribute("id","field-milestone"+i);
> +
> field_milestone.setAttribute("class","input-block-level");
> +
> field_milestone.setAttribute("name","field_milestone"+i);
> + for (milestone in milestones){
> + option = document.createElement("option");
> +
> option.setAttribute("value",(milestones[milestone])[0]);
> +
> option.appendChild(document.createTextNode((milestones[milestone])[0]));
> + field_milestone.appendChild(option);
> }
> - /*else if (header == "type") {
> - td_row = document.createElement("td");
> - input_type =
> document.createElement("select");
> -
> input_type.setAttribute("id","field-type"+i);
> -
> input_type.setAttribute("class","input-block-level");
> -
> input_type.setAttribute("name","field_type"+i);
> - for (type in types){
> - option =
> document.createElement("option");
> -
> option.setAttribute("value",types[type]);
> -
> option.appendChild(document.createTextNode(types[type]));
> - input_type.appendChild(option);
> - }
> - td_row.appendChild(input_type);
> - tr_rows.appendChild(td_row);
> - }*/
> - else if (header == "product") {
> - td_row = document.createElement("td");
> - field_product =
> document.createElement("select");
> -
> field_product.setAttribute("id","field-product"+i);
> -
> field_product.setAttribute("class","input-block-level");
> -
> field_product.setAttribute("name","field_product"+i);
> - for (product in products){
> - option =
> document.createElement("option");
> -
> option.setAttribute("value",(products[product])[0]);
> -
> option.appendChild(document.createTextNode((products[product])[1]));
> - field_product.appendChild(option);
> - }
> - td_row.appendChild(field_product);
> - tr_rows.appendChild(td_row);
> + td_row.appendChild(field_milestone);
> + tr_rows.appendChild(td_row);
> + }
> + else if (header == "component"){
> + td_row = document.createElement("td");
> + field_component = document.createElement("select");
> +
> field_component.setAttribute("id","field-component"+i);
> +
> field_component.setAttribute("class","input-block-level");
> +
> field_component.setAttribute("name","field_component"+i);
> + for (component in components){
> + option = document.createElement("option");
> +
> option.setAttribute("value",(components[component])[0]);
> +
> option.appendChild(document.createTextNode((components[component])[0]));
> + field_component.appendChild(option);
> }
> - /*else if (header == "owner"){
> - td_row = document.createElement("td");
> - input_owner =
> document.createElement("input");
> - input_owner.setAttribute("type","text");
> -
> input_owner.setAttribute("id","field-owner"+i);
> -
> input_owner.setAttribute("class","input-block-level");
> -
> input_owner.setAttribute("name","field_owner"+i);
> - td_row.appendChild(input_owner);
> - tr_rows.appendChild(td_row);
> - }*/
> - /*else if (header == "cc"){
> - td_row = document.createElement("td");
> - input_cc = document.createElement("input");
> - input_cc.setAttribute("type","text");
> - input_cc.setAttribute("id","field-cc"+i);
> -
> input_cc.setAttribute("class","input-block-level");
> - input_cc.setAttribute("name","field_cc"+i);
> - td_row.appendChild(input_cc);
> - tr_rows.appendChild(td_row);
> - }*/
> - /*else if (header == "milestone"){
> - td_row = document.createElement("td");
> - input_milestone =
> document.createElement("input");
> -
> input_milestone.setAttribute("type","text");
> -
> input_milestone.setAttribute("id","field-milestone"+i);
> -
> input_milestone.setAttribute("class","input-block-level");
> -
> input_milestone.setAttribute("name","field_milestone"+i);
> - td_row.appendChild(input_milestone);
> - tr_rows.appendChild(td_row);
> - }*/
> - /*else if (header == "keywords"){
> - td_row = document.createElement("td");
> - input_keywords =
> document.createElement("input");
> - input_keywords.setAttribute("type","text");
> -
> input_keywords.setAttribute("id","field-keywords"+i);
> -
> input_keywords.setAttribute("class","input-block-level");
> -
> input_keywords.setAttribute("name","field_keywords"+i);
> - td_row.appendChild(input_keywords);
> - tr_rows.appendChild(td_row);
> - }*/
> -
> + td_row.appendChild(field_component);
> + tr_rows.appendChild(td_row);
> + }
> }
>
> document.getElementById("empty-table").childNodes[1].childNodes[1].childNodes[1].appendChild(tr_rows);
> }
>
> -function remove_row_btn_action(){
> -
> document.getElementById("empty-table").childNodes[1].childNodes[1].childNodes[1].lastChild.remove();
> +function remove_row_btn_action(numOfRows){
> + var cnt=0;
> + for(var i=0;i<parseInt(numOfRows)-parseInt(cnt);i++){
> +
> if(document.getElementById("empty-table").childNodes[1].childNodes[1].childNodes[1].childNodes[i].childNodes[0].childNodes[0].checked){
> +
> document.getElementById("empty-table").childNodes[1].childNodes[1].childNodes[1].childNodes[i].remove();
> + cnt=cnt+1;
> + i--;
> + }
> + }
> + return cnt;
> }
>
> Modified:
> bloodhound/branches/bep_0011_batch_create_tickets/bloodhound_theme/bhtheme/theme.py
> URL:
> http://svn.apache.org/viewvc/bloodhound/branches/bep_0011_batch_create_tickets/bloodhound_theme/bhtheme/theme.py?rev=1615401&r1=1615400&r2=1615401&view=diff
>
> ==============================================================================
> ---
> bloodhound/branches/bep_0011_batch_create_tickets/bloodhound_theme/bhtheme/theme.py
> (original)
> +++
> bloodhound/branches/bep_0011_batch_create_tickets/bloodhound_theme/bhtheme/theme.py
> Sun Aug 3 11:40:12 2014
> @@ -691,6 +691,7 @@ class QuickCreateTicketDialog(Component)
> from pkg_resources import get_distribution
> application_version = get_distribution('BloodhoundTheme').version
>
> +
> class BatchCreateTicketDialog(Component):
> implements(
> IRequestFilter,
> @@ -802,7 +803,7 @@ class BatchCreateTicketDialog(Component)
> if k.startswith('field_'))
> # new_tkts variable will contain the tickets that have been
> created as a batch
> # that information will be used to load the resultant query
> table
> - product, tid, new_tkts, num_of_tkts = self.batch_create(
> + product, tid, new_tkts = self.batch_create(
> req, attrs, True)
> # product, tid = self.batch_create(req, attrs, True)
> except Exception as exc:
> @@ -811,6 +812,7 @@ class BatchCreateTicketDialog(Component)
> else:
> tkt_list = []
> tkt_dict = {}
> + num_of_tkts = len(new_tkts)
> for i in range(0, num_of_tkts):
> tres = Neighborhood(
> 'product',
> @@ -832,6 +834,8 @@ class BatchCreateTicketDialog(Component)
> href),
> 'summary': new_tkts[i].values['summary'],
> 'status': new_tkts[i].values['status'],
> + 'milestone': new_tkts[i].values['milestone'],
> + 'component': new_tkts[i].values['component'],
> 'priority': new_tkts[i].values['priority'],
> 'description':
> new_tkts[i].values['description']}))
> tkt_dict["tickets"] = tkt_list
> @@ -850,11 +854,19 @@ class BatchCreateTicketDialog(Component)
>
> # Template Stream Filter methods
> def filter_stream(self, req, method, filename, stream, data):
> - if (filename == 'bh_wiki_view.html') and (req.perm.has_permission(
> - 'TRAC_ADMIN') or
> req.perm.has_permission('TICKET_BATCH_CREATE')):
> + if (self.env.product is not None) and (filename ==
> 'bh_wiki_view.html') and (
> + req.perm.has_permission('TRAC_ADMIN') or
> req.perm.has_permission('TICKET_BATCH_CREATE')):
> add_script(req, 'theme/js/batchcreate.js')
> xpath = '//form[@id=modifypage]'
> - products = self.env.db_query("SELECT * FROM
> bloodhound_product")
> +
> + product_id = str(self.env.product.resource.id)
> +
> + product_name = self.env.db_query(
> + "SELECT * FROM bloodhound_product WHERE prefix=%s",
> (product_id,))
> + milestones = self.env.db_query(
> + "SELECT * FROM milestone WHERE product=%s", (product_id,))
> + components = self.env.db_query(
> + "SELECT * FROM component WHERE product=%s", (product_id,))
> form = tag.form(
> method="get",
> style="display:inline",
> @@ -872,7 +884,11 @@ class BatchCreateTicketDialog(Component)
>
> style="background-color:transparent;border:0;position:absolute;right:0;top:0;margin-top:
> 0px;height:29px;background-color:#5C85FF;color:white",
> type="button",
> onclick="Javascript:emptyTable(" +
> - to_json(products) +
> + to_json(product_name) +
> + "," +
> + to_json(milestones) +
> + "," +
> + to_json(components) +
> "," +
> to_json(
> req.href() +
> @@ -895,9 +911,15 @@ class BatchCreateTicketDialog(Component)
> def batch_create(self, req, attributes={}, notify=False):
> """ Create batch of tickets, returning created tickets.
> """
> - num_of_tkts = attributes.__len__() / 5
> + num_of_tkts = attributes.__len__() / 6
> created_tickets = []
> - for i in range(0, num_of_tkts):
> + loop_condition = True
> + i = -1
> +
> + while loop_condition:
> + i += 1
> + if 'summary' + str(i) not in attributes:
> + continue
>
> if 'product' + str(i) in attributes:
> env = self.env.parent or self.env
> @@ -909,11 +931,18 @@ class BatchCreateTicketDialog(Component)
> str(i)])
> else:
> env = self.env
> +
> + if attributes.get('summary' + str(i)) == "":
> + num_of_tkts -= 1
> + continue
> +
> description = attributes.pop('description' + str(i))
> - status = attributes.pop('status' + str(i))
> + status = 'new'
> summary = attributes.pop('summary' + str(i))
> product = attributes.pop('product' + str(i))
> priority = attributes.pop('priority' + str(i))
> + milestone = attributes.pop('milestone' + str(i))
> + component = attributes.pop('component' + str(i))
>
> t = Ticket(env)
> t['summary'] = summary
> @@ -923,6 +952,8 @@ class BatchCreateTicketDialog(Component)
> t['resolution'] = ''
> t['product'] = product
> t['priority'] = priority
> + t['milestone'] = milestone
> + t['component'] = component
> t.insert()
> created_tickets.append(t)
>
> @@ -935,7 +966,8 @@ class BatchCreateTicketDialog(Component)
> "Failure sending notification on creation "
> "of ticket #%s: %s" %
> (t.id, e))
> - # start_id = self.env.db_query("SELECT MAX(uid) FROM
> ticket")[0][0] - num_of_tkts
> - # created_tickets = self.env.db_query("SELECT * FROM ticket WHERE
> uid>%s"%start_id)
> - # return t['product'], t.id, created_tickets
> - return t['product'], t.id, created_tickets, num_of_tkts
> + num_of_tkts -= 1
> + if num_of_tkts <= 0:
> + loop_condition = False
> +
> + return t['product'], t.id, created_tickets
>
>
>
--
Dammina Sahabandu.
Committer for ASF (Apache Bloodhound)
Undergraduate Department of Computer Science and Engineering
University of Moratuwa
Sri Lanka.