Changeset 65 in main for trunk/openPLM/plmapp/controllers.py


Ignore:
Timestamp:
07/05/10 13:22:31 (11 years ago)
Author:
pjoulaud
Message:

Addition of files upload/deletion in a document

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/openPLM/plmapp/controllers.py

    r63 r65  
    848848                    self.detach_part(part) 
    849849 
     850 
     851    def update_file(self, formset): 
     852        u""" 
     853        Updates uploaded file informations with data from *formset* 
     854         
     855        :param formset: 
     856        :type formset: a modelfactory_formset of  
     857                        :class:`~plmapp.forms.ModifyFileForm` 
     858        """ 
     859        if formset.is_valid(): 
     860            for form in formset.forms: 
     861                document = form.cleaned_data["document"] 
     862                if document.pk != self.document.pk: 
     863                    raise ValueError("Bad document %s (%s expected)" % (document, self.object)) 
     864                delete = form.cleaned_data["delete"] 
     865                filename = form.cleaned_data["id"] 
     866                if delete: 
     867                    self.delete_file(filename) 
     868 
     869                     
     870 
Note: See TracChangeset for help on using the changeset viewer.