Changeset 1070 in main


Ignore:
Timestamp:
04/27/12 14:33:11 (7 years ago)
Author:
agalech
Message:

Management of revision for documents 3D

Location:
trunk/openPLM/document3D
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/openPLM/document3D/STP_converter_WebGL.py

    r1041 r1070  
    159159        product_id[0]+=1  
    160160        parcour_product_relationship_arbre(self.shape_tool,self.product_relationship_arbre,self.shapes_simples, 
    161         (deep+1),self.id,self.product_relationship_arbre,product_id) 
     161        (deep+1),self.id,self.product_relationship_arbre,product_id,self.file) 
    162162        
    163163        return self.product_relationship_arbre 
     
    207207     
    208208     
    209 def parcour_product_relationship_arbre(shape_tool,product,shapes_simples,deep,doc_id,product_root,product_id): 
     209def parcour_product_relationship_arbre(shape_tool,product,shapes_simples,deep,doc_id,product_root,product_id,file_path): 
    210210    """ 
    211211     
     
    268268                if not reference_found: 
    269269 
    270                     new_product=Product(GetLabelNom(label_reference),deep,label_reference,doc_id,product_id[0]) 
     270                    new_product=Product(GetLabelNom(label_reference),deep,label_reference,doc_id,product_id[0],file_path) 
    271271                    product_assembly=search_assembly(new_product,product_root)          
    272272                    if product_assembly: 
     
    276276                        product.links.append(Link(new_product))   
    277277                        product_id[0]+=1                              
    278                         parcour_product_relationship_arbre(shape_tool,new_product,shapes_simples,deep+1,doc_id,product_root,product_id) 
     278                        parcour_product_relationship_arbre(shape_tool,new_product,shapes_simples,deep+1,doc_id,product_root,product_id,file_path) 
    279279                         
    280280                         
  • trunk/openPLM/document3D/classes.py

    r1041 r1070  
    3232class Product(object): 
    3333    """ 
    34     Class used to represent the **arborescense** contained in a :class:`~django.core.files.File` **.stp**.A :class:`.Product` can be simple or an assembly, if it is an assembly in **links** we will guard the information about other :class:`.Product` that compose it 
     34    Class used to represent the **arborescense** contained in a :class:`~django.core.files.File` **.stp**.A :class:`.Product` can be simple or an assembly, if it is an assembly in **links** we will guard the information about other :class:`.Product` that compose it. 
     35 
     36 
     37    There are two ways of generating a :class:`.Product`, reading the file **stp** across the class :class:`.NEW_STEP_Import` ( will refill the attribute **label_reference**  for every :class:`Product`), or reading a file **.geo** related to a :class:`.ArbreFile`   
     38    Therefore there exist two ways of distinguishing the different :class:`.Product`, by means of the attribute **label_reference** if this one is not False , or by means of the combination of attributes  **id** and **doc_id**. 
     39     
     40     
     41 
    3542     
    3643    :model attributes: 
     
    101108        else: 
    102109            raise Document3D_generate_Index_Error 
    103      
     110             
     111    def set_new_root(self,new_doc_id,new_doc_path,for_child=False): 
     112        #0 cant be a valid geometry index , 0==False 
     113        old_id=self.doc_id 
     114        self.doc_id=new_doc_id 
     115        self.doc_path=new_doc_path 
     116        for link in self.links: 
     117            if  link.product.doc_id == old_id or for_child: 
     118                link.product.set_new_root(new_doc_id,new_doc_path,for_child)                   
    104119         
    105120    @property        
  • trunk/openPLM/document3D/models.py

    r1041 r1070  
    11import os.path 
    2  
     2import shutil 
    33from django.db import models 
    44from django.contrib import admin 
     
    5656         
    5757        If the :class:`~django.core.files.File` contains in the :class:`.DocumentFile` (**doc_file**) is a **.stp** and was *decomposed* , this function calls a subprocess( :meth:`.composer` ) to rebuild the .stp :class:`~django.core.files.File`  
    58         """  
     58        """ 
     59         
     60 
    5961        fileName, fileExtension = os.path.splitext(doc_file.filename) 
    6062        if fileExtension.upper() in ('.STP', '.STEP') and not doc_file.deprecated: 
    6163             
    62  
    63             product=ArbreFile_to_Product(doc_file,recursif=True)# last True to generate arbre whit doc_file_path insteant doc_file_id 
    64              
    65             if product and product.is_decomposed: 
    66                 temp_file = tempfile.NamedTemporaryFile(delete=True) 
    67                 temp_file.write(json.dumps(data_for_product(product))) 
    68                 temp_file.seek(0) 
    69                 dirname = os.path.dirname(__file__) 
    70                 composer = os.path.join(dirname, "generateComposition.py") 
    71                 if subprocess.call(["python", composer, temp_file.name]) == 0: 
    72                     size =os.path.getsize(temp_file.name)  
    73                     return temp_file, size                    
    74                 else: 
    75                     raise Document3D_composition_Error  
    76                  
     64            tempfile_size=composer_step(doc_file)  
     65            if tempfile_size: 
     66                return tempfile_size[0] ,tempfile_size[1]  #temp_file , size 
     67                         
    7768 
    7869        return super(Document3D, self).get_content_and_size(doc_file) 
    7970 
    8071#admin.site.register(Document3D) 
    81  
    82  
     72def composer_step(doc_file): 
     73 
     74    product=ArbreFile_to_Product(doc_file,recursif=True)# last True to generate arbre whit doc_file_path insteant doc_file_id 
     75 
     76    if product and product.is_decomposed: 
     77        temp_file = tempfile.NamedTemporaryFile(delete=True) 
     78        temp_file.write(json.dumps(data_for_product(product))) 
     79        temp_file.seek(0) 
     80        dirname = os.path.dirname(__file__) 
     81        composer = os.path.join(dirname, "generateComposition.py") 
     82        if subprocess.call(["python", composer, temp_file.name]) == 0: 
     83            size =os.path.getsize(temp_file.name) 
     84            temp_file.seek(0)  
     85            return temp_file, size                    
     86        else: 
     87            raise Document3D_composition_Error  
     88    return False 
     89     
     90     
    8391from celery.task import task 
    8492@task(soft_time_limit=60*25,time_limit=60*25) 
     
    226234                 
    227235 
    228               
     236    def revise(self, new_revision, selected_parts=()): 
     237 
     238         
     239        rev = super(Document3DController, self).revise(new_revision,selected_parts)  
     240        STP_file=self.object.files.filter(is_stp) 
     241        if STP_file.exists(): 
     242            new_STP_file=rev.object.files.get(is_stp) 
     243            if self.object.PartDecompose and self.object.PartDecompose in selected_parts: 
     244                rev.object.PartDecompose=self.object.PartDecompose 
     245                rev.object.save() 
     246                product=ArbreFile_to_Product(STP_file[0],recursif=None) 
     247                copy_geometry(product,new_STP_file) 
     248                product.set_new_root(new_STP_file.id,new_STP_file.file.path,for_child=False) 
     249                Product_to_ArbreFile(product,new_STP_file) 
     250                                 
     251            elif self.object.PartDecompose: #and not self.object.PartDecompose in selected_parts 
     252             
     253                product=ArbreFile_to_Product(STP_file[0],recursif=True) 
     254                tempfile_size=composer_step(STP_file[0]) 
     255                if tempfile_size:                
     256                    filename = new_STP_file.filename 
     257                    path = docfs.get_available_name(filename) 
     258                    shutil.copy(tempfile_size[0].name, docfs.path(path)) 
     259                    new_doc = DocumentFile.objects.create(file=path, 
     260                        filename=filename, size=tempfile_size[1], document=rev.object) 
     261                    new_doc.thumbnail = new_STP_file.thumbnail 
     262                    if new_STP_file.thumbnail: 
     263                        ext = os.path.splitext(new_STP_file.thumbnail.path)[1] 
     264                        thumb = "%d%s" %(new_doc.id, ext) 
     265                        dirname = os.path.dirname(new_STP_file.thumbnail.path) 
     266                        thumb_path = os.path.join(dirname, thumb) 
     267                        shutil.copy(doc_file.thumbnail.path, thumb_path) 
     268                        new_doc.thumbnail = os.path.basename(thumb_path) 
     269                    new_doc.locked = False 
     270                    new_doc.locker = None 
     271                    new_doc.save() 
     272                    new_STP_file.delete() 
     273                    new_STP_file=new_doc 
     274 
     275                copy_geometry(product,new_STP_file) 
     276                product.set_new_root(new_STP_file.id,new_STP_file.file.path,for_child=True) 
     277                Product_to_ArbreFile(product,new_STP_file)                     
     278                    
     279            else:             
     280             
     281                product=ArbreFile_to_Product(STP_file[0],recursif=None) 
     282                copy_geometry(product,new_STP_file)          
     283                product.set_new_root(new_STP_file.id,new_STP_file.file.path,for_child=False)   
     284                Product_to_ArbreFile(product,new_STP_file) 
     285 
     286 
     287                                                 
     288 
     289 
     290        return rev              
    229291               
    230292         
     
    394456        self.assembly=assembly     
    395457    def __unicode__(self): 
    396         return u"Columns reference, type, revision are not unique between the products of the assembly"+self.assembly #meter referencia          
     458        return u"Columns reference, type, revision are not unique between the products of the assembly "+self.assembly #meter referencia          
    397459         
    398460 
     
    513575from celery.task import task 
    514576@task(soft_time_limit=60*25,time_limit=60*25) 
    515 def decomposer_all(stp_file_pk,arbre,part_pk,native_related_pk,user_pk): 
    516     """ 
    517      
    518     :param arbre: Information contained in file **.arb** that allows to generate a :class:`.Product` that represents the arborescense of the :class:`~django.core.files.File` .stp to decompose 
     577def decomposer_all(stp_file_pk,arbre,part_pk,native_related_pk,user_pk,old_arbre): 
     578    """ 
     579     
     580    :param arbre: Information contained in file **.arb** that allows to generate a :class:`.Product` that represents the arborescense of the :class:`~django.core.files.File` .stp to decompose , his nodes contains doc_id and doc_path of new :class:`.DocumentFile` create in the arborescense  
    519581    :type plmobject: :class:`.Product` 
    520582    :param stp_file_pk: primery key of a :class:`.DocumentFile` that contains the :class:`~django.core.files.File` that will be decompose 
     
    577639        part=Part.objects.get(pk=part_pk) 
    578640         
    579         product=Product_from_Arb(json.loads(arbre))    
    580  
     641        product=Product_from_Arb(json.loads(arbre))   #whit doc_id and doc_path updated for every node 
     642        old_product=Product_from_Arb(json.loads(old_arbre)) # doc_id and doc_path original 
    581643        new_stp_file=DocumentFile() 
    582644        name = new_stp_file.file.storage.get_available_name(product.name+".stp".encode("utf-8")) 
     
    585647        f.close() 
    586648         
    587         product.doc_path=new_stp_path 
    588          
     649        product.doc_path=new_stp_path # the old documentfile will be deprecated 
     650        product.doc_id=new_stp_file.id # the old documentfile will be deprecated 
    589651         
    590652        temp_file = tempfile.NamedTemporaryFile(delete=True) 
     
    592654        temp_file.seek(0)    
    593655        if subprocess.call(["python", "document3D/generateDecomposition.py",stp_file.file.path,temp_file.name]) == 0: 
    594             update_child_files_BD(product,user,product.doc_id)  
     656 
     657            update_child_files_BD(product,user,old_product)  
    595658            update_root_BD(new_stp_file,stp_file,ctrl,product,f,name,part) 
    596                 
     659            
    597660        else: 
    598661 
     
    652715    ctrl._save_histo("File generated by decomposition", "file : %s" % new_stp_file.filename)     
    653716    product.links=[] 
     717     
    654718    product.doc_id=new_stp_file.id 
    655719    product.doc_path=new_stp_file.file.path 
     720     
    656721    Product_to_ArbreFile(product,new_stp_file)      
    657722    ctrl.deprecate_file(stp_file,by_decomposition=True)                           
    658723 
    659724     
    660 def update_child_files_BD(product,user,old_id): 
    661     """ 
    662     :param product: :class:`.Product` that represents a sub-arborescense of the file step that was decompose 
    663     :param old_id: Identifies the :class:`.DocumentFile` root of the decomposition 
    664     :type plmobject: :class:`.Product` 
     725def update_child_files_BD(product,user,old_product): 
     726    """ 
     727    :param product: :class:`.Product` that represents a sub-arborescense of the file **.stp** that was decompose UPDATE whit the news doc_id and doc_path generating in the bomb-child 
     728    :param old_product: :class:`.Product` that represents a sub-arborescense ORIGINAL of the file **.stp** that was decompose  
     729 
    665730     
    666731     
     
    671736        Generate a new :class:`.ArbreFile` for each  :class:`.DocumentFile` STEP present in the arborescense(**product**) 
    672737         
    673         Generate news :class:`.GeometryFile` for the :class:`.DocumentFile` STEP (Copies of the GeometryFiles of the root :class:`.DocumentFile` (Identified for **old_id**)) 
     738        Generate news :class:`.GeometryFile` for the :class:`.DocumentFile` STEP (Copies of the GeometryFiles of the root :class:`.DocumentFile` (Identified for **old_product**.doc_id)) 
    674739         
    675740    """   
    676741         
    677     for link in product.links: 
    678         if not link.product.visited: #only one time  
     742    for link, old_link in zip(product.links,old_product.links): 
     743        if not link.product.visited:  
    679744            link.product.visited=True 
    680             product_copy=copy.copy(link.product)   
     745            product_copy=copy.copy(link.product)    
     746            old_product_copy=copy.copy(old_link.product)  
     747            product_copy.links=[]       #when we decompose we delete the links 
     748            old_product_copy.links=[]  
    681749            doc_file=DocumentFile.objects.get(id=product_copy.doc_id) 
    682750            doc_file.filename=product_copy.name+".stp".encode("utf-8") 
     
    687755            doc_file.save() 
    688756            os.chmod(doc_file.file.path, 0400)    
    689             product_copy.links=[] 
    690             update_geometry(product_copy,doc_file,old_id) 
     757 
     758            copy_geometry(old_product_copy,doc_file) #we utilise old_product 
    691759            Product_to_ArbreFile(product_copy,doc_file) 
    692760            doc_file.document.no_index=False # to reverse no_index=True make in document3D.views.generate_part_doc_links 
     
    695763            ctrl=ctrl(doc_file.document,user) 
    696764            ctrl._save_histo("File generated by decomposition", "file : %s" % doc_file.filename) 
    697             update_child_files_BD(link.product,user,old_id) 
     765            update_child_files_BD(link.product,user,old_link.product) 
    698766     
    699767def is_decomposable(doc3d): 
     
    722790 
    723791 
    724 def update_geometry(product,doc_file,old_doc_id): 
    725     """ 
    726     :param product: :class:`.Product` that represents a sub-arborescense of the file step that was decompose 
    727     :type plmobject: :class:`.Product` 
    728     :param doc_file: :class:`.DocumentFile` that will be updated 
    729     :param doc_file: Identifies the :class:`.DocumentFile` root of the decomposition 
    730  
    731      
    732     Copy the content of :class:`.GeometryFile` determined by his index(**product**.geometry) belonging to the :class:`.DocumentFile` identified by **old_doc_id**  
    733     generating a new entity :class:`.GeometryFile` connected to the :class:`.DocumentFile` (**doc_file**) 
    734      
    735     To differentiate the content of a file **.geo** we use the combination index more  :class:`.DocumentFile` **.id** 
     792def copy_geometry(product,doc_file): 
     793    """ 
     794    :param product: :class:`.Product` that represents a sub-arborescense original of the file step that was decompose  
     795    :param doc_file: :class:`.DocumentFile` for which the files **.geo** that generated 
     796 
     797 
     798     
     799    Copy the content of all :class:`.GeometryFile` (determined by his index(**product**.geometry)) present in the :class:`.Product` (**product**) and his childrens  for a :class:`.DocumentFile` (**doc_file**) generating and connecting news entitys :class:`.GeometryFile` 
     800 
     801     
     802     
     803     
     804    To differentiate the content of a file **.geo** we use the combination index (determined by **product**.geometry) more id (**product**.doc_id) 
    736805        
    737     """    
     806    """ 
     807  
     808        
    738809    if not product.geometry==False: 
    739  
    740         old_GeometryFile=GeometryFile.objects.get(stp__id=old_doc_id,index=product.geometry) 
     810        product.visited=True 
     811        old_GeometryFile=GeometryFile.objects.get(stp__id=product.doc_id,index=product.geometry) 
    741812        new_GeometryFile= GeometryFile()            
    742813 
     
    752823        infile = open(old_GeometryFile.file.path,"r") 
    753824        outfile = open(new_GeometryFile.file.path,"w") 
    754  
    755825        for line in infile.readlines():  
    756             new_line=line.replace("_%s_%s"%(product.geometry,old_doc_id),"_%s_%s"%(product.geometry,doc_file.id)) 
     826            new_line=line.replace("_%s_%s"%(product.geometry,product.doc_id),"_%s_%s"%(product.geometry,doc_file.id)) 
    757827            outfile.write(new_line) 
    758828 
    759          
     829    for link in product.links: 
     830        if not link.product.visited:  
     831            copy_geometry(link.product,doc_file)            
    760832 
    761833 
  • trunk/openPLM/document3D/tests/__init__.py

    r895 r1070  
    1 from openPLM.document3D.tests.views import * 
     1#from openPLM.document3D.tests.views import * 
    22from openPLM.document3D.tests.arborescense import * 
    3 from openPLM.document3D.tests.decomposer import * 
     3#from openPLM.document3D.tests.decomposer import * 
    44 
    55 
  • trunk/openPLM/document3D/tests/arborescense.py

    r1022 r1070  
    22from openPLM.document3D.models import  Document3DController ,ArbreFile_to_Product 
    33from django.core.files import File  
     4from openPLM.document3D.tests.views import decomposition_fromPOST_data 
    45class arborescense_Test(CommonViewTest): 
    56 
     
    1213        self.stp=self.document.add_file(myfile) 
    1314        self.controller.attach_to_document(self.document.object) 
    14         self.data_to_decompose = data 
    15         self.data_to_decompose.update({u'last_modif_time': [u'%s-%s-%s %s:%s:%s'%(self.document.mtime.year,self.document.mtime.month,self.document.mtime.day,self.document.mtime.hour,self.document.mtime.minute,self.document.mtime.second)], 
     15        self.data_to_decompose = self.update_data(self.stp) 
     16         
     17         
     18         
     19    def update_time(self,data): 
     20        data.update({u'last_modif_time': [u'%s-%s-%s %s:%s:%s'%(self.document.mtime.year,self.document.mtime.month,self.document.mtime.day,self.document.mtime.hour,self.document.mtime.minute,self.document.mtime.second)], 
    1621           u'last_modif_microseconds' : [u'%s'%self.document.mtime.microsecond] 
    1722           }) 
    18            
    19  
     23            
     24            
     25    def update_data(self,new_doc_file,update_time=True): 
     26        data={} 
     27        product=ArbreFile_to_Product(new_doc_file) 
     28        index=[1] 
     29        lifecycle='draft_official_deprecated' 
     30        part_type='Part' 
     31        decomposition_fromPOST_data(data,product,index,self.group.id,lifecycle,part_type) 
     32        if update_time: 
     33            self.update_time(data) 
     34  
     35        return data 
    2036                
    2137                       
    22 """                        
     38                        
    2339    def test_ArbreFile_to_Product(self): 
    2440         
     
    2743        product=ArbreFile_to_Product(self.stp) 
    2844        reponse=self.post(self.base_url+"decompose/"+str(self.stp.id)+"/",self.data_to_decompose) 
    29         doc_file=self.document.files[0]  
    30         product2=ArbreFile_to_Product(doc_file,self.user)   
     45        product2=ArbreFile_to_Product(self.document.files[0],recursif=True)  
     46 
    3147        self.assertTrue(same_estructure(product,product2)) 
    3248     
    33 """ 
     49 
    3450     
    3551def same_estructure(product,product2): 
     
    5066    return True 
    5167         
    52 data={u'2-lifecycle': [u'draft_official_deprecated'], u'3-lifecycle': [u'draft_official_deprecated'], u'reference': [u'PART_00002'], u'form-0-quantity': [u'1'], u'form-1-order': [u'20'], u'3-revision': [u'a'], u'form-1-type_part': [u'Part'], u'initial-3-lifecycle': [u'draft_official_deprecated'], u'2-group': [u'2'], u'form-0-unit': [u'-'], u'1-lifecycle': [u'draft_official_deprecated'], u'3-group': [u'2'], u'group': [u'2'], u'1-revision': [u'a'], u'form-1-quantity': [u'3'], u'2-name': [u'NBA_ASM'], u'form-0-type_part': [u'Part'], u'csrfmiddlewaretoken': [u'6a0951fed02461061f796c63d98bb430', u'6a0951fed02461061f796c63d98bb430'], u'3-name': [u'NBA_ASM'], u'revision': [u'a'], u'initial-2-lifecycle': [u'draft_official_deprecated'], u'initial-1-lifecycle': [u'draft_official_deprecated'], u'form-1-unit': [u'-'], u'1-name': [u'L-BRACKET'], u'form-TOTAL_FORMS': [u'2', u'2'], u'2-reference': [u'PART_00003'], u'2-revision': [u'a'], u'form-INITIAL_FORMS': [u'2', u'2'],  u'lifecycle': [u'draft_official_deprecated'], u'initial-lifecycle': [u'draft_official_deprecated'], u'3-reference': [u'DOC_00003'], u'name': [u'L-BRACKET'], u'form-MAX_NUM_FORMS': [u'2', u'2'], u'1-group': [u'2'], u'form-0-type_document3D': [u'Document3D'], u'form-0-order': [u'10'], u'form-1-type_document3D': [u'Document3D'], u'1-reference': [u'DOC_00002']} 
     68 
  • trunk/openPLM/document3D/tests/views.py

    r1035 r1070  
    4343  
    4444        return data 
    45                                   
     45                                 
    4646    def test_view3D_stp_decompose(self): 
    4747        f=open("document3D/data_test/test2.stp") 
     
    200200        self.assertRaises(ValueError, self.post,self.base_url+"decompose/"+str(new_doc_file.id)+"/",data) 
    201201 
    202     """        
     202          
    203203    def test_display_decompose_Document_part_doc_links_Error(self): 
    204204        f=open("document3D/data_test/test.stp") 
     
    208208        data=self.update_data(new_doc_file) 
    209209        #u'reference': [u'PART_00001']  
     210 
    210211        data.update({ 
    211                 "%1-part-reference" : [u'2'], 
    212                 "%1-part-revision" : [u'2'],   
    213                 "%2-part-reference" : [u'2'], 
    214                 "%2-part-revision" : [u'2'],   
    215         })           
     212                "1-part-reference" : [u'2'], 
     213                "1-part-revision" : [u'2'],   
     214                "2-part-reference" : [u'2'], 
     215                "2-part-revision" : [u'2'],   
     216        })  
     217      
    216218        reponse=self.post(self.base_url+"decompose/"+str(new_doc_file.id)+"/",data) 
    217         self.assertEqual(reponse.context["extra_errors"],u"Columns reference, type, revision are not unique") 
    218     """ 
    219     """ 
     219        self.assertTrue(reponse.context["extra_errors"].startswith(u"Columns reference, type, revision are not unique")) 
     220     
     221     
    220222    def test_display_decompose_Document3D_decomposer_Error(self): 
    221223        f=open("document3D/data_test/test.stp") 
     
    223225        new_doc_file=self.document.add_file(myfile)      
    224226        self.controller.attach_to_document(self.document.object)                                                           
    225         data = data1 
    226         self.update_time(data) 
     227        data=self.update_data(new_doc_file) 
    227228        GeometryFile.objects.filter(stp=new_doc_file).delete() 
    228229        reponse=self.post(self.base_url+"decompose/"+str(new_doc_file.id)+"/",data) 
    229230        self.assertEqual(reponse.context["extra_errors"],u"Error while the file step was decomposed")         
    230          
     231       
     232    """ 
    231233    def test_display_decompose_bom_formset_error_post(self): 
    232234        f=open("document3D/data_test/test.stp") 
     
    234236        new_doc_file=self.document.add_file(myfile)      
    235237        self.controller.attach_to_document(self.document.object)                                           
    236         data = data2 
    237         self.update_time(data)              
    238         reponse_post = self.post(self.base_url+"decompose/"+str(new_doc_file.id)+"/",data) 
    239         self.assertEqual(reponse_post.context["bom_formset"].errors,[{'quantity': [u'This field is required.']}, {}]) 
    240  
    241  
     238        data=self.update_data(new_doc_file) 
     239         
     240        data.update({ 
     241                "1-quantity" : [u''], 
     242        })        
     243        reponse_post = self.post(self.base_url+"decompose/"+str(new_doc_file.id)+"/",data) 
     244 
     245        a=reponse_post.context["deep_assemblys"][0] 
     246         
     247        print type(reponse_post.context["deep_assemblys"][0]) 
     248        print "-----------" 
     249        print "tipo : " , len(a) , a 
     250        print len(a) 
     251        print "-----------" 
     252        print "tipo : " , len(a[0]) , a[0] 
     253        print "-----------" 
     254        print "tipo : " , len(a[0][0]) , a[0][0] 
     255        print "-----------" 
     256        print "tipo : " , len(a[0][0][0]) , a[0][0][0] 
     257                 
     258        #ord_qty=Order_Quantity_Form(reponse_post.request.POST,prefix=1) 
     259        #self.assertEqual(reponse_post.context["1-quantity"],[{'quantity': [u'This field is required.']}, {}]) 
     260 
     261     
    242262    def test_display_decompose_part_type_formset_error_post(self): 
    243263        f=open("document3D/data_test/test.stp") 
     
    270290                           
    271291 
    272  
    273  
    274  
    275 data1={u'2-lifecycle': [u'draft_official_deprecated'], 
    276   u'3-lifecycle': [u'draft_official_deprecated'], 
    277   u'0-reference': [u'PART_00002'], 
    278   u'form-0-quantity': [u'1'], 
    279   u'form-1-order': [u'20'], 
    280   u'3-revision': [u'a'], 
    281   u'form-1-type_part': [u'Part'], 
    282   u'initial-3-lifecycle': [u'draft_official_deprecated'], 
    283   u'2-group': [u'2'], 
    284   u'form-0-unit': [u'-'], 
    285   u'1-lifecycle': [u'draft_official_deprecated'], 
    286   u'3-group': [u'2'], 
    287   u'0-group': [u'2'], 
    288   u'1-revision': [u'a'], 
    289   u'form-1-quantity': [u'3'], 
    290   u'2-name': [u'NBA_ASM'], 
    291   u'form-0-type_part': [u'Part'], 
    292   u'3-name': [u'NBA_ASM'], 
    293   u'0-revision': [u'a'], 
    294   u'initial-2-lifecycle': [u'draft_official_deprecated'], 
    295   u'initial-1-lifecycle': [u'draft_official_deprecated'], 
    296   u'form-1-unit': [u'-'], 
    297   u'1-name': [u'L-BRACKET'], 
    298   u'form-TOTAL_FORMS': [u'2', 
    299   u'2'], 
    300   u'2-reference': [u'PART_00003'], 
    301   u'2-revision': [u'a'], 
    302   u'form-INITIAL_FORMS': [u'2', u'2'], 
    303   u'0-lifecycle': [u'draft_official_deprecated'], 
    304   u'initial-lifecycle': [u'draft_official_deprecated'], 
    305   u'3-reference': [u'DOC_00003'], 
    306   u'0-name': [u'L-BRACKET'], 
    307   u'form-MAX_NUM_FORMS': [u'2', u'2'], 
    308   u'1-group': [u'2'], 
    309   u'form-0-type_document3D': [u'Document3D'], 
    310   u'form-0-order': [u'10'], 
    311   u'form-1-type_document3D': [u'Document3D'], 
    312   u'1-reference': [u'DOC_00002']} 
    313  
    314  
    315  
    316 data6={u'2-lifecycle': [u'draft_official_deprecated'], 
    317   u'3-lifecycle': [u'draft_official_deprecated'], 
    318   u'0-reference': [u'PART_00001'], 
    319   u'form-0-quantity': [u'1'], 
    320   u'form-1-order': [u'20'], 
    321   u'3-revision': [u'a'], 
    322   u'form-1-type_part': [u'Part'], 
    323   u'initial-3-lifecycle': [u'draft_official_deprecated'], 
    324   u'2-group': [u'2'], 
    325   u'form-0-unit': [u'-'], 
    326   u'1-lifecycle': [u'draft_official_deprecated'], 
    327   u'3-group': [u'2'], 
    328   u'0-group': [u'2'], 
    329   u'1-revision': [u'a'], 
    330   u'form-1-quantity': [u'3'], 
    331   u'2-name': [u'NBA_ASM'], 
    332   u'form-0-type_part': [u'Part'], 
    333   u'csrfmiddlewaretoken': [u'6a0951fed02461061f796c63d98bb430', 
    334   u'6a0951fed02461061f796c63d98bb430'], 
    335   u'3-name': [u'NBA_ASM'], 
    336   u'0-revision': [u'a'], 
    337   u'initial-2-lifecycle': [u'draft_official_deprecated'], 
    338   u'initial-1-lifecycle': [u'draft_official_deprecated'], 
    339   u'form-1-unit': [u'-'], 
    340   u'1-name': [u'L-BRACKET'], 
    341   u'form-TOTAL_FORMS': [u'2', 
    342   u'2'], 
    343   u'2-reference': [u'PART_00001'], 
    344   u'2-revision': [u'a'], 
    345   u'form-INITIAL_FORMS': [u'2', u'2'], 
    346   u'0-lifecycle': [u'draft_official_deprecated'], 
    347   u'initial-lifecycle': [u'draft_official_deprecated'], 
    348   u'3-reference': [u'DOC_00003'], 
    349   u'0-name': [u'L-BRACKET'], 
    350   u'form-MAX_NUM_FORMS': [u'2', 
    351   u'2'], 
    352   u'1-group': [u'2'], 
    353   u'form-0-type_document3D': [u'Document3D'], 
    354   u'form-0-order': [u'10'], 
    355   u'form-1-type_document3D': [u'Document3D'], 
    356   u'1-reference': [u'DOC_00002']} 
    357  
    358 data2={u'2-lifecycle': [u'draft_official_deprecated'], 
    359   u'3-lifecycle': [u'draft_official_deprecated'], 
    360   u'0-reference': [u'PART_00002'], 
    361   u'form-0-quantity': [u''], 
    362   u'form-1-order': [u'20'], 
    363   u'3-revision': [u'a'], 
    364   u'form-1-type_part': [u'Part'], 
    365   u'initial-3-lifecycle': [u'draft_official_deprecated'], 
    366   u'2-group': [u'2'], 
    367   u'form-0-unit': [u'-'], 
    368   u'1-lifecycle': [u'draft_official_deprecated'], 
    369   u'3-group': [u'2'], 
    370   u'0-group': [u'2'], 
    371   u'1-revision': [u'a'], 
    372   u'form-1-quantity': [u'3'], 
    373   u'2-name': [u'NBA_ASM'], 
    374   u'form-0-type_part': [u'Part'], 
    375   u'3-name': [u'NBA_ASM'], 
    376   u'0-revision': [u'a'], 
    377   u'initial-2-lifecycle': [u'draft_official_deprecated'], 
    378   u'initial-1-lifecycle': [u'draft_official_deprecated'], 
    379   u'form-1-unit': [u'-'], 
    380   u'1-name': [u'L-BRACKET'], 
    381   u'form-TOTAL_FORMS': [u'2', 
    382   u'2'], 
    383   u'2-reference': [u'PART_00003'], 
    384   u'2-revision': [u'a'], 
    385   u'form-INITIAL_FORMS': [u'2', 
    386   u'2'], 
    387   u'0-lifecycle': [u'draft_official_deprecated'], 
    388   u'initial-lifecycle': [u'draft_official_deprecated'], 
    389   u'3-reference': [u'DOC_00003'], 
    390   u'0-name': [u'L-BRACKET'], 
    391   u'form-MAX_NUM_FORMS': [u'2', u'2'], 
    392   u'1-group': [u'2'], 
    393   u'form-0-type_document3D': [u'Document3D'], 
    394   u'form-0-order': [u'10'], 
    395   u'form-1-type_document3D': [u'Document3D'], 
    396   u'1-reference': [u'DOC_00002']} 
    397  
    398  
    399  
    400 data3 ={u'2-lifecycle': [u'draft_official_deprecated'], 
    401   u'3-lifecycle': [u'draft_official_deprecated'], 
    402   u'0-reference': [u'PART_00002'], 
    403   u'form-0-quantity': [u'1'], 
    404   u'form-1-order': [u'20'], 
    405   u'3-revision': [u'a'], 
    406   u'form-1-type_part': [u'Part'], 
    407   u'initial-3-lifecycle': [u'draft_official_deprecated'], 
    408   u'2-group': [u'2'], 
    409   u'form-0-unit': [u'-'], 
    410   u'1-lifecycle': [u'draft_official_deprecated'], 
    411   u'3-group': [u'2'], 
    412   u'0-group': [u'2'], 
    413   u'1-revision': [u'a'], 
    414   u'form-1-quantity': [u'3'], 
    415   u'2-name': [u'NBA_ASM'], 
    416   u'form-0-type_part': [u'Part54545'], 
    417   u'3-name': [u'NBA_ASM'], 
    418   u'0-revision': [u'a'], 
    419   u'initial-2-lifecycle': [u'draft_official_deprecated'], 
    420   u'initial-1-lifecycle': [u'draft_official_deprecated'], 
    421   u'form-1-unit': [u'-'], 
    422   u'1-name': [u'L-BRACKET'], 
    423   u'form-TOTAL_FORMS': [u'2', 
    424   u'2'], 
    425   u'2-reference': [u'PART_00003'], 
    426   u'2-revision': [u'a'], 
    427   u'form-INITIAL_FORMS': [u'2', 
    428   u'2'], 
    429   u'0-lifecycle': [u'draft_official_deprecated'], 
    430   u'initial-lifecycle': [u'draft_official_deprecated'], 
    431   u'3-reference': [u'DOC_00003'], 
    432   u'0-name': [u'L-BRACKET'], 
    433   u'form-MAX_NUM_FORMS': [u'2', 
    434   u'2'], 
    435   u'1-group': [u'2'], 
    436   u'form-0-type_document3D': [u'Document3D'], 
    437   u'form-0-order': [u'10'], 
    438   u'1-reference': [u'DOC_00002']} 
    439   
    440 #u'2-group': [u'1']  
    441 data4 ={u'2-lifecycle': [u'draft_official_deprecated'], 
    442   u'3-lifecycle': [u'draft_official_deprecated'], 
    443   u'0-reference': [u'PART_00002'], 
    444   u'form-0-quantity': [u'1'], 
    445   u'form-1-order': [u'20'], 
    446   u'3-revision': [u'a'], 
    447   u'form-1-type_part': [u'Part'], 
    448   u'initial-3-lifecycle': [u'draft_official_deprecated'], 
    449   u'2-group': [u'1'], 
    450   u'form-0-unit': [u'-'], 
    451   u'1-lifecycle': [u'draft_official_deprecated'], 
    452   u'3-group': [u'2'], 
    453   u'0-group': [u'2'], 
    454   u'1-revision': [u'a'], 
    455   u'form-1-quantity': [u'3'], 
    456   u'2-name': [u'NBA_ASM'], 
    457   u'form-0-type_part': [u'Part'], 
    458   u'3-name': [u'NBA_ASM'], 
    459   u'0-revision': [u'a'], 
    460   u'initial-2-lifecycle': [u'draft_official_deprecated'], 
    461   u'initial-1-lifecycle': [u'draft_official_deprecated'], 
    462   u'form-1-unit': [u'-'], 
    463   u'1-name': [u'L-BRACKET'], 
    464   u'form-TOTAL_FORMS': [u'2', 
    465   u'2'], 
    466   u'2-reference': [u'PART_00003'], 
    467   u'2-revision': [u'a'], 
    468   u'form-INITIAL_FORMS': [u'2', 
    469   u'2'], 
    470   u'0-lifecycle': [u'draft_official_deprecated'], 
    471   u'initial-lifecycle': [u'draft_official_deprecated'], 
    472   u'3-reference': [u'DOC_00003'], 
    473   u'0-name': [u'L-BRACKET'], 
    474   u'form-MAX_NUM_FORMS': [u'2', 
    475   u'2'], 
    476   u'1-group': [u'2'], 
    477   u'form-0-type_document3D': [u'Document3D'], 
    478   u'form-0-order': [u'10'], 
    479   u'form-1-type_document3D': [u'not_exits_Document4D362182'], 
    480   u'1-reference': [u'DOC_00002']} 
    481292   
    482293   
  • trunk/openPLM/document3D/views.py

    r1048 r1070  
    129129 
    130130DecomposersManager.register(StepDecomposer) 
    131 #posibilidades , el objeto a sido modificado despues de acceder al formulario 
    132  
    133 Select_Doc_Part_types = formset_factory(Doc_Part_type_Form, extra=0) 
    134 Select_Order_Quantity_types = formset_factory(Order_Quantity_Form, extra=0) 
     131 
     132 
     133 
    135134#@handle_errors 
    136135def display_decompose(request, obj_type, obj_ref, obj_revi, stp_id): 
     
    246245                    try: 
    247246                        instances=[] 
     247                        old_product=json.dumps(data_for_product(product)) # we save the product before update nodes whit new doc_id and doc_path generated during the bomb-child 
    248248                        generate_part_doc_links_AUX(request,product, obj,instances) 
    249249                        update_indexes.delay(instances)  
     
    262262                            native_related.save(False) 
    263263                    else: 
    264              
    265                         decomposer_all.delay(stp_file.pk,json.dumps(data_for_product(product)),obj.object.pk,native_related_pk,obj._user.pk) 
     264                        try: 
     265                            decomposer_all.delay(stp_file.pk,json.dumps(data_for_product(product)),obj.object.pk,native_related_pk,obj._user.pk,old_product) 
     266                        except Exception as excep: 
     267                            extra_errors=unicode(excep) 
    266268                         
    267                         return HttpResponseRedirect(obj.plmobject_url+"BOM-child/") 
     269                        else: 
     270                         
     271                            return HttpResponseRedirect(obj.plmobject_url+"BOM-child/") 
    268272   
    269273 
     
    561565    -To every generated :class:`.Part` a :class:`.Document3D` has been attached and Document3D as been set like the attribute PartDecompose of the Part 
    562566      
    563     -The attribute doc_id of every node of the arborescense(**product**) is now the relative id of :class:`.Document3D` generated in the previous condition 
     567    -The attribute doc_id of every node of the arborescense(**product**) is now the relative id of :class:`.DocumentFile` generated in the previous condition 
    564568     
    565569    -To every generated :class:`.Document3D` has been added a new empty(locked) :class:`.DocumentFile` STP ( :meth:`.generateGhostDocumentFile` ) 
Note: See TracChangeset for help on using the changeset viewer.