Changeset 65 in main for trunk/openPLM/plmapp/forms.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/forms.py

    r60 r65  
    153153    return formset 
    154154 
     155 
     156 
     157 
     158 
     159class AddFileForm(forms.Form): 
     160    filename = forms.FileField() 
     161     
     162class ModifyFileForm(forms.ModelForm): 
     163    delete = forms.BooleanField(required=False, initial=False) 
     164    document = forms.ModelChoiceField(queryset=m.Document.objects.all(), 
     165                                   widget=forms.HiddenInput()) 
     166    class Meta: 
     167        model = m.DocumentFile 
     168        fields = ["document"] 
     169         
     170def get_file_formset(controller, data=None): 
     171    Formset = modelformset_factory(m.DocumentFile, form=ModifyFileForm, extra=0) 
     172    if data is None: 
     173        queryset = controller.files 
     174        formset = Formset(queryset=queryset) 
     175    else: 
     176        formset = Formset(data=data) 
     177    return formset 
     178 
     179 
     180 
     181 
Note: See TracChangeset for help on using the changeset viewer.