Django 1.7, Python 3.4
authorRadek Czajka <radekczajka@nowoczesnapolska.org.pl>
Tue, 30 Sep 2014 12:28:48 +0000 (14:28 +0200)
committerRadek Czajka <radekczajka@nowoczesnapolska.org.pl>
Tue, 30 Sep 2014 12:28:48 +0000 (14:28 +0200)
apps/edition1/models.py [deleted file]
apps/edition2/models.py [deleted file]
apps/poetry/migrations/0001_initial.py
apps/poetry/models.py
apps/poetry/utils.py
requirements.txt
turniej/settings.py

diff --git a/apps/edition1/models.py b/apps/edition1/models.py
deleted file mode 100644 (file)
index 71a8362..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-from django.db import models
-
-# Create your models here.
diff --git a/apps/edition2/models.py b/apps/edition2/models.py
deleted file mode 100644 (file)
index 71a8362..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-from django.db import models
-
-# Create your models here.
index c6bfda3..0586896 100644 (file)
@@ -1,78 +1,53 @@
-# 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 'Poet'
-        db.create_table('poetry_poet', (
-            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
-            ('name', self.gf('django.db.models.fields.CharField')(max_length=50)),
-            ('path', self.gf('django.db.models.fields.CharField')(max_length=255)),
-            ('slug', self.gf('django.db.models.fields.SlugField')(unique=True, max_length=50, db_index=True)),
-            ('author', self.gf('django.db.models.fields.CharField')(max_length=128, blank=True)),
-            ('url', self.gf('django.db.models.fields.CharField')(max_length=255, blank=True)),
-            ('description', self.gf('django.db.models.fields.TextField')(blank=True)),
-            ('first_line_title', self.gf('django.db.models.fields.BooleanField')(default=False)),
-            ('skip_first_lines', self.gf('django.db.models.fields.IntegerField')(default=0)),
-        ))
-        db.send_create_signal('poetry', ['Poet'])
-
-        # Adding model 'Poem'
-        db.create_table('poetry_poem', (
-            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
-            ('slug', self.gf('django.db.models.fields.SlugField')(max_length=50, db_index=True)),
-            ('title', self.gf('django.db.models.fields.CharField')(max_length=255, null=True, blank=True)),
-            ('text', self.gf('django.db.models.fields.TextField')()),
-            ('poet', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['poetry.Poet'])),
-            ('created_at', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, db_index=True, blank=True)),
-            ('seen_at', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
-            ('view_count', self.gf('django.db.models.fields.IntegerField')(default=1)),
-            ('for_contest', self.gf('django.db.models.fields.BooleanField')(default=False)),
-            ('in_contest', self.gf('django.db.models.fields.BooleanField')(default=False)),
-        ))
-        db.send_create_signal('poetry', ['Poem'])
-
-
-    def backwards(self, orm):
-        
-        # Deleting model 'Poet'
-        db.delete_table('poetry_poet')
-
-        # Deleting model 'Poem'
-        db.delete_table('poetry_poem')
-
-
-    models = {
-        'poetry.poem': {
-            'Meta': {'object_name': 'Poem'},
-            'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'db_index': 'True', 'blank': 'True'}),
-            'for_contest': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
-            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'in_contest': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
-            'poet': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['poetry.Poet']"}),
-            'seen_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
-            'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'db_index': 'True'}),
-            'text': ('django.db.models.fields.TextField', [], {}),
-            'title': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
-            'view_count': ('django.db.models.fields.IntegerField', [], {'default': '1'})
-        },
-        'poetry.poet': {
-            'Meta': {'object_name': 'Poet'},
-            'author': ('django.db.models.fields.CharField', [], {'max_length': '128', 'blank': 'True'}),
-            'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
-            'first_line_title': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
-            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
-            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
-            'path': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
-            'skip_first_lines': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
-            'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50', 'db_index': 'True'}),
-            'url': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'})
-        }
-    }
-
-    complete_apps = ['poetry']
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='Poem',
+            fields=[
+                ('id', models.AutoField(verbose_name='ID', auto_created=True, serialize=False, primary_key=True)),
+                ('slug', models.SlugField()),
+                ('title', models.CharField(null=True, max_length=255, blank=True)),
+                ('text', models.TextField()),
+                ('created_at', models.DateTimeField(db_index=True, auto_now_add=True)),
+                ('seen_at', models.DateTimeField(auto_now_add=True)),
+                ('view_count', models.IntegerField(default=1)),
+                ('for_contest', models.BooleanField(default=False)),
+                ('in_contest', models.BooleanField(default=False)),
+            ],
+            options={
+            },
+            bases=(models.Model,),
+        ),
+        migrations.CreateModel(
+            name='Poet',
+            fields=[
+                ('id', models.AutoField(verbose_name='ID', auto_created=True, serialize=False, primary_key=True)),
+                ('name', models.CharField(max_length=50)),
+                ('path', models.CharField(max_length=255)),
+                ('slug', models.SlugField(unique=True)),
+                ('author', models.CharField(max_length=128, blank=True)),
+                ('url', models.CharField(max_length=255, blank=True)),
+                ('description', models.TextField(blank=True)),
+                ('first_line_title', models.BooleanField(default=False)),
+                ('skip_first_lines', models.IntegerField(default=0)),
+            ],
+            options={
+            },
+            bases=(models.Model,),
+        ),
+        migrations.AddField(
+            model_name='poem',
+            name='poet',
+            field=models.ForeignKey(to='poetry.Poet'),
+            preserve_default=True,
+        ),
+    ]
index 63bf8f2..c0e6c93 100644 (file)
@@ -17,7 +17,7 @@ class Poet(models.Model):
     first_line_title = models.BooleanField(default=False)
     skip_first_lines = models.IntegerField(default=0)
 
-    def __unicode__(self):
+    def __str__(self):
         return self.name
 
     def get_absolute_url(self):
@@ -30,7 +30,7 @@ class Poet(models.Model):
             stdout=subprocess.PIPE, stderr=subprocess.PIPE)
         os.chdir(curdir)
         stdout, stderr = proc.communicate()
-        text = unicode(stdout, "utf-8", errors="ignore")[:1000]
+        text = str(stdout, "utf-8", errors="ignore")[:1000]
         slug = get_hash(text)
         title = ''
         if self.first_line_title:
@@ -69,9 +69,9 @@ class Poem(models.Model):
     for_contest = models.BooleanField(default=False)
     in_contest = models.BooleanField(default=False)
 
-    def __unicode__(self):
-        oneliner = u"%s, %s" % (self.poet.name, self.pretty_title())
-        oneliner += u" [%s…]" % (u" ".join(self.text.split()[:5]))
+    def __str__(self):
+        oneliner = "%s, %s" % (self.poet.name, self.pretty_title())
+        oneliner += " [%s…]" % (" ".join(self.text.split()[:5]))
         return oneliner
 
     def get_absolute_url(self):
index 29473da..0286505 100644 (file)
@@ -5,6 +5,6 @@ from hashlib import sha1
 
 
 def get_hash(seed):
-    sha_digest = sha1('%s%s' %
-        (time.time(), unicode(seed).encode('utf-8', 'replace'))).digest()
-    return urlsafe_b64encode(sha_digest).replace('=', '').replace('_', '-').lower()
+    sha_digest = sha1(('%d%s' % (time.time(), str(seed))
+        ).encode('utf-8', 'replace')).digest()
+    return urlsafe_b64encode(sha_digest).replace(b'=', b'').replace(b'_', b'-').lower()
index 5743d4f..f7f889f 100644 (file)
@@ -1,7 +1,6 @@
--i http://pypi.nowoczesnapolska.org.pl/simple
+-i https://py.mdrn.pl:8443/simple
 
-Django>=1.6,<1.7
-South>=0.7.4
-fnpdjango>=0.1.18,<0.2
+Django>=1.7,<1.8
+fnpdjango>=0.2,<0.3
 
 django-piwik
index b9525ed..d09e780 100644 (file)
@@ -135,7 +135,6 @@ INSTALLED_APPS = [
     # 'django.contrib.admin',
     # 'django.contrib.admindocs',
 
-    'south',
     'piwik',
 
     'fnpdjango',
@@ -175,6 +174,6 @@ ALLOWED_HOSTS = [
 
 # Load localsettings, if they exist
 try:
-    from localsettings import *
+    from .localsettings import *
 except ImportError:
     pass