Got upload view working, staging preview and delete working ok
This commit is contained in:
39
apps/sources/forms.py
Normal file
39
apps/sources/forms.py
Normal file
@@ -0,0 +1,39 @@
|
||||
from django import forms
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.conf import settings
|
||||
|
||||
from common.forms import DetailForm
|
||||
from common.literals import PAGE_SIZE_CHOICES, PAGE_ORIENTATION_CHOICES
|
||||
from common.conf.settings import DEFAULT_PAPER_SIZE
|
||||
from common.conf.settings import DEFAULT_PAGE_ORIENTATION
|
||||
|
||||
from documents.forms import DocumentForm
|
||||
|
||||
|
||||
class StagingDocumentForm(DocumentForm):
|
||||
"""
|
||||
Form that show all the files in the staging folder specified by the
|
||||
StagingFile class passed as 'cls' argument
|
||||
"""
|
||||
def __init__(self, *args, **kwargs):
|
||||
cls = kwargs.pop('cls')
|
||||
super(StagingDocumentForm, self).__init__(*args, **kwargs)
|
||||
try:
|
||||
self.fields['staging_file_id'].choices = [
|
||||
(staging_file.id, staging_file) for staging_file in cls.get_all()
|
||||
]
|
||||
except:
|
||||
pass
|
||||
|
||||
# Put staging_list field first in the field order list
|
||||
staging_list_index = self.fields.keyOrder.index('staging_file_id')
|
||||
staging_list = self.fields.keyOrder.pop(staging_list_index)
|
||||
self.fields.keyOrder.insert(0, staging_list)
|
||||
|
||||
staging_file_id = forms.ChoiceField(label=_(u'Staging file'))
|
||||
|
||||
class Meta(DocumentForm.Meta):
|
||||
exclude = ('description', 'file', 'document_type', 'tags')
|
||||
Reference in New Issue
Block a user