diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..72dc365 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +venv/ +__init__.py \ No newline at end of file diff --git a/NIP_APP/asgi.py b/NIP_APP/asgi.py new file mode 100644 index 0000000..69183e1 --- /dev/null +++ b/NIP_APP/asgi.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() diff --git a/NIP_APP/settings.py b/NIP_APP/settings.py new file mode 100644 index 0000000..b0bf5c2 --- /dev/null +++ b/NIP_APP/settings.py @@ -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' diff --git a/NIP_APP/urls.py b/NIP_APP/urls.py new file mode 100644 index 0000000..a18eaed --- /dev/null +++ b/NIP_APP/urls.py @@ -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 +] diff --git a/NIP_APP/wsgi.py b/NIP_APP/wsgi.py new file mode 100644 index 0000000..16326dd --- /dev/null +++ b/NIP_APP/wsgi.py @@ -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() diff --git a/app/admin.py b/app/admin.py new file mode 100644 index 0000000..6954e90 --- /dev/null +++ b/app/admin.py @@ -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) diff --git a/app/apps.py b/app/apps.py new file mode 100644 index 0000000..ed327d2 --- /dev/null +++ b/app/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class AppConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'app' diff --git a/app/migrations/0001_initial.py b/app/migrations/0001_initial.py new file mode 100644 index 0000000..d2f7a63 --- /dev/null +++ b/app/migrations/0001_initial.py @@ -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)), + ], + ), + ] diff --git a/app/migrations/0002_player.py b/app/migrations/0002_player.py new file mode 100644 index 0000000..14e3d21 --- /dev/null +++ b/app/migrations/0002_player.py @@ -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')), + ], + ), + ] diff --git a/app/migrations/0003_player_leader.py b/app/migrations/0003_player_leader.py new file mode 100644 index 0000000..a27da3b --- /dev/null +++ b/app/migrations/0003_player_leader.py @@ -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), + ), + ] diff --git a/app/migrations/0004_answer.py b/app/migrations/0004_answer.py new file mode 100644 index 0000000..df6ad75 --- /dev/null +++ b/app/migrations/0004_answer.py @@ -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')), + ], + ), + ] diff --git a/app/migrations/0005_games_round_open.py b/app/migrations/0005_games_round_open.py new file mode 100644 index 0000000..9d9be4e --- /dev/null +++ b/app/migrations/0005_games_round_open.py @@ -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), + ), + ] diff --git a/app/migrations/0006_answer_akey.py b/app/migrations/0006_answer_akey.py new file mode 100644 index 0000000..0e8264b --- /dev/null +++ b/app/migrations/0006_answer_akey.py @@ -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), + ), + ] diff --git a/app/migrations/0007_alter_answer_answer.py b/app/migrations/0007_alter_answer_answer.py new file mode 100644 index 0000000..41c19bd --- /dev/null +++ b/app/migrations/0007_alter_answer_answer.py @@ -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), + ), + ] diff --git a/app/models.py b/app/models.py new file mode 100644 index 0000000..04f44a9 --- /dev/null +++ b/app/models.py @@ -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}" \ No newline at end of file diff --git a/app/static/nip-app.png b/app/static/nip-app.png new file mode 100644 index 0000000..87a5ba7 Binary files /dev/null and b/app/static/nip-app.png differ diff --git a/app/templates/app/game.html b/app/templates/app/game.html new file mode 100644 index 0000000..4cce6fc --- /dev/null +++ b/app/templates/app/game.html @@ -0,0 +1,114 @@ +{% load static %} + + +
+ +
+
+ {% if has_name %}
+
+ Spieler erkannt.
{{ player_data.name }}{% if player_data.leader %} - {{ countPlayers }} gesamt{% endif %}
Bitte Namen eingeben:
+ + {% endif %} + + + {% if player_data.leader %} + + + +| # | +Spieler | +Antwort | +
|---|---|---|
| {{ answer.akey }} | +{{ answer.player.name }} | +{{ answer.answer }} | +
+
+
+
+ | Spiel-ID | +Key | +Status | +Action | +
|---|---|---|---|
| {{ game.id }} | +{{ game.key }} | +{{ game.state }} | +öffnen | +