adding DriveAuth model to notes app, closes #10
authorSeth Woodworth <seth@sethish.com>
Wed, 9 Jan 2013 21:53:38 +0000 (16:53 -0500)
committerSeth Woodworth <seth@sethish.com>
Wed, 9 Jan 2013 21:53:38 +0000 (16:53 -0500)
karmaworld/apps/notes/models.py
karmaworld/static/css/responsive-tables.css [new file with mode: 0644]

index 74567380d967dcb1d607c18e5affb1e947c5a01f..e02a3860865a49ae29cf9f8e0cf983ec83e8b840 100644 (file)
@@ -7,10 +7,10 @@
     Contains only the minimum for handling files and their representation
 """
 import datetime
-import os
 
 from django.db import models
 from taggit.managers import TaggableManager
+from oauth2client.client import Credentials
 
 from karmaworld.apps.courses.models import Course
 
@@ -59,3 +59,39 @@ class Note(models.Model):
 
         # resume save
         super(Note, self).save(*args, **kwargs)
+
+
+# FIXME: replace the following GOOGLE_USER in a settings.py
+GOOGLE_USER = 'seth.woodworth@gmail.com'
+
+class DriveAuth(models.Model):
+    """ stored google drive authentication and refresh token
+        used for interacting with google drive """
+
+    email = models.EmailField(default=GOOGLE_USER)
+    credentials = models.TextField() # JSON of Oauth2Credential object
+    stored_at = models.DateTimeField(auto_now=True)
+
+
+    @staticmethod
+    def get(email=GOOGLE_USER):
+        """ Staticmethod for getting the singleton DriveAuth object """
+        # FIXME: this is untested
+        return DriveAuth.objects.filter(email=email).reverse()[0]
+
+
+    def store(self, creds):
+        """ Transform an existing credentials object to a db serialized """
+        self.email = creds.id_token['email']
+        self.credentials = creds.to_json()
+        self.save()
+
+
+    def transform_to_cred(self):
+        """ take stored credentials and produce a Credentials object """
+        return Credentials.new_from_json(self.credentials)
+
+
+    def __unicode__(self):
+        return u'Gdrive auth for %s created/updated at %s' % \
+                    (self.email, self.stored_at)
diff --git a/karmaworld/static/css/responsive-tables.css b/karmaworld/static/css/responsive-tables.css
new file mode 100644 (file)
index 0000000..4765406
--- /dev/null
@@ -0,0 +1,50 @@
+/* Foundation v2.1.4 http://foundation.zurb.com */
+/* Artfully masterminded by ZURB  */
+
+/* -------------------------------------------------- 
+   Table of Contents
+-----------------------------------------------------
+:: Shared Styles
+:: Page Name 1
+:: Page Name 2
+*/
+
+
+/* -----------------------------------------
+   Shared Styles
+----------------------------------------- */
+
+table th { font-weight: bold; }
+table td, table th { padding: 9px 10px; text-align: left; }
+
+/* Mobile */
+@media only screen and (max-width: 767px) {
+       
+       table.responsive { margin-bottom: 0; }
+       
+       .pinned { position: absolute; left: 0; top: 0; background: #fff; width: 35%; overflow: hidden; overflow-x: scroll; border-right: 1px solid #ccc; border-left: 1px solid #ccc; }
+       .pinned table { border-right: none; border-left: none; width: 100%; }
+       .pinned table th, .pinned table td { white-space: nowrap; }
+       .pinned td:last-child { border-bottom: 0; }
+       
+       div.table-wrapper { position: relative; margin-bottom: 20px; overflow: hidden; border-right: 1px solid #ccc; }
+       div.table-wrapper div.scrollable table { margin-left: 35%; }
+       div.table-wrapper div.scrollable { overflow: scroll; overflow-y: hidden; }      
+       
+       table.responsive td, table.responsive th { position: relative; white-space: nowrap; overflow: hidden; }
+       table.responsive th:first-child, table.responsive td:first-child, table.responsive td:first-child, table.responsive.pinned td { display: none; }
+       
+}
+
+/* -----------------------------------------
+   Page Name 1
+----------------------------------------- */
+
+
+
+
+/* -----------------------------------------
+   Page Name 2
+----------------------------------------- */
+
+