Changeset 1291 in main


Ignore:
Timestamp:
07/02/12 12:17:26 (9 years ago)
Author:
zali
Message:

fixed cloning : clone objects without links

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/openPLM/plmapp/views/main.py

    r1287 r1291  
    14431443            formsets["doc_formset"] = forms.SelectDocumentFormset(prefix="documents", 
    14441444                initial=initial) 
    1445         elif issubclass(cls, models.Document) and is_linked : 
    1446             formsets["part_formset"] = forms.SelectPartFormset(queryset=parts) 
     1445        else: 
     1446            if issubclass(cls, models.Document) and is_linked : 
     1447                formsets["part_formset"] = forms.SelectPartFormset(queryset=parts) 
    14471448                 
    14481449    elif request.method == 'POST': 
    1449         if issubclass(cls, models.Part): 
     1450        if issubclass(cls, models.Part) and is_linked: 
    14501451            formsets.update({ 
    14511452                "children_formset":forms.SelectChildFormset(request.POST, 
     
    14541455                    prefix="document"), 
    14551456            }) 
    1456         else: 
     1457        elif is_linked: 
    14571458            formsets["part_formset"]=forms.SelectPartFormset(request.POST) 
    14581459        if creation_form is None: 
    14591460            creation_form = forms.get_creation_form(request.user, cls, request.POST) 
    14601461        if creation_form.is_valid(): 
    1461             valid_forms = False 
    1462             if issubclass(cls, models.Part) and is_linked: 
    1463                 valid_forms, selected_children, selected_documents = clone_part(creation_form, request.user, request.POST, children, documents) 
    1464                 if valid_forms : 
    1465                     new_ctrl = obj.clone(creation_form, request.user, selected_children, selected_documents) 
    1466                     return HttpResponseRedirect(new_ctrl.plmobject_url) 
    1467                 else : 
    1468                     formsets.update({ 
    1469                         "children_formset":forms.SelectChildFormset(request.POST, 
    1470                             prefix="children"), 
    1471                         "doc_formset": forms.SelectDocumentFormset(request.POST, 
    1472                             prefix="document"), 
    1473                     }) 
    1474             elif issubclass(cls, models.Document) and is_linked : 
    1475                 valid_forms, selected_parts = clone_document(creation_form, request.user, request.POST, parts) 
    1476                 if valid_forms: 
    1477                     new_ctrl = obj.clone(creation_form, request.user, selected_parts) 
    1478                     return HttpResponseRedirect(new_ctrl.plmobject_url)  
    1479                 else : 
    1480                     formsets["part_formset"]=forms.SelectPartFormset(request.POST) 
     1462            if is_linked : 
     1463                valid_forms = False 
     1464                if issubclass(cls, models.Part) : 
     1465                    valid_forms, selected_children, selected_documents = clone_part(creation_form, request.user, request.POST, children, documents) 
     1466                    if valid_forms : 
     1467                        new_ctrl = obj.clone(creation_form, request.user, selected_children, selected_documents) 
     1468                        return HttpResponseRedirect(new_ctrl.plmobject_url) 
     1469                    else : 
     1470                        formsets.update({ 
     1471                            "children_formset":forms.SelectChildFormset(request.POST, 
     1472                                prefix="children"), 
     1473                            "doc_formset": forms.SelectDocumentFormset(request.POST, 
     1474                                prefix="document"), 
     1475                        }) 
     1476                elif issubclass(cls, models.Document) and is_linked : 
     1477                    valid_forms, selected_parts = clone_document(creation_form, request.user, request.POST, parts) 
     1478                    if valid_forms: 
     1479                        new_ctrl = obj.clone(creation_form, request.user, selected_parts) 
     1480                        return HttpResponseRedirect(new_ctrl.plmobject_url)  
     1481                    else : 
     1482                        formsets["part_formset"]=forms.SelectPartFormset(request.POST) 
     1483            else: 
     1484                if issubclass(cls, models.Part): 
     1485                    new_ctrl = obj.clone(creation_form, request.user, [], []) 
     1486                else: 
     1487                    new_ctrl = obj.clone(creation_form, request.user, []) 
     1488                return HttpResponseRedirect(new_ctrl.plmobject_url) 
    14811489    ctx.update({ 
    14821490        'creation_form':creation_form, 
     
    21372145        obj, ctx = get_generic_data(self.request, search=False) 
    21382146        ctx["type"] = self.request.session["type"] 
    2139         ctx["object_type"] = "Search" 
     2147        ctx["object_type"] = _("Search") 
    21402148        extra.update(ctx) 
    21412149        return extra 
Note: See TracChangeset for help on using the changeset viewer.