Commits

Greg Newman committed b3b904e

adding upload form

Comments (0)

Files changed (3)

 
 from loupe.models import Image, Corkboard, Note, Project
 
+class ProjectForm(forms.ModelForm):
+
+    class Meta:
+        model = Project
+        exclude = ('created_on', 'updated_on', 'user',)
+    
+    def __init__(self, user=None, *args, **kwargs):
+        self.user = user
+        super(ProjectForm, self).__init__(*args, **kwargs)
+
 class CorkboardForm(forms.ModelForm):
 
     class Meta:
         model = Corkboard
-        exclude = ('created_on', 'updated_on', 'user', 'images',)
+        exclude = ('created_on', 'updated_on', 'user', 'images', 'project',)
     
     def __init__(self, user=None, *args, **kwargs):
         self.user = user
 
     class Meta:
         model = Image
-        exclude = ('created_on', 'updated_on', 'user', 'num_views',)
+        exclude = ('created_on', 'updated_on', 'user', 'num_views', 'corkboard',)
     
     def __init__(self, user=None, *args, **kwargs):
         self.user = user
 
 # and our display spec
 class Display(ImageSpec):
+    access_as = 'display'
+    pre_cache = True
     increment_count = True
     processors = [ResizeDisplay]

loupe/templates/loupe/corkboard_detail.html

 {% block content %}
     <h2>{{ corkboard.title }}</h2>
     <p>{{ corkboard.description }}</p>
-    {% for p in corkboard.images.all %}
+    {% for p in images %}
         <a href="{% url image_detail p.id %}"><img src="{{ p.thumbnail_image.url }}" alt="{{ p.title }}"></a>
     {% endfor %}
 
+    <h4>Upload an image to this corkboard</h4>
+    <form enctype="multipart/form-data" method="POST" action="">
+        <fieldset>
+        <table>
+            {{ form.as_table }}
+            <tr>
+                <td><input type="submit" value="Upload" /></td>
+            </tr>
+        </table>
+        </fieldset>
+    </form>
+
     <h4>Corkboard Comments</h4>
     {% get_comment_list for corkboard as comment_list %}
     {% for comment in comment_list %}