Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django 19 #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified manage.py
100644 → 100755
Empty file.
10 changes: 7 additions & 3 deletions ss_chess_tour/settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Django settings for ss_chess_tour project.
import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

DEBUG = True
TEMPLATE_DEBUG = DEBUG
Expand All @@ -11,9 +15,10 @@

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'ss-chess-tour', # Or path to database file if using sqlite3.
# The following settings are not used with sqlite3:
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
'USER': 'root',
'PASSWORD': '',
'HOST': '', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
Expand All @@ -23,7 +28,7 @@

# Hosts/domain names that are valid for this site; required if DEBUG is False
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
ALLOWED_HOSTS = ['ss-chess-tour.lo', 'ss-chess-tour.niakhaichyk.org']
ALLOWED_HOSTS = ['ss-chess-tour.lo', 'ss-chess-tour.niakhaichyk.org','localhost']

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
Expand Down Expand Up @@ -129,7 +134,6 @@
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
'tournaments',
'south'
)

# A sample logging configuration. The only tangible logging
Expand Down
220 changes: 97 additions & 123 deletions tournaments/migrations/0001_initial.py

Large diffs are not rendered by default.

85 changes: 85 additions & 0 deletions tournaments/migrations/0002_auto_20160628_1506.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-06-28 12:06
from __future__ import unicode_literals

from django.db import migrations, connection


def forwards(apps, schema_editor):
if connection.vendor == 'mysql':
query = """
CREATE VIEW tournaments_tournament_player_score AS
SELECT CONCAT(tournaments_round.tournament_id, ':', player_score.player_id) as id,
tournaments_round.tournament_id, player_score.player_id, SUM(player_score.score) as score,
player.name, player.rating, player.fide_title,
case player.fide_title
when "GM" then 8
when "IM" then 7
when "WGM" then 6
when "FM" then 5
when "WIM" then 4
when "CM" then 3
when "WFM" then 2
when "WCM" then 1
else 0
end as title_number

FROM tournaments_round
INNER JOIN tournaments_game_player_score as `player_score`
ON (tournaments_round.id = player_score.round_id)
INNER JOIN tournaments_player as `player`
ON (player.id = player_score.player_id)
GROUP BY tournaments_round.tournament_id, player_score.player_id
"""
else :
query = """
CREATE VIEW tournaments_tournament_player_score AS
SELECT tournaments_round.tournament_id || ':' || player_score.player_id as id,
tournaments_round.tournament_id, player_score.player_id, SUM(player_score.score) as score,
player.name, player.rating, player.fide_title,
case player.fide_title
when "GM" then 8
when "IM" then 7
when "WGM" then 6
when "FM" then 5
when "WIM" then 4
when "CM" then 3
when "WFM" then 2
when "WCM" then 1
else 0
end as title_number

FROM tournaments_round
INNER JOIN tournaments_game_player_score as `player_score`
ON (tournaments_round.id = player_score.round_id)
INNER JOIN tournaments_player as `player`
ON (player.id = player_score.player_id)
GROUP BY tournaments_round.tournament_id, player_score.player_id
"""
connection.cursor().execute(query);

def backwards(apps, schema_editor):
connection.cursor().execute(""" DROP VIEW tournaments_tournament_player_score; """)


class Migration(migrations.Migration):

dependencies = [
('tournaments', '0001_initial'),
]

operations = [
migrations.RunSQL("""
CREATE VIEW tournaments_game_player_score AS
SELECT id as game_id, round_id, player_id, player_score as score FROM tournaments_game
UNION ALL
SELECT id as game_id, round_id, opponent_id as player_id, opponent_score as score
FROM tournaments_game
WHERE opponent_id IS NOT NULL
;
""",
""" DROP VIEW tournaments_game_player_score;"""),

migrations.RunPython(forwards, backwards)
]

61 changes: 0 additions & 61 deletions tournaments/migrations/0002_auto__chg_field_game_opponent.py

This file was deleted.

69 changes: 0 additions & 69 deletions tournaments/migrations/0003_add_game_player_score_view.py

This file was deleted.

85 changes: 0 additions & 85 deletions tournaments/migrations/0004_add_tournament_score_view.py

This file was deleted.

Loading