@@ -0,0 +1,2907 @@
+%22%22%22%0AFusionbox widgets%0A%22%22%22%0Afrom django.forms import FileInput%0Afrom django.utils.safestring import mark_safe%0A%0A%0Aclass MultiFileWidget(FileInput):%0A    %22%22%22%0A    Provides a widget to enable multifile uploads for a file field.%0A%0A    Static Requirements:%0A        - jquery%0A        - jquery.tmpl.js%0A        - jquery.multifile.js%0A%0A    If you would like to use a different jquery-tmpl%0A    %22%22%22%0A%0A    def __init__(self, *args, **kwargs):%0A        self.render_jquery_tmpl_func = kwargs.pop('jquery_tmpl_func',%0A                self.render_jquery_tmpl)%0A        super(MultiFileWidget, self).__init__(*args, **kwargs)%0A%0A    def render_jquery_tmpl(self, attrs):%0A        %22%22%22%0A        Calculates the template string to use for the jQuery template.%0A%0A        This determines the template to be used for each uploaded file.%0A        Two variables will be available in the template:%0A            - name (of uploaded file)%0A            - size (in bytes)%0A        %22%22%22%0A        return u%22%22%22%0A%3Cp class=%22uploaded_file%22%3E%0A%3Ca href=%22%22 class=%22remove_input%22%3Ex%3C/a%3E %3Cspan class=%22filename%22%3E%0A$%7B name %7D%3C/span%3E %3Cspan class=%22filesize%22%3E%5B$%7B size %7D bytes%5D%3C/span%3E%0A%3C/p%3E%22%22%22%0A%0A    def tmpl_id(self, name):%0A        %22%22%22%0A        Given the name of the field, return the ID for the jquery template.%0A        %22%22%22%0A        return %22%25s_uploaded_file%22 %25 name%0A%0A    def container_id(self, name):%0A        %22%22%22%0A        Given the name of the field, return the ID of the container that holds%0A        the files.%0A        %22%22%22%0A        return %22%25s_attachment_container%22 %25 name%0A%0A    def render(self, name, value, attrs=None):%0A        attrs.update(%7B%22multiple%22: %22%22%7D)%0A        tmpl_id = self.tmpl_id(name)%0A        container_id = self.container_id(name)%0A        tmpl = u'%3Cscript id=%22%7Btmpl_id%7D%22 type=%22jquery-tmpl%22%3E%7Btmpl%7D%3C/script%3E'%5C%0A                .format(tmpl_id=tmpl_id,%0A                        tmpl=self.render_jquery_tmpl_func(attrs))%0A        input_tag = super(FileInput, self).render(name, None, attrs=attrs)%0A        container = u'%3Cdiv id=%22%25s%22%3E%3C/div%3E' %25 container_id%0A        binding = u%22%22%22%0A%3Cscript type=%22text/javascript%22%3E%0A$('input%5Btype=file%5D').multifile('#%7Bcontainer_id%7D', '#%7Btmpl_id%7D');%0A%3C/script%3E%22%22%22.format(tmpl_id=tmpl_id, container_id=container_id)%0A%0A        return mark_safe(u%22%7Btmpl%7D%7Binput%7D%7Bcontainer%7D%7Bbinding%7D%22%5C%0A                .format(%0A                    tmpl=tmpl,%0A                    input=input_tag,%0A                    container=container,%0A                    binding=binding%0A                    )%0A                )%0A%0A    def value_from_datadict(self, data, files, name):%0A        %22%22%22%0A        Given a dictionary of data and this widget's name, returns the value%0A        of this widget. Returns None if it's not provided.%0A%0A        The change here from the default implementation from %60FileInput%60 is%0A        that we are getting a list of files from the form.  Not just one.%0A        %22%22%22%0A        try:%0A            return files.getlist(name)%0A        except AttributeError:%0A            return None%0A

add fusionbox.forms.widgets