Remove Django backend

master
John Montagu, the 4th Earl of Sandvich 2024-11-03 14:24:06 -08:00
parent 3fab130ae0
commit b76d2786e5
Signed by: sandvich
GPG Key ID: 9A39BE37E602B22D
20 changed files with 0 additions and 547 deletions

1
backend/.gitignore vendored
View File

@ -1 +0,0 @@
venv/

View File

@ -1,11 +0,0 @@
from django.contrib import admin
from api.models import *
# Register your models here.
admin.site.register(Team)
admin.site.register(Player)
admin.site.register(PlayerInfo)
admin.site.register(PlayerInfo_Team)
admin.site.register(PlayerRole)

View File

@ -1,6 +0,0 @@
from django.apps import AppConfig
class ApiConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'api'

View File

@ -1,70 +0,0 @@
# Generated by Django 5.1.2 on 2024-10-24 01:56
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Player',
fields=[
('steam_id', models.BigIntegerField(primary_key=True, serialize=False)),
('name', models.CharField(max_length=63)),
],
),
migrations.CreateModel(
name='PlayerInfo_Team',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('team_role', models.CharField(choices=[('PL', 'Player'), ('CM', 'Coach/Mentor'), ('TC', 'Team Captain')], default='PL', max_length=2)),
('created_at', models.DateTimeField(auto_now_add=True)),
],
),
migrations.CreateModel(
name='Team',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('team_name', models.CharField(max_length=63)),
],
),
migrations.CreateModel(
name='PlayerInfo',
fields=[
('player', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, serialize=False, to='api.player')),
],
),
migrations.CreateModel(
name='PlayerRole',
fields=[
('playerinfo_team', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, primary_key=True, serialize=False, to='api.playerinfo_team')),
('player_role', models.CharField(choices=[('P_SCOUT', 'Pocket Scout'), ('F_SCOUT', 'Flank Scout'), ('SCOUT', 'Scout'), ('P_SOLLY', 'Pocket Soldier'), ('ROAMER', 'Roamer'), ('SOLDIER', 'Soldier'), ('PYRO', 'Pyro'), ('DEMO', 'Demoman'), ('HEAVY', 'Heavy'), ('ENGIE', 'Engineer'), ('MEDIC', 'Medic'), ('SNIPER', 'Sniper'), ('SPY', 'Spy')], max_length=7)),
('main', models.BooleanField(default=True)),
],
),
migrations.AddField(
model_name='playerinfo_team',
name='team',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='api.team'),
),
migrations.AddField(
model_name='playerinfo_team',
name='player_info',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.playerinfo'),
),
migrations.AddField(
model_name='playerinfo',
name='team',
field=models.ManyToManyField(through='api.PlayerInfo_Team', to='api.team'),
),
migrations.AlterUniqueTogether(
name='playerinfo_team',
unique_together={('player_info', 'team')},
),
]

View File

@ -1,18 +0,0 @@
# Generated by Django 5.1.2 on 2024-10-24 02:00
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='playerinfo_team',
name='team_role',
field=models.CharField(choices=[('PL', 'Player'), ('CM', 'Coach/Mentor'), ('TL', 'Team Leader')], default='PL', max_length=2),
),
]

View File

@ -1,36 +0,0 @@
# Generated by Django 5.1.2 on 2024-10-24 02:18
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0002_alter_playerinfo_team_team_role'),
]
operations = [
migrations.CreateModel(
name='PlayerMasterAvailability',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('start_time', models.DateTimeField()),
('playerinfo', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.playerinfo')),
],
options={
'constraints': [models.UniqueConstraint(fields=('playerinfo', 'start_time'), name='unique_master_availability')],
},
),
migrations.CreateModel(
name='PlayerTeamAvailability',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('start_time', models.DateTimeField()),
('playerinfo_team', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.playerinfo_team')),
],
options={
'constraints': [models.UniqueConstraint(fields=('playerinfo_team', 'start_time'), name='unique_team_availability')],
},
),
]

View File

@ -1,39 +0,0 @@
# Generated by Django 5.1.2 on 2024-10-24 02:21
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0003_playermasteravailability_playerteamavailability'),
]
operations = [
migrations.RemoveConstraint(
model_name='playermasteravailability',
name='unique_master_availability',
),
migrations.RemoveConstraint(
model_name='playerteamavailability',
name='unique_team_availability',
),
migrations.RenameField(
model_name='playermasteravailability',
old_name='playerinfo',
new_name='player_info',
),
migrations.RenameField(
model_name='playerteamavailability',
old_name='playerinfo_team',
new_name='player_info_team',
),
migrations.AddConstraint(
model_name='playermasteravailability',
constraint=models.UniqueConstraint(fields=('player_info', 'start_time'), name='unique_master_availability'),
),
migrations.AddConstraint(
model_name='playerteamavailability',
constraint=models.UniqueConstraint(fields=('player_info_team', 'start_time'), name='unique_team_availability'),
),
]

View File

@ -1,31 +0,0 @@
# Generated by Django 5.1.2 on 2024-10-26 00:32
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0004_remove_playermasteravailability_unique_master_availability_and_more'),
]
operations = [
migrations.AddField(
model_name='playerinfo_team',
name='playtime',
field=models.DurationField(default=datetime.timedelta(0)),
),
migrations.AddField(
model_name='playermasteravailability',
name='end_time',
field=models.DateTimeField(default=datetime.datetime(2024, 10, 26, 0, 32, 4, 805564, tzinfo=datetime.timezone.utc)),
preserve_default=False,
),
migrations.AddField(
model_name='playerteamavailability',
name='end_time',
field=models.DateTimeField(default=datetime.datetime(2024, 10, 26, 0, 32, 13, 959511, tzinfo=datetime.timezone.utc)),
preserve_default=False,
),
]

View File

@ -1,123 +0,0 @@
from datetime import timedelta
from typing import override
from django.db import models
from cpkmodel import CPkModel
from django.db.models.constraints import UniqueConstraint
class Team(models.Model):
team_name = models.CharField(max_length=63)
@override
def __str__(self) -> str:
return str(self.team_name)
class Player(models.Model):
steam_id = models.BigIntegerField(primary_key=True)
name = models.CharField(max_length=63)
@override
def __str__(self) -> str:
return f"{self.name}#{self.steam_id}"
class PlayerInfo(models.Model):
player = models.OneToOneField(
Player,
on_delete=models.CASCADE,
null=False,
primary_key=True
)
team = models.ManyToManyField(Team, through="PlayerInfo_Team")
@override
def __str__(self) -> str:
return str(self.player)
class PlayerInfo_Team(models.Model):
class TeamRole(models.TextChoices):
PLAYER = "PL", "Player"
COACH_MENTOR = "CM", "Coach/Mentor"
TEAM_LEADER = "TL", "Team Leader"
player_info = models.ForeignKey(PlayerInfo, on_delete=models.CASCADE)
team = models.ForeignKey(Team, on_delete=models.CASCADE, null=True)
team_role = models.CharField(
max_length=2,
choices=TeamRole.choices,
default=TeamRole.PLAYER
)
playtime = models.DurationField(default=timedelta(0))
created_at = models.DateTimeField(auto_now_add=True)
@override
def __str__(self) -> str:
return f"{self.player_info} in {self.team} as {self.team_role}"
class Meta:
unique_together = (("player_info", "team"),)
class PlayerRole(models.Model):
class Role(models.TextChoices):
P_SCOUT = "P_SCOUT", "Pocket Scout"
F_SCOUT = "F_SCOUT", "Flank Scout"
SCOUT = "SCOUT", "Scout"
P_SOLLY = "P_SOLLY", "Pocket Soldier"
ROAMER = "ROAMER", "Roamer"
SOLDIER = "SOLDIER", "Soldier"
PYRO = "PYRO", "Pyro"
DEMO = "DEMO", "Demoman"
HEAVY = "HEAVY", "Heavy"
ENGIE = "ENGIE", "Engineer"
MEDIC = "MEDIC", "Medic"
SNIPER = "SNIPER", "Sniper"
SPY = "SPY", "Spy"
playerinfo_team = models.ForeignKey(
PlayerInfo_Team,
on_delete=models.CASCADE,
primary_key=True,
)
player_role = models.CharField(
max_length=7,
choices=Role.choices,
)
main = models.BooleanField(default=True)
@override
def __str__(self) -> str:
return f"{self.playerinfo_team.player_info} ({self.player_role} for {self.playerinfo_team.team})"
class PlayerTeamAvailability(models.Model):
player_info_team = models.ForeignKey(PlayerInfo_Team, on_delete=models.CASCADE)
start_time = models.DateTimeField()
end_time = models.DateTimeField()
class Meta:
constraints = [
UniqueConstraint(fields=[
"player_info_team",
"start_time"
], name="unique_team_availability")
]
@override
def __str__(self) -> str:
return f"{self.player_info_team} available on {self.start_time}"
class PlayerMasterAvailability(models.Model):
player_info = models.ForeignKey(PlayerInfo, on_delete=models.CASCADE)
start_time = models.DateTimeField()
end_time = models.DateTimeField()
class Meta:
constraints = [
UniqueConstraint(fields=[
"player_info",
"start_time"
], name="unique_master_availability")
]
@override
def __str__(self) -> str:
return f"{self.player_info} available on {self.start_time}"

View File

@ -1,3 +0,0 @@
from django.test import TestCase
# Create your tests here.

View File

@ -1,3 +0,0 @@
from django.shortcuts import render
# Create your views here.

View File

@ -1,16 +0,0 @@
"""
ASGI config for availabili_tf project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'availabili_tf.settings')
application = get_asgi_application()

View File

@ -1,125 +0,0 @@
"""
Django settings for availabili_tf project.
Generated by 'django-admin startproject' using Django 5.1.2.
For more information on this file, see
https://docs.djangoproject.com/en/5.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.1/ref/settings/
"""
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-zxk500vvcl9@tru__++ze08$#=%yr_*y_*w9bup$thf@p6gn=v'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'api',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'availabili_tf.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'availabili_tf.wsgi.application'
# Database
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/5.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/5.1/howto/static-files/
STATIC_URL = 'static/'
# Default primary key field type
# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

View File

@ -1,23 +0,0 @@
"""
URL configuration for availabili_tf project.
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/5.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
urlpatterns = [
path("admin/", admin.site.urls),
path("/", admin.site.urls),
]

View File

@ -1,16 +0,0 @@
"""
WSGI config for availabili_tf project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/5.1/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'availabili_tf.settings')
application = get_wsgi_application()

View File

@ -1,22 +0,0 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'availabili_tf.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()

View File

@ -1,4 +0,0 @@
djangorestframework
markdown
pygments
django-filter