From f9cfa6efa4b3fabe0ff78ffc83a26ce3852f717e Mon Sep 17 00:00:00 2001 From: hEAh4rd <33156156+hEAh4rd@users.noreply.github.com> Date: Wed, 10 Apr 2019 01:59:27 +0300 Subject: [PATCH] Test v1 v1 --- clicker/settings.py | 122 ++++++++++++++++++++++++++ clicker/urls.py | 24 +++++ clicker/wsgi.py | 16 ++++ game/admin.py | 4 + game/apps.py | 5 ++ game/migrations/0001_initial.py | 22 +++++ game/models.py | 17 ++++ game/static/style.css | 3 + game/templates/game/hello.html | 20 +++++ game/templates/game/log.html | 28 ++++++ game/templates/game/your_options.html | 16 ++++ game/tests.py | 3 + game/urls.py | 16 ++++ game/views.py | 45 ++++++++++ manage.py | 15 ++++ 15 files changed, 356 insertions(+) create mode 100644 clicker/settings.py create mode 100644 clicker/urls.py create mode 100644 clicker/wsgi.py create mode 100644 game/admin.py create mode 100644 game/apps.py create mode 100644 game/migrations/0001_initial.py create mode 100644 game/models.py create mode 100644 game/static/style.css create mode 100644 game/templates/game/hello.html create mode 100644 game/templates/game/log.html create mode 100644 game/templates/game/your_options.html create mode 100644 game/tests.py create mode 100644 game/urls.py create mode 100644 game/views.py create mode 100644 manage.py diff --git a/clicker/settings.py b/clicker/settings.py new file mode 100644 index 0000000..8487a05 --- /dev/null +++ b/clicker/settings.py @@ -0,0 +1,122 @@ +""" +Django settings for clicker project. + +Generated by 'django-admin startproject' using Django 2.1.7. + +For more information on this file, see +https://docs.djangoproject.com/en/2.1/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/2.1/ref/settings/ +""" + +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__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'xw@6x_63cq@5s0*-+rtgu)7bdg#3x+bs2ybwe(jjl#aon5lsw*' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'game', + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +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 = 'clicker.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [os.path.join(BASE_DIR, 'templates')] + , + '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 = 'clicker.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/2.1/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/2.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/2.1/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/2.1/howto/static-files/ + +STATIC_URL = '/static/' diff --git a/clicker/urls.py b/clicker/urls.py new file mode 100644 index 0000000..1b048c0 --- /dev/null +++ b/clicker/urls.py @@ -0,0 +1,24 @@ +"""clicker URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/2.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 +from django.conf.urls import url, include + + +urlpatterns = [ + path('admin/', admin.site.urls), + url(r'^', include('game.urls')), +] diff --git a/clicker/wsgi.py b/clicker/wsgi.py new file mode 100644 index 0000000..03276d9 --- /dev/null +++ b/clicker/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for clicker 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/2.1/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'clicker.settings') + +application = get_wsgi_application() diff --git a/game/admin.py b/game/admin.py new file mode 100644 index 0000000..a14474d --- /dev/null +++ b/game/admin.py @@ -0,0 +1,4 @@ +from django.contrib import admin +from .models import Click + +admin.site.register(Click) diff --git a/game/apps.py b/game/apps.py new file mode 100644 index 0000000..f46c908 --- /dev/null +++ b/game/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class GameConfig(AppConfig): + name = 'game' diff --git a/game/migrations/0001_initial.py b/game/migrations/0001_initial.py new file mode 100644 index 0000000..be951b0 --- /dev/null +++ b/game/migrations/0001_initial.py @@ -0,0 +1,22 @@ +# Generated by Django 2.1.7 on 2019-04-03 20:10 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Click', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=50)), + ('click_count', models.IntegerField()), + ], + ), + ] diff --git a/game/models.py b/game/models.py new file mode 100644 index 0000000..a387316 --- /dev/null +++ b/game/models.py @@ -0,0 +1,17 @@ +from django.db import models +from django.contrib.auth.models import User + + +class Click(models.Model): + + #user_id = models.ForeignKey(User, on_delete=models.CASCADE) + users = models.ManyToManyField(User) + name = models.CharField(max_length=50) + click_count = models.IntegerField() + + def __str__(self): + return self.name + + class Meta: + ordering = ('name',) + diff --git a/game/static/style.css b/game/static/style.css new file mode 100644 index 0000000..ca36efa --- /dev/null +++ b/game/static/style.css @@ -0,0 +1,3 @@ +body { + background-color: coral; +} \ No newline at end of file diff --git a/game/templates/game/hello.html b/game/templates/game/hello.html new file mode 100644 index 0000000..8b8bf2e --- /dev/null +++ b/game/templates/game/hello.html @@ -0,0 +1,20 @@ + + +
+ + + + +