Disable download button if we don't have a fp_file field
authorCharles Connell <charles@connells.org>
Tue, 11 Mar 2014 00:48:13 +0000 (20:48 -0400)
committerCharles Connell <charles@connells.org>
Tue, 11 Mar 2014 00:48:13 +0000 (20:48 -0400)
karmaworld/apps/notes/models.py
karmaworld/templates/notes/note_detail.html

index 3e58f4886aa3d23d2dc84d76afe33ecadea9d9de..45c4caaac162247d3da29767ad52686342958467 100644 (file)
@@ -158,6 +158,9 @@ class Document(models.Model):
         Returns the Filepicker URL for reading the upstream document.
         """
         # Fetch FilepickerFile
+        if not self.fp_file.name:
+            return None
+
         fpf = self._get_fpf()
         # Return proper URL for reading
         return fpf.get_url()
index 0f6ac931aa8a3cc1ac09595d446fed35c2ddf159..52286c356082bbb7ee704c63cf3a736ba558097a 100644 (file)
                 </a>
               </div>
               <div class="small-4 column">
-                <a id="note-download-button" href="{{ note.get_fp_url }}">
+                {% if note.get_fp_url %}
+                  <a id="note-download-button" href="{{ note.get_fp_url }}">
+                    <img
+                      src="{{ STATIC_URL }}img/note_download.png"
+                      alt="note_download"
+                      width="51" height="36"
+                      data-ot="It costs 2 karma points to download a note"
+                      {% include 'partial/opentip_settings.html' %}
+                      class="opentip" />
+                  </a>
+                {% else %}
                   <img
-                    src="{{ STATIC_URL }}img/note_download.png"
+                    src="{{ STATIC_URL }}img/note_download_disabled.png"
                     alt="note_download"
                     width="51" height="36"
-                    data-ot="It costs 2 karma points to download a note"
+                    data-ot="Sorry, this note cannot be downloaded"
                     {% include 'partial/opentip_settings.html' %}
                     class="opentip" />
-                </a>
+                {% endif %}
               </div>
             {% else %}
               <div class="small-4 column">