adding first pass of note viewing page, iframe NotImplemented
authorSeth Woodworth <seth@sethish.com>
Thu, 10 Jan 2013 20:33:49 +0000 (15:33 -0500)
committerSeth Woodworth <seth@sethish.com>
Thu, 10 Jan 2013 20:33:49 +0000 (15:33 -0500)
karmaworld/apps/notes/views.py [new file with mode: 0644]
karmaworld/templates/notes/note_detail.html [new file with mode: 0644]
karmaworld/urls.py

diff --git a/karmaworld/apps/notes/views.py b/karmaworld/apps/notes/views.py
new file mode 100644 (file)
index 0000000..c910e88
--- /dev/null
@@ -0,0 +1,9 @@
+from django.views.generic import DetailView
+from karmaworld.apps.notes.models import Note
+
+class NoteDetailView(DetailView):
+    """ Class-based view for the note html page """
+
+    # name passed to template
+    context_object_name = u"note"
+    model = Note
diff --git a/karmaworld/templates/notes/note_detail.html b/karmaworld/templates/notes/note_detail.html
new file mode 100644 (file)
index 0000000..8c63930
--- /dev/null
@@ -0,0 +1,131 @@
+{% extends "base.html" %}
+{% load url from future %}
+
+{% block pagestyle %}
+  <link rel="stylesheet" type="text/css" media="all" href="/static/css/note_course_pages.css">
+{% endblock %}
+
+{% block pagescripts %}
+<script>
+  var view_note_pk = {{ note.id }};
+  var view_note_title = "{{ note.name }}";
+  var view_note_description = "{{ note.desc }}";
+  var editing_note = false;
+
+  function autoResize(id){
+      var newheight;
+      var newwidth;
+
+      if(document.getElementById){
+        newheight = document.getElementById(id).contentWindow.document .body.scrollHeight;
+        newwidth = document.getElementById(id).contentWindow.document .body.scrollWidth;
+      }
+
+      document.getElementById(id).height = (newheight+ 10) + "px";
+      document.getElementById(id).width= (newwidth + 5) + "px";
+      //alert('height: ' + newheight);
+  }
+
+</script>
+{% endblock %}
+
+{% block content %}
+  <section id="note_content">
+
+    <div id="note_header" class="hero_gradient_bar">
+      <div class="row">
+        <div id="note_back_to_course" class="twelve columns">
+          <a href="{{ note.course.get_absolute_url }}">
+            {# TODO: style this not like a link #}
+            <img src="/static/img/search_arrow_left.png" alt="search_arrow_left" width="5" height="10" />&nbsp;back to {{ note.course.name }}
+          </a>
+
+        </div>
+      </div>
+
+      <div class="row">
+        <div id="note_name" class="twelve columns">
+          {{ note.name }}
+        </div><!-- /note_name -->
+      </div>
+
+      <div class="row">
+        <div id="note_status" class="twelve columns">
+          <div class="activity_details_status">
+            So far, <span class="activity_details_status_number">{{ note.numUpVotes }}</span> people have completely fallen in love with with these notes. <span class="activity_details_status_secondary_number">{{ note.viewCount }}</span> people have viewed them.
+          </div><!-- /activity_details_status -->
+        </div><!-- /note_status -->
+      </div>
+
+      <div class="row">
+        <div id="note_author" class="twelve columns">
+          uploaded by
+          {% if owns_file %}
+            you
+          {% else %}
+            {{ note.owner.get_profile.get_name }}
+          {% endif %}
+        </div><!-- /note_author -->
+      </div>
+
+      <div class="row">
+        <div id="note_actions" class="three columns centered">
+          {% if not owns_file %}
+          <div class="row">
+            <div class="six column thank" {% if has_voted %} style="display:none" {% endif %} data-id={{ file.id }}>
+              <img src="/static/img/note_thank.png" alt="note_thank" width="34" height="34" />
+            </div>
+            <div class="six column flag" {% if has_voted %} style="display:none" {% endif %} data-id={{ file.id }}>
+               <img src="/static/img/note_flag.png" alt="note_flag" width="25" height="35" />
+            </div>
+            <div class="twelve column voted_message" data-id={{ file.id }} {% if not has_voted %} style="display:none" {% endif %}>
+              You've
+              <span id="thanked_or_flagged">
+                {% if not lovable %}
+                  thanked
+                {% elif not flaggable %}
+                  flagged
+                {% endif %}
+              </span>
+             this file
+            </div>
+            {% comment %}
+            <!-- disabling downloads for now -->
+            <div class="four column">
+              <img src="/static/img/note_download.png" alt="note_download" width="51" height="36" />
+            </div>
+            {% endcomment %}
+          </div>
+          {% endif %} <!-- not owns_file -->
+        </div><!-- /note_actions -->
+      </div>
+    </div><!-- /note_header -->
+
+
+    <div id="note_container">
+
+      <div class="row">
+        <div class="eight columns centered body_copy">
+
+          <h1>description</h1>
+
+          <p>{{ note.desc }}</p>
+
+          <h1>notes</h1>
+
+          <div class="note-text">
+            <iframe style="border:none; width:100%;" id="noteframe" src="/raw/{{ note.id }}" onload="autoResize('noteframe')">
+            </iframe>
+          </div> <!-- .note-text -->
+          <div class="note-error" style="display:none">
+            This document's content is currently unavailable. It's likely the document is still being processed. Please try again later.
+          </div>
+
+        </div><!-- /body_copy -->
+      </div>
+
+    </div><!-- /note_container -->
+
+
+  </section><!--/note_content-->
+{% endblock %}
index bd19f19fd711c499cb2f707d9b603f0a77529283..4f2ab967e72e04c6b358f905c815d1c26e8fcee9 100644 (file)
@@ -4,6 +4,7 @@ from django.views.generic import ListView, DetailView
 
 from karmaworld.apps.courses.models import Course
 from karmaworld.apps.courses.views import CourseDetailView
+from karmaworld.apps.notes.views import NoteDetailView
 
 # See: https://docs.djangoproject.com/en/dev/ref/contrib/admin/#hooking-adminsite-instances-into-your-urlconf
 admin.autodiscover()
@@ -16,6 +17,7 @@ urlpatterns = patterns('',
     url(r'^admin/', include(admin.site.urls)),
 
     url(r'^(?P<school_slug>[^/]+)/(?P<slug>[^/]+)$', CourseDetailView.as_view(), name='course_detail'),
+    url(r'^(?P<school_slug>[^/]+)/(?P<course_slug>[^/]+)/(?P<slug>[^/]+)$', NoteDetailView.as_view(), name='note_detail'),
 
     url(r'^$', ListView.as_view(model=Course), name='home'),
 )