parent
5312abd25b
commit
7b106409ae
@ -0,0 +1,2 @@
|
||||
venv/
|
||||
__init__.py
|
||||
@ -0,0 +1,16 @@
|
||||
"""
|
||||
ASGI config for NIP_APP 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/4.2/howto/deployment/asgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.asgi import get_asgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'NIP_APP.settings')
|
||||
|
||||
application = get_asgi_application()
|
||||
@ -0,0 +1,128 @@
|
||||
"""
|
||||
Django settings for NIP_APP project.
|
||||
|
||||
Generated by 'django-admin startproject' using Django 4.2.23.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/4.2/topics/settings/
|
||||
|
||||
For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/4.2/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/4.2/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = 'django-insecure-kk922joxhefnfkzxvg_aqecsq546)ae8o22#33+6h))_3^nm#!'
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = []
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
|
||||
# CUSTOMS
|
||||
'app',
|
||||
]
|
||||
|
||||
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 = 'NIP_APP.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 = 'NIP_APP.wsgi.application'
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': BASE_DIR / 'db.sqlite3',
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/4.2/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/4.2/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/4.2/howto/static-files/
|
||||
|
||||
STATIC_URL = 'static/'
|
||||
|
||||
# Default primary key field type
|
||||
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
@ -0,0 +1,23 @@
|
||||
"""
|
||||
URL configuration for NIP_APP project.
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/4.2/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, include
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('', include('app.urls')), # APP-URLs Einbindung
|
||||
]
|
||||
@ -0,0 +1,16 @@
|
||||
"""
|
||||
WSGI config for NIP_APP 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/4.2/howto/deployment/wsgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'NIP_APP.settings')
|
||||
|
||||
application = get_wsgi_application()
|
||||
@ -0,0 +1,6 @@
|
||||
from django.contrib import admin
|
||||
from app.models import games, Player, answer
|
||||
|
||||
admin.site.register(games)
|
||||
admin.site.register(Player)
|
||||
admin.site.register(answer)
|
||||
@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class AppConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'app'
|
||||
@ -0,0 +1,23 @@
|
||||
# Generated by Django 4.2.23 on 2025-06-18 23:06
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='games',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('key', models.CharField(max_length=14, unique=True)),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('state', models.BooleanField(default=True)),
|
||||
],
|
||||
),
|
||||
]
|
||||
@ -0,0 +1,22 @@
|
||||
# Generated by Django 4.2.23 on 2025-06-18 23:40
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('app', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Player',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=100)),
|
||||
('game', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='players', to='app.games')),
|
||||
],
|
||||
),
|
||||
]
|
||||
@ -0,0 +1,18 @@
|
||||
# Generated by Django 4.2.23 on 2025-06-18 23:52
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('app', '0002_player'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='player',
|
||||
name='leader',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
]
|
||||
@ -0,0 +1,22 @@
|
||||
# Generated by Django 4.2.23 on 2025-06-19 00:12
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('app', '0003_player_leader'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='answer',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('answer', models.CharField(max_length=250, unique=True)),
|
||||
('player', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='answers', to='app.player')),
|
||||
],
|
||||
),
|
||||
]
|
||||
@ -0,0 +1,18 @@
|
||||
# Generated by Django 4.2.23 on 2025-06-19 00:13
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('app', '0004_answer'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='games',
|
||||
name='round_open',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
]
|
||||
@ -0,0 +1,18 @@
|
||||
# Generated by Django 4.2.23 on 2025-06-19 00:41
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('app', '0005_games_round_open'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='answer',
|
||||
name='akey',
|
||||
field=models.CharField(max_length=1, null=True),
|
||||
),
|
||||
]
|
||||
@ -0,0 +1,18 @@
|
||||
# Generated by Django 4.2.23 on 2025-06-19 01:19
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('app', '0006_answer_akey'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='answer',
|
||||
name='answer',
|
||||
field=models.CharField(max_length=250),
|
||||
),
|
||||
]
|
||||
@ -0,0 +1,27 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
class games(models.Model):
|
||||
key = models.CharField(max_length=14, unique=True)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
state = models.BooleanField(default=True)
|
||||
round_open = models.BooleanField(default=False)
|
||||
|
||||
def __str__(self):
|
||||
return self.key
|
||||
|
||||
class Player(models.Model):
|
||||
name = models.CharField(max_length=100)
|
||||
game = models.ForeignKey(games, on_delete=models.CASCADE, related_name='players')
|
||||
leader = models.BooleanField(default=False)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.name} ({self.game.key})"
|
||||
|
||||
class answer(models.Model):
|
||||
answer = models.CharField(max_length=250, unique=False, null=False)
|
||||
player = models.ForeignKey(Player, on_delete=models.CASCADE, related_name='answers')
|
||||
akey = models.CharField(max_length=1, null=True, unique=False)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.answer}"
|
||||
|
After Width: | Height: | Size: 44 KiB |
@ -0,0 +1,114 @@
|
||||
{% load static %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Spielseite</title>
|
||||
<style>
|
||||
body { text-align: center; font-family: sans-serif; }
|
||||
img { max-width: 200px; margin: 30px auto; }
|
||||
form { margin-top: 20px; }
|
||||
button { padding: 10px 20px; font-size: 16px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<style>
|
||||
body {
|
||||
height: 100vh;
|
||||
background-color: #F5F5F5;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: top;
|
||||
margin-top: 3rem;
|
||||
font-family: Arial, sans-serif;
|
||||
padding: 20px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- PNG-Logo -->
|
||||
<img src="{% static 'nip-app.png' %}" alt="Logo" onclick="window.location.href='../'">
|
||||
|
||||
{% if has_name %}
|
||||
<!-- Wenn Name gesetzt ist -->
|
||||
<p>Spieler erkannt. <br><b>{{ player_data.name }}{% if player_data.leader %} - <i>{{ countPlayers }} gesamt</i>{% endif %}</b></p>
|
||||
<form method="get">
|
||||
<input type="hidden" name="key" value="{{ game_key }}">
|
||||
<button type="submit">Aktualisieren</button>
|
||||
</form>
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<button type="submit" name="btn_logout">Abmelden</button>
|
||||
|
||||
{% if player_data.leader %}
|
||||
{% if round_open %}
|
||||
<button style="background-color: red; color: white;" type="submit" name="btn_stop">Stop</button>
|
||||
{% else %}
|
||||
<button style="background-color: green; color: white;" type="submit" name="btn_start">Start</button>
|
||||
<button style="background-color: rgb(128, 15, 126); color: white;" type="submit" name="btn_clear">Leeren</button>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if round_open and not openAnswer %}
|
||||
<br><br>
|
||||
<input type="text" name="input_answer">
|
||||
<button type="submit" name="btn_sendAnswer">Antwort senden</button>
|
||||
{% endif %}
|
||||
</form>
|
||||
{% else %}
|
||||
<!-- Wenn noch kein Name vorhanden ist -->
|
||||
<p>Bitte Namen eingeben:</p>
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<input type="text" name="input_newPlayerName" id="input_newPlayerName">
|
||||
<button type="submit" name="btn_login_name">Namen einloggen</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% if player_data.leader %}
|
||||
|
||||
<style>
|
||||
table {
|
||||
width: 100%;
|
||||
max-width: 600px;
|
||||
border-collapse: collapse;
|
||||
background-color: white;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||
margin-top: 2rem;
|
||||
}
|
||||
|
||||
th, td {
|
||||
padding: 10px;
|
||||
text-align: left;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
th {
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Spieler</th>
|
||||
<th>Antwort</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for answer in answers %}
|
||||
<tr>
|
||||
<td>{{ answer.akey }}</td>
|
||||
<td>{{ answer.player.name }}</td>
|
||||
<td>{{ answer.answer }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{% endif %}
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,79 @@
|
||||
{% load static %}
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Nobody is Perfect | Die APP</title>
|
||||
</head>
|
||||
<body>
|
||||
<style>
|
||||
body {
|
||||
height: 100vh;
|
||||
background-color: #F5F5F5;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-family: Arial, sans-serif;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
img.logo {
|
||||
max-width: 200px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
button {
|
||||
padding: 10px 20px;
|
||||
font-size: 16px;
|
||||
margin-bottom: 30px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
max-width: 600px;
|
||||
border-collapse: collapse;
|
||||
background-color: white;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
th, td {
|
||||
padding: 10px;
|
||||
text-align: left;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
th {
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<img src="{% static 'nip-app.png' %}" alt="App Logo" class="logo">
|
||||
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<button type="submit" name="btn_newGame" value="newGame">Neues Spiel</button>
|
||||
</form>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Spiel-ID</th>
|
||||
<th>Key</th>
|
||||
<th>Status</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for game in games %}
|
||||
<tr>
|
||||
<td>{{ game.id }}</td>
|
||||
<td>{{ game.key }}</td>
|
||||
<td>{{ game.state }}</td>
|
||||
<td><a href="game?key={{game.key}}">öffnen</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
@ -0,0 +1,7 @@
|
||||
from django.urls import path
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path('', views.home, name='home'),
|
||||
path('game', views.game, name='game'),
|
||||
]
|
||||
@ -0,0 +1,106 @@
|
||||
from django.shortcuts import render, redirect
|
||||
from django.urls import reverse
|
||||
from django.utils.http import urlencode
|
||||
import app.models as AppDB
|
||||
import random
|
||||
import string
|
||||
|
||||
def random_alphabet(playerCount, listOfUsed):
|
||||
full_alphabet = ("A", "B", "C", "D", "E", "F", "G", "H", "I", "J")
|
||||
game_alphabet = full_alphabet[:playerCount+1]
|
||||
|
||||
# Verfügbare Buchstaben berechnen
|
||||
available_letters = list(set(game_alphabet) - set(listOfUsed))
|
||||
|
||||
# Optional: sortieren (wenn Reihenfolge wichtig ist)
|
||||
available_letters.sort()
|
||||
|
||||
# Zufälligen Buchstaben wählen (falls verfügbar)
|
||||
if available_letters:
|
||||
chosen_letter = random.choice(available_letters)
|
||||
print(f"Ausgewählter Buchstabe: {chosen_letter}")
|
||||
return chosen_letter
|
||||
else:
|
||||
print("Keine Buchstaben mehr verfügbar.")
|
||||
return "X"
|
||||
|
||||
|
||||
def generate_key_view():
|
||||
key = ''.join(random.choices(string.ascii_uppercase + string.digits, k=14))
|
||||
|
||||
# Optional: Stelle sicher, dass der Key einzigartig ist
|
||||
while AppDB.games.objects.filter(key=key).exists():
|
||||
key = ''.join(random.choices(string.ascii_uppercase + string.digits, k=14))
|
||||
|
||||
AppDB.games.objects.create(key=key)
|
||||
|
||||
return key
|
||||
|
||||
def home(request):
|
||||
if request.method == "POST":
|
||||
generate_key_view()
|
||||
|
||||
requestGames = AppDB.games.objects.all()
|
||||
return render(request, 'app/home.html', {'games':requestGames})
|
||||
|
||||
def game(request):
|
||||
game_key = request.GET.get("key")
|
||||
base_url = reverse("game")
|
||||
query_string = urlencode({"key": game_key})
|
||||
game_instance = AppDB.games.objects.get(key=game_key)
|
||||
player_name = request.session.get("device_name")
|
||||
player_instance = AppDB.Player.objects.get(name=player_name) if player_name else None
|
||||
openAnswer = True if AppDB.answer.objects.filter(player=player_instance).exists() else False
|
||||
players_inGame = AppDB.Player.objects.filter(game=game_instance)
|
||||
|
||||
if request.method == "POST":
|
||||
if "btn_login_name" in request.POST:
|
||||
input_PlayerName = request.POST.get("input_newPlayerName")
|
||||
request.session["device_name"] = input_PlayerName
|
||||
newEntry_Player = AppDB.Player()
|
||||
|
||||
if not players_inGame.exists():
|
||||
newEntry_Player.leader = True
|
||||
|
||||
newEntry_Player.game = game_instance
|
||||
print(query_string)
|
||||
newEntry_Player.name = input_PlayerName
|
||||
newEntry_Player.save()
|
||||
# Redirect mit key
|
||||
return redirect(f"{base_url}?{query_string}")
|
||||
|
||||
if "btn_logout" in request.POST:
|
||||
toDeleteEntry = AppDB.Player.objects.get(name=player_name)
|
||||
toDeleteEntry.delete()
|
||||
request.session.flush() # oder: del request.session["device_name"]
|
||||
return redirect(f"{base_url}?{query_string}")
|
||||
|
||||
if "btn_start" in request.POST:
|
||||
game_instance.round_open = True
|
||||
game_instance.save()
|
||||
|
||||
if "btn_stop" in request.POST:
|
||||
game_instance.round_open = False
|
||||
game_instance.save()
|
||||
|
||||
if "btn_clear" in request.POST:
|
||||
AppDB.answer.objects.filter(player__game=game_instance).delete()
|
||||
|
||||
if "btn_sendAnswer" in request.POST:
|
||||
sendAnswer = AppDB.answer()
|
||||
sendAnswer.answer = request.POST.get("input_answer")
|
||||
sendAnswer.player = player_instance
|
||||
sendAnswer.akey = random_alphabet(players_inGame.count(), AppDB.answer.objects.filter(player__game=game_instance.id).values_list('akey', flat=True))
|
||||
sendAnswer.save()
|
||||
openAnswer = False
|
||||
return redirect(f"{base_url}?{query_string}")
|
||||
|
||||
return render(request, "app/game.html", {
|
||||
"has_name": player_name,
|
||||
"game_key": game_key,
|
||||
'player_data': player_instance,
|
||||
"round_open": game_instance.round_open,
|
||||
"openAnswer": openAnswer,
|
||||
"answers": AppDB.answer.objects.filter(player__game=game_instance.id).order_by("akey"),
|
||||
'countPlayers':players_inGame.count(),
|
||||
})
|
||||
Binary file not shown.
@ -0,0 +1,22 @@
|
||||
#!/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', 'NIP_APP.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()
|
||||
Loading…
Reference in new issue