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

Refactor #1

Open
wants to merge 13 commits into
base: main
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
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ clean:
build:
docker-compose build

run-dev:
-pkill docker-compose
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up

run:
-pkill docker-compose
docker-compose up
Expand All @@ -28,7 +32,3 @@ init_db: clean_db

backup_db:
docker-compose exec db pg_dumpall -c -U postgres > clover_dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql

install_package:
docker-compose exec backend pip3 install $(pkg)
docker-compose exec backend pip3 freeze | tail -n +1 > backend/requirements.txt
19 changes: 13 additions & 6 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
FROM python:3.10-rc-alpine

####
# Install Poetry
####
RUN apk add curl
ENV BASE_POETRY_VERSION=1.1.13
RUN echo Installing poetry $BASE_POETRY_VERSION \
&& curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3 - --version $BASE_POETRY_VERSION
ENV PATH /root/.poetry/bin:$PATH

ENV DJANGO_PRODUCTION=false
ENV PYTHONUNBUFFERED 1

Expand All @@ -8,13 +17,11 @@ RUN apk add --no-cache libpq postgresql-dev build-base zlib-dev jpeg-dev tiff-de
RUN mkdir /logs
RUN mkdir /logs/gunicorn

WORKDIR /app
ADD . /app/backend
WORKDIR /app/backend

EXPOSE 80

ADD requirements.txt /app/
RUN pip3 install -r requirements.txt

ADD . /app/
RUN poetry install

CMD ["/bin/sh","/app/initialize.sh"]
CMD ["/bin/sh","/app/backend/initialize.sh"]
File renamed without changes.
2 changes: 1 addition & 1 deletion backend/src/clover/asgi.py → backend/backend/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'clover.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings')

application = get_asgi_application()
File renamed without changes.
16 changes: 15 additions & 1 deletion backend/src/games/admin.py → backend/backend/games/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.contrib import admin
from django.utils.html import mark_safe
from . import models

from backend.games import models

# Register your models here.

Expand All @@ -17,9 +18,22 @@
@admin.register(models.Board)
class BoardAdmin(admin.ModelAdmin):
pass

@admin.register(models.BoardClientState)
class BoardClientStateAdmin(admin.ModelAdmin):
pass

@admin.register(models.BoardGuess)
class BoardGuessAdmin(admin.ModelAdmin):
pass
# fields = ('fen', 'turn_count', 'game_link', 'created_time', 'last_updated_time')
# readonly_fields = ('game_link', 'created_time', 'last_updated_time')

# def game_link(self, obj):
# url = '../../../game/%d/change' % obj.game.id
# return mark_safe('<a href="%s">%s</a>' % (url, obj.game))


@admin.register(models.WordList)
class WordListAdmin(admin.ModelAdmin):
pass
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

class GamesConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'games'
name = 'backend.games'
40 changes: 40 additions & 0 deletions backend/backend/games/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Generated by Django 4.0.4 on 2022-05-23 08:01

from django.db import migrations, models
import django.db.models.deletion
import django_jsonform.models.fields


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Board',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_time', models.DateTimeField(auto_now_add=True)),
('last_updated_time', models.DateTimeField(auto_now=True)),
('clues', django_jsonform.models.fields.ArrayField(base_field=models.CharField(blank=True, max_length=20), null=True, size=4)),
('cards', django_jsonform.models.fields.ArrayField(base_field=django_jsonform.models.fields.ArrayField(base_field=models.CharField(max_length=20), size=4), size=20)),
('answer', django_jsonform.models.fields.ArrayField(base_field=django_jsonform.models.fields.ArrayField(base_field=models.IntegerField(), size=2), size=4)),
('suggested_num_cards', models.IntegerField(null=True)),
('author', models.CharField(blank=True, max_length=50)),
('daily_set_time', models.DateTimeField(null=True)),
],
),
migrations.CreateModel(
name='BoardClientState',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_time', models.DateTimeField(auto_now_add=True)),
('data', models.JSONField()),
('client_id', models.CharField(max_length=50)),
('board', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='games.board')),
],
),
]
24 changes: 24 additions & 0 deletions backend/backend/games/migrations/0002_boardguess.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 4.0.4 on 2022-05-23 08:01

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

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

operations = [
migrations.CreateModel(
name='BoardGuess',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_time', models.DateTimeField(auto_now_add=True)),
('data', models.JSONField()),
('client_id', models.CharField(blank=True, max_length=50)),
('board', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='games.board')),
],
),
]
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Generated by Django 4.0.4 on 2022-05-17 07:34
# Generated by Django 4.0.4 on 2022-06-22 14:24

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('games', '0001_initial'),
('games', '0002_boardguess'),
]

operations = [
migrations.AddField(
model_name='board',
name='author',
field=models.CharField(blank=True, max_length=50),
name='adult',
field=models.BooleanField(default=False),
),
]
29 changes: 29 additions & 0 deletions backend/backend/games/migrations/0004_wordlist_board_word_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Generated by Django 4.0.4 on 2022-06-24 07:28

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('games', '0003_board_adult'),
]

operations = [
migrations.CreateModel(
name='WordList',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=40, unique=True)),
('words', models.TextField(blank=True)),
('created_time', models.DateTimeField(auto_now_add=True)),
('last_updated_time', models.DateTimeField(auto_now=True)),
],
),
migrations.AddField(
model_name='board',
name='word_list',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='games.wordlist'),
),
]
18 changes: 18 additions & 0 deletions backend/backend/games/migrations/0005_wordlist_adult.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.0.4 on 2022-06-24 07:49

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('games', '0004_wordlist_board_word_list'),
]

operations = [
migrations.AddField(
model_name='wordlist',
name='adult',
field=models.BooleanField(default=False),
),
]
Loading