Skip to content

Commit

Permalink
Upgrade to Django 1.8
Browse files Browse the repository at this point in the history
- Made all the changes so install, migrate, runserver, test work
- Tried playing a game, worked fine.
  • Loading branch information
therealphildini committed May 20, 2015
1 parent 49f99f2 commit 3807e5d
Show file tree
Hide file tree
Showing 11 changed files with 243 additions and 12 deletions.
4 changes: 2 additions & 2 deletions cah/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
}
}

REDIS_URL = urlparse.urlparse(get_env_variable('REDISCLOUD_URL'))
SOCKETIO_URL = get_env_variable("SOCKETIO_URL")
# REDIS_URL = urlparse.urlparse(get_env_variable('REDISCLOUD_URL'))
# SOCKETIO_URL = get_env_variable("SOCKETIO_URL")

#INSTALLED_APPS += ('debug_toolbar', )
INTERNAL_IPS = ('127.0.0.1',)
Expand Down
2 changes: 1 addition & 1 deletion cah/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# vim:ts=4:sw=4:softtabstop=4:smarttab:expandtab
#

from django.conf.urls.defaults import patterns, include, url
from django.conf.urls import patterns, include, url

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
Expand Down
1 change: 1 addition & 0 deletions cards/forms/card_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
class SubmittedCardForm(ModelForm):
class Meta:
model = SubmittedCard
fields = ['submitter', 'card_type', 'text']

def __init__(self, *args, **kwargs):
user = kwargs.pop('user')
Expand Down
123 changes: 123 additions & 0 deletions cards/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
import model_utils.fields
import jsonfield.fields
import django.db.models.deletion
import django.utils.timezone
from django.conf import settings


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='BlackCard',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('text', models.CharField(max_length=255)),
('draw', models.SmallIntegerField(default=0)),
('pick', models.SmallIntegerField(default=1)),
('watermark', models.CharField(max_length=100, null=True)),
],
options={
'db_table': 'black_cards',
},
),
migrations.CreateModel(
name='CardSet',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('active', models.BooleanField(default=True)),
('name', models.CharField(unique=True, max_length=255)),
('base_deck', models.BooleanField(default=True)),
('description', models.CharField(max_length=255)),
('weight', models.SmallIntegerField(default=0)),
('black_card', models.ManyToManyField(to='cards.BlackCard', db_table=b'card_set_black_card')),
],
options={
'db_table': 'card_set',
},
),
migrations.CreateModel(
name='Game',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, verbose_name='created', editable=False)),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, verbose_name='modified', editable=False)),
('name', models.CharField(unique=True, max_length=140)),
('game_state', models.CharField(max_length=140)),
('is_active', models.BooleanField(default=True)),
('gamedata', jsonfield.fields.JSONField()),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='Player',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, verbose_name='created', editable=False)),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, verbose_name='modified', editable=False)),
('name', models.CharField(max_length=140)),
('player_data', jsonfield.fields.JSONField(blank=True)),
('wins', models.IntegerField(blank=True)),
('game', models.ForeignKey(to='cards.Game')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, blank=True, to=settings.AUTH_USER_MODEL, null=True)),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='StandardSubmission',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, verbose_name='created', editable=False)),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, verbose_name='modified', editable=False)),
('winner', models.BooleanField(default=False)),
('complete_submission', models.TextField(null=True, blank=True)),
('blackcard', models.ForeignKey(to='cards.BlackCard', null=True)),
('game', models.ForeignKey(to='cards.Game', null=True)),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='SubmittedCard',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('card_type', models.CharField(default=b'1', max_length=1, choices=[(b'1', b'White Card'), (b'2', b'Black Card')])),
('text', models.CharField(max_length=255)),
('submitter', models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL, null=True)),
],
),
migrations.CreateModel(
name='WhiteCard',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('text', models.CharField(max_length=255)),
('watermark', models.CharField(max_length=100, null=True)),
],
options={
'db_table': 'white_cards',
},
),
migrations.AddField(
model_name='standardsubmission',
name='submissions',
field=models.ManyToManyField(to='cards.WhiteCard', null=True),
),
migrations.AddField(
model_name='cardset',
name='white_card',
field=models.ManyToManyField(to='cards.WhiteCard', db_table=b'card_set_white_card'),
),
]
File renamed without changes.
2 changes: 1 addition & 1 deletion cards/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ def twitter_text(self):
return text


@transaction.commit_on_success
@transaction.atomic
def dict2db(d, verbosity=1, replace_existing=False):
"""Import complete card sets.
Does not allow using existing cards, cardset needs to include the card
Expand Down
2 changes: 1 addition & 1 deletion cards/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.conf.urls.defaults import patterns, include, url
from django.conf.urls import patterns, include, url

from views.game_views import (
GameView,
Expand Down
6 changes: 3 additions & 3 deletions cards/views/game_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def get_context_data(self, *args, **kwargs):
name for name in self.game.gamedata['players'] if name not in self.game.gamedata['submissions'] and name != card_czar_name
]

context['socketio'] = settings.SOCKETIO_URL
# context['socketio'] = settings.SOCKETIO_URL
context['qr_code_url'] = reverse('game-qrcode-view', kwargs={'pk': self.game.id})

submissions = StandardSubmission.objects.filter(game=self.game).order_by('-id')[:10]
Expand Down Expand Up @@ -340,7 +340,7 @@ def form_valid(self, form):
)
self.game.save()

push_notification(str(self.game.name))
# push_notification(str(self.game.name))

return super(GameView, self).form_valid(form)

Expand Down Expand Up @@ -449,7 +449,7 @@ def form_valid(self, form):
if really_exit == 'yes': # FIXME use bool via coerce?
self.game.del_player(self.player_name)
self.game.save()
push_notification(str(self.game.name))
# push_notification(str(self.game.name))
return super(GameExitView, self).form_valid(form)


Expand Down
107 changes: 107 additions & 0 deletions porting_notes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
(cards-against-django)SensitiveDependence:cards-against-django phildini$ CAH_KEY=12345 python manage.py runserver --settings=cah.settings.local
Traceback (most recent call last):
File "manage.py", line 17, in <module>
execute_from_command_line(sys.argv)
File "/Users/phildini/Repos/cards-against-django/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/Users/phildini/Repos/cards-against-django/lib/python2.7/site-packages/django/core/management/__init__.py", line 312, in execute
django.setup()
File "/Users/phildini/Repos/cards-against-django/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/phildini/Repos/cards-against-django/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/Users/phildini/Repos/cards-against-django/lib/python2.7/site-packages/django/apps/config.py", line 86, in create
module = import_module(entry)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Users/phildini/Repos/cards-against-django/lib/python2.7/site-packages/django_nose/__init__.py", line 4, in <module>
from django_nose.runner import *
File "/Users/phildini/Repos/cards-against-django/lib/python2.7/site-packages/django_nose/runner.py", line 20, in <module>
from django.db.backends.creation import BaseDatabaseCreation
ImportError: No module named creation

==========================================

(cards-against-django)SensitiveDependence:cards-against-django phildini$ CAH_KEY=12345 python manage.py runserver --settings=cah.settings.local
Traceback (most recent call last):
File "manage.py", line 17, in <module>
execute_from_command_line(sys.argv)
File "/Users/phildini/Repos/cards-against-django/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/Users/phildini/Repos/cards-against-django/lib/python2.7/site-packages/django/core/management/__init__.py", line 312, in execute
django.setup()
File "/Users/phildini/Repos/cards-against-django/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/phildini/Repos/cards-against-django/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/Users/phildini/Repos/cards-against-django/lib/python2.7/site-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Users/phildini/Repos/cards-against-django/cards/models.py", line 546, in <module>
@transaction.commit_on_success
AttributeError: 'module' object has no attribute 'commit_on_success'

=================

(cards-against-django)SensitiveDependence:cards-against-django phildini$ CAH_KEY=12345 python manage.py runserver --settings=cah.settings.local
Performing system checks...

System check identified some issues:

WARNINGS:
cards.StandardSubmission.submissions: (fields.W340) null has no effect on ManyToManyField.

System check identified 1 issue (0 silenced).
There is no South database module 'south.db.sqlite3' for your database. Please either choose a supported database, check for SOUTH_DATABASE_ADAPTER[S] settings, or remove South from INSTALLED_APPS.

===================

(cards-against-django)SensitiveDependence:cards-against-django phildini$ CAH_KEY=12345 python manage.py runserver --settings=cah.settings.local
Performing system checks...

System check identified some issues:

WARNINGS:
cards.StandardSubmission.submissions: (fields.W340) null has no effect on ManyToManyField.

System check identified 1 issue (0 silenced).

You have unapplied migrations; your app may not work properly until they are applied.
Run 'python manage.py migrate' to apply them.

May 16, 2015 - 13:49:21
Django version 1.8.1, using settings 'cah.settings.local'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

================

(cards-against-django)SensitiveDependence:cards-against-django phildini$ CAH_KEY=12345 python manage.py migrate --fake --settings=cah.settings.local
System check identified some issues:

WARNINGS:
cards.StandardSubmission.submissions: (fields.W340) null has no effect on ManyToManyField.
Operations to perform:
Synchronize unmigrated apps: staticfiles, twitter, messages, allauth, facebook, django_nose, cards, rest_framework
Apply all migrations: account, sessions, admin, sites, auth, contenttypes, socialaccount
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Installing custom SQL...
Running migrations:
Rendering model states... DONE
Applying auth.0001_initial... FAKED
Applying account.0001_initial... FAKED
Applying account.0002_auto_20150516_1527... FAKED
Applying admin.0001_initial... FAKED
Applying auth.0002_alter_permission_name_max_length... FAKED
Applying auth.0003_alter_user_email_max_length... FAKED
Applying auth.0004_alter_user_username_opts... FAKED
Applying auth.0005_alter_user_last_login_null... FAKED
Applying auth.0006_require_contenttypes_0002... FAKED
Applying sessions.0001_initial... FAKED
Applying sites.0001_initial... FAKED
Applying socialaccount.0001_initial... FAKED
Applying socialaccount.0002_auto_20150516_1527... FAKED
(cards-against-django)SensitiveDependence:cards-against-django phildini$
4 changes: 2 additions & 2 deletions requirements/_base.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Basic libraries
Django==1.5.4
Django==1.8.2
Unipath==0.2.1
django-model-utils==1.2.0
wsgiref==0.1.2
Expand All @@ -10,7 +10,7 @@ psycopg2==2.4.6
django-robots-txt==0.4

# Authentication & Dependencies
django-allauth==0.10.1
django-allauth==0.19.1
httplib2==0.8
oauth2==1.5.211
oauthlib==0.4.0
Expand Down
4 changes: 2 additions & 2 deletions requirements/local.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
-r _base.txt

django-debug-toolbar==0.9.4
nose==1.3.0
django-nose==1.1
nose==1.3.6
django-nose==1.4
factory-boy==2.1.2

0 comments on commit 3807e5d

Please sign in to comment.