adding notes app with Note model and adding taggit tagging manager
authorSeth Woodworth <seth@sethish.com>
Thu, 3 Jan 2013 00:16:20 +0000 (19:16 -0500)
committerSeth Woodworth <seth@sethish.com>
Thu, 3 Jan 2013 00:16:20 +0000 (19:16 -0500)
karmaworld/apps/notes/__init__.py [new file with mode: 0644]
karmaworld/apps/notes/admin.py [new file with mode: 0644]
karmaworld/apps/notes/models.py [new file with mode: 0644]
karmaworld/settings/common.py
karmaworld/settings/dev.py
reqs/common.txt

diff --git a/karmaworld/apps/notes/__init__.py b/karmaworld/apps/notes/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/karmaworld/apps/notes/admin.py b/karmaworld/apps/notes/admin.py
new file mode 100644 (file)
index 0000000..ae49e66
--- /dev/null
@@ -0,0 +1,10 @@
+#!/usr/bin/python
+# -*- coding:utf8 -*-
+# Copyright (C) 2012  FinalsClub Foundation
+""" Administration configuration for notes """
+
+from django.contrib import admin
+
+import models
+
+admin.site.register(models.Note)
diff --git a/karmaworld/apps/notes/models.py b/karmaworld/apps/notes/models.py
new file mode 100644 (file)
index 0000000..ff468c6
--- /dev/null
@@ -0,0 +1,49 @@
+#!/usr/bin/python2.7
+# -*- coding:utf8 -*-
+# Copyright (C) 2012  FinalsClub Foundation
+
+"""
+    Models for the notes django app.
+    Contains only the minimum for handling files and their representation
+"""
+import datetime
+import os
+
+from django.db import models
+from taggit.managers import TaggableManager
+
+class Note(models.Model):
+    """ A django model representing an uploaded file and associated metadata.
+    """
+    FILE_TYPE_CHOICES = (
+        ('doc', 'MS Word compatible file (.doc, .docx, .rtf, .odf)'),
+        ('img', 'Scan or picture of notes'),
+        ('pdf', 'PDF file'),
+        ('???', 'Unknown file'),
+    )
+
+    # Tagging system
+    tags            = TaggableManager()
+
+    name            = models.CharField(max_length=255, blank=True, null=True)
+    desc            = models.TextField(max_length=511, blank=True, null=True)
+    uploaded_at     = models.DateTimeField(null=True, default=datetime.datetime.utcnow)
+
+    file_type   = models.CharField(max_length=15, blank=True, null=True, choices=FILE_TYPE_CHOICES, default='???')
+    # Upload files to MEDIA_ROOT/notes/YEAR/MONTH/DAY, 2012/10/30/filename
+    note_file   = models.FileField(upload_to="notes/%Y/%m/%j/", blank=True, null=True)
+
+    ## post gdrive conversion data
+    embed_url   = models.URLField(max_length=1024, blank=True, null=True)
+    download_url = models.URLField(max_length=1024, blank=True, null=True)
+    # for word processor documents
+    html        = models.TextField(blank=True, null=True)
+    text        = models.TextField(blank=True, null=True)
+
+    # FIXME: Not Implemented
+    #uploader    = models.ForeignKey(User, blank=True, null=True, related_name='notes')
+    #course      = models.ForeignKey(Course, blank=True, null=True, related_name="files")
+    #school      = models.ForeignKey(School, blank=True, null=True)
+
+    def __unicode__(self):
+        return u"{0}: {1} -- {2}".format(self.file_type, self.name, self.uploaded_at)
index 0aecfb4ba1d207eaef1c5be942a7df3e512d0d43..cb036978f2ef750872ae4a999d7ee2677fae4340 100644 (file)
@@ -196,9 +196,14 @@ THIRD_PARTY_APPS = (
 
     # Asynchronous task queue:
     'djcelery',
+
+    # Tagging https://github.com/yedpodtrzitko/django-taggit
+    'taggit',
 )
 
 LOCAL_APPS = (
+    # file handling app
+    'karmaworld.apps.notes',
 )
 
 # See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
@@ -257,3 +262,15 @@ COMPRESS_JS_FILTERS = [
     'compressor.filters.template.TemplateFilter',
 ]
 ########## END COMPRESSION CONFIGURATION
+
+########## TAGGIT CONFIGURATION
+# From https://github.com/yedpodtrzitko/django-taggit
+
+# Use lowercase tags
+TAGGIT_FORCE_LOWERCASE = True
+
+# Ignore common stopwords
+TAGGIT_STOPWORDS = [u'a', u'an', u'and', u'be', u'from', u'of']
+
+########## END TAGGIT CONFIGURATION
+
index 2fd3297d3e831c594f8f1b2f573f00f0d7edb6c3..fdf6bbcdf2cdcbddb924708ba9f880b0c0dff073 100644 (file)
@@ -26,7 +26,7 @@ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
 DATABASES = {
     'default': {
         'ENGINE': 'django.db.backends.sqlite3',
-        'NAME': normpath(join(DJANGO_ROOT, 'default.db')),
+        'NAME': normpath(join(DJANGO_ROOT, 'karmaworld.db')),
         'USER': '',
         'PASSWORD': '',
         'HOST': '',
index 79a8f5b33b74e37dfb65f40d746238390537bcd2..7d5924b5545662da69baf3e39ff2399b047e1820 100644 (file)
@@ -4,3 +4,4 @@ django-compressor==1.2
 Fabric==1.4.3
 South==0.7.6
 Sphinx==1.1.3
+git+git://github.com/yedpodtrzitko/django-taggit.git