diff --git a/.hgignore b/.hgignore index c221144..01e07fe 100644 --- a/.hgignore +++ b/.hgignore @@ -3,6 +3,7 @@ syntax: glob *.json *.gunicorn.* *.pyc +*.sql db.db local_settings.py diff --git a/fabfile.py b/fabfile.py index 6389160..d020314 100644 --- a/fabfile.py +++ b/fabfile.py @@ -7,10 +7,10 @@ from dwfab.misc import growl as _growl UPLOADS_DIR = 'media/uploads' APPS_TO_SYNC = [ - 'auth', 'contenttypes', + 'auth', 'redirects', - 'registration', + 'sites', ] def prod(): @@ -19,7 +19,7 @@ def prod(): env.hosts = ['nick@beta.snipt.net:38038'] env.process_name = 'beta_snipt' env.site_path = '/var/www/beta-snipt' - env.venv_path = '/home/nick/.virtualenvs/beta-snipt' + env.venv_path = '/home/nick/virtualenvs/beta-snipt' env.site_url = 'https://beta.snipt.net/' env.uploads_path = env.site_path + '/' + UPLOADS_DIR diff --git a/migrate.py b/migrate.py new file mode 100644 index 0000000..a0bd5e7 --- /dev/null +++ b/migrate.py @@ -0,0 +1,92 @@ +#!/usr/bin/python + +import MySQLdb + +from django.contrib.auth.models import User + +from snipts.models import Snipt + +conn = MySQLdb.connect(host='localhost', user='root', passwd='root', db='sniptold') +cursor = conn.cursor() + +def i(): + users() + snipts() + +def users(): + + print "Deleting existing users" + users = User.objects.all() + for u in users: + u.delete() + + cursor.execute("SELECT * FROM auth_user") + rows = cursor.fetchall() + + for row in rows: + user_id = row[0] + username = row[1] + first_name = row[2] + last_name = row[3] + email = row[4] + password = row[5] + is_staff = row[6] + is_active = row[7] + is_superuser = row[8] + last_login = row[9] + date_joined = row[10] + + user = User( + id=user_id, + username=username, + first_name=first_name, + last_name=last_name, + email=email, + password=password, + is_staff=is_staff, + is_active=is_active, + is_superuser=is_superuser, + last_login=last_login, + date_joined=date_joined, + ) + user.save() + + print 'Done with users' + +def snipts(): + + print "Deleting existing snipts" + snipts = Snipt.objects.all() + for s in snipts: + s.delete() + + cursor.execute("SELECT * FROM snippet_snippet") + rows = cursor.fetchall() + + for row in rows: + snipt_id = row[0] + code = row[1] + title = row[2] + created = row[3] + user_id = row[4] + tags = row[5] + lexer = row[6] + public = row[7] + key = row[8] + slug = row[9] + + snipt = Snipt( + id=snipt_id, + code=code, + title=title, + slug=slug, + lexer=lexer, + key=key, + user=User.objects.get(id=user_id), + tags=tags, + public=public, + created=created, + ) + snipt.save() + + print 'Done with snipts' diff --git a/settings.py b/settings.py index 61d14b9..478dc4b 100644 --- a/settings.py +++ b/settings.py @@ -61,6 +61,8 @@ INSTALLED_APPS = ( 'compressor', 'django_bcrypt', 'south', + + 'snipts', ) # CSS compression diff --git a/snipts/__init__.py b/snipts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/snipts/admin.py b/snipts/admin.py new file mode 100644 index 0000000..4336644 --- /dev/null +++ b/snipts/admin.py @@ -0,0 +1,11 @@ +from django.contrib import admin + +from snipts.models import Snipt + +class SniptAdmin(admin.ModelAdmin): + list_display = ('title', 'slug', 'tags', 'user', 'lexer', 'public', 'created', 'modified',) + search_fields = ('title', 'user__username', 'tags', 'lexer',) + ordering = ('created',) + prepopulated_fields = {'slug': ('title',)} + +admin.site.register(Snipt, SniptAdmin) diff --git a/snipts/migrations/0001_initial.py b/snipts/migrations/0001_initial.py new file mode 100644 index 0000000..60aabe8 --- /dev/null +++ b/snipts/migrations/0001_initial.py @@ -0,0 +1,87 @@ +# encoding: utf-8 +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + +class Migration(SchemaMigration): + + def forwards(self, orm): + + # Adding model 'Snipt' + db.create_table('snipts_snipt', ( + ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])), + ('title', self.gf('django.db.models.fields.CharField')(max_length=255)), + ('slug', self.gf('django.db.models.fields.SlugField')(max_length=50, db_index=True)), + ('lexer', self.gf('django.db.models.fields.CharField')(max_length=50)), + ('code', self.gf('django.db.models.fields.TextField')()), + ('stylized', self.gf('django.db.models.fields.TextField')()), + ('key', self.gf('django.db.models.fields.TextField')(max_length=100)), + ('public', self.gf('django.db.models.fields.BooleanField')(default=False)), + ('created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)), + ('modified', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)), + )) + db.send_create_signal('snipts', ['Snipt']) + + + def backwards(self, orm): + + # Deleting model 'Snipt' + db.delete_table('snipts_snipt') + + + models = { + 'auth.group': { + 'Meta': {'object_name': 'Group'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), + 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + 'auth.permission': { + 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + 'auth.user': { + 'Meta': {'object_name': 'User'}, + 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), + 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), + 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + 'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) + }, + 'snipts.snipt': { + 'Meta': {'object_name': 'Snipt'}, + 'code': ('django.db.models.fields.TextField', [], {}), + 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'key': ('django.db.models.fields.TextField', [], {'max_length': '100'}), + 'lexer': ('django.db.models.fields.CharField', [], {'max_length': '50'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), + 'public': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'db_index': 'True'}), + 'stylized': ('django.db.models.fields.TextField', [], {}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}) + } + } + + complete_apps = ['snipts'] diff --git a/snipts/migrations/0002_auto__add_field_snipt_tags.py b/snipts/migrations/0002_auto__add_field_snipt_tags.py new file mode 100644 index 0000000..ebf7ceb --- /dev/null +++ b/snipts/migrations/0002_auto__add_field_snipt_tags.py @@ -0,0 +1,75 @@ +# encoding: utf-8 +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + +class Migration(SchemaMigration): + + def forwards(self, orm): + + # Adding field 'Snipt.tags' + db.add_column('snipts_snipt', 'tags', self.gf('django.db.models.fields.CharField')(default='', max_length=255), keep_default=False) + + + def backwards(self, orm): + + # Deleting field 'Snipt.tags' + db.delete_column('snipts_snipt', 'tags') + + + models = { + 'auth.group': { + 'Meta': {'object_name': 'Group'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), + 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + 'auth.permission': { + 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + 'auth.user': { + 'Meta': {'object_name': 'User'}, + 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), + 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), + 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + 'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) + }, + 'snipts.snipt': { + 'Meta': {'object_name': 'Snipt'}, + 'code': ('django.db.models.fields.TextField', [], {}), + 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'key': ('django.db.models.fields.TextField', [], {'max_length': '100'}), + 'lexer': ('django.db.models.fields.CharField', [], {'max_length': '50'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), + 'public': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'db_index': 'True'}), + 'stylized': ('django.db.models.fields.TextField', [], {}), + 'tags': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}) + } + } + + complete_apps = ['snipts'] diff --git a/snipts/migrations/0003_auto__chg_field_snipt_key.py b/snipts/migrations/0003_auto__chg_field_snipt_key.py new file mode 100644 index 0000000..8cbea61 --- /dev/null +++ b/snipts/migrations/0003_auto__chg_field_snipt_key.py @@ -0,0 +1,75 @@ +# encoding: utf-8 +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + +class Migration(SchemaMigration): + + def forwards(self, orm): + + # Changing field 'Snipt.key' + db.alter_column('snipts_snipt', 'key', self.gf('django.db.models.fields.CharField')(max_length=100)) + + + def backwards(self, orm): + + # Changing field 'Snipt.key' + db.alter_column('snipts_snipt', 'key', self.gf('django.db.models.fields.TextField')(max_length=100)) + + + models = { + 'auth.group': { + 'Meta': {'object_name': 'Group'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), + 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + 'auth.permission': { + 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + 'auth.user': { + 'Meta': {'object_name': 'User'}, + 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), + 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), + 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + 'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) + }, + 'snipts.snipt': { + 'Meta': {'object_name': 'Snipt'}, + 'code': ('django.db.models.fields.TextField', [], {}), + 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'key': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'lexer': ('django.db.models.fields.CharField', [], {'max_length': '50'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), + 'public': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'db_index': 'True'}), + 'stylized': ('django.db.models.fields.TextField', [], {}), + 'tags': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}) + } + } + + complete_apps = ['snipts'] diff --git a/snipts/migrations/0004_auto__chg_field_snipt_created.py b/snipts/migrations/0004_auto__chg_field_snipt_created.py new file mode 100644 index 0000000..07e3f8a --- /dev/null +++ b/snipts/migrations/0004_auto__chg_field_snipt_created.py @@ -0,0 +1,75 @@ +# encoding: utf-8 +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + +class Migration(SchemaMigration): + + def forwards(self, orm): + + # Changing field 'Snipt.created' + db.alter_column('snipts_snipt', 'created', self.gf('django.db.models.fields.DateTimeField')()) + + + def backwards(self, orm): + + # Changing field 'Snipt.created' + db.alter_column('snipts_snipt', 'created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True)) + + + models = { + 'auth.group': { + 'Meta': {'object_name': 'Group'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), + 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + 'auth.permission': { + 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + 'auth.user': { + 'Meta': {'object_name': 'User'}, + 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), + 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), + 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + 'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) + }, + 'snipts.snipt': { + 'Meta': {'object_name': 'Snipt'}, + 'code': ('django.db.models.fields.TextField', [], {}), + 'created': ('django.db.models.fields.DateTimeField', [], {}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'key': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'lexer': ('django.db.models.fields.CharField', [], {'max_length': '50'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), + 'public': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'db_index': 'True'}), + 'stylized': ('django.db.models.fields.TextField', [], {}), + 'tags': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}) + } + } + + complete_apps = ['snipts'] diff --git a/snipts/migrations/__init__.py b/snipts/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/snipts/models.py b/snipts/models.py new file mode 100644 index 0000000..345aa62 --- /dev/null +++ b/snipts/models.py @@ -0,0 +1,25 @@ +from django.contrib.auth.models import User +from django.db import models + +class Snipt(models.Model): + """An individual code snippet.""" + + user = models.ForeignKey(User) + + title = models.CharField(max_length=255) + slug = models.SlugField() + tags = models.CharField(max_length=255) + + lexer = models.CharField(max_length=50) + code = models.TextField() + stylized = models.TextField() + + key = models.CharField(max_length=100) + public = models.BooleanField(default=False) + + # TODO Set auto_now_add back to True for production! + created = models.DateTimeField(auto_now_add=False, editable=False) + modified = models.DateTimeField(auto_now=True, editable=False) + + def __unicode__(self): + return u'%s' %(self.title) diff --git a/snipts/tests.py b/snipts/tests.py new file mode 100644 index 0000000..501deb7 --- /dev/null +++ b/snipts/tests.py @@ -0,0 +1,16 @@ +""" +This file demonstrates writing tests using the unittest module. These will pass +when you run "manage.py test". + +Replace this with more appropriate tests for your application. +""" + +from django.test import TestCase + + +class SimpleTest(TestCase): + def test_basic_addition(self): + """ + Tests that 1 + 1 always equals 2. + """ + self.assertEqual(1 + 1, 2) diff --git a/snipts/views.py b/snipts/views.py new file mode 100644 index 0000000..60f00ef --- /dev/null +++ b/snipts/views.py @@ -0,0 +1 @@ +# Create your views here.