def __init__(self, *args, **kwargs): super(StagingDocumentForm, self).__init__(*args, **kwargs) try: self.fields["staging_file_id"].choices = [ (staging_file.id, staging_file) for staging_file in StagingFile.get_all() ] except: pass if "initial" in kwargs: if "document_type" in kwargs["initial"]: filenames_qs = kwargs["initial"]["document_type"].documenttypefilename_set.filter(enabled=True) if filenames_qs.count() > 0: self.fields["document_type_available_filenames"] = forms.ModelChoiceField( queryset=filenames_qs, required=False, label=_(u"Quick document rename") )
context = { "document_type_id": document_type_id, "form_list": [ { "form": local_form, "title": _(u"upload a local document"), "grid": 6, "grid_clear": False if USE_STAGING_DIRECTORY else True, } ], } if USE_STAGING_DIRECTORY: try: filelist = StagingFile.get_all() except Exception, e: messages.error(request, e) filelist = [] finally: context.update( { "subtemplates_dict": [ { "name": "generic_list_subtemplate.html", "title": _(u"files in staging"), "object_list": filelist, "hide_link": True, } ] }
def __init__(self, *args, **kwargs): super(StagingDocumentForm, self).__init__(*args, **kwargs) try: self.fields['staging_file_id'].choices=[(staging_file.id, staging_file) for staging_file in StagingFile.get_all()] except: pass if 'initial' in kwargs: if 'document_type' in kwargs['initial']: filenames_qs = kwargs['initial']['document_type'].documenttypefilename_set.filter(enabled=True) if filenames_qs.count() > 0: self.fields['document_type_available_filenames'] = forms.ModelChoiceField( queryset=filenames_qs, required=False, label=_(u'Quick document rename'))
context = { 'document_type_id':document_type_id, 'form_list':[ { 'form':local_form, 'title':_(u'upload a local document'), 'grid':6, 'grid_clear':False if USE_STAGING_DIRECTORY else True, }, ], } if USE_STAGING_DIRECTORY: try: filelist = StagingFile.get_all() except Exception, e: messages.error(request, e) filelist = [] finally: context.update({ 'subtemplates_dict':[ { 'name':'generic_list_subtemplate.html', 'title':_(u'files in staging'), 'object_list':filelist, 'hide_link':True, }, ], }) context['form_list'].append(