Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ANDREW committed Jun 4, 2017
1 parent ddf35a6 commit 3c9c89d
Show file tree
Hide file tree
Showing 21 changed files with 480 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file removed Task05/blagun_gordun_chuprin_stepanenko.rar
Binary file not shown.
Empty file.
123 changes: 123 additions & 0 deletions Task05/blagun_gordun_chuprin_stepanenko/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
"""
Django settings for blagun_gordun_chuprin_stepanenko project.
Generated by 'django-admin startproject' using Django 1.11.1.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/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/1.11/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '9e_v#^x_eh(@f&7w8@9u_5sl#rar(+km#7$s_cm1j1yqp5(d8j'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

SOME_VAR = 'Blagun'

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
'didnotguess.apps.DidnotguessConfig',
'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 = 'blagun_gordun_chuprin_stepanenko.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 = 'blagun_gordun_chuprin_stepanenko.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.11/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/1.11/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/1.11/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/1.11/howto/static-files/

STATIC_URL = '/static/'
22 changes: 22 additions & 0 deletions Task05/blagun_gordun_chuprin_stepanenko/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""blagun_gordun_chuprin_stepanenko URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url, include
from django.contrib import admin

urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^didnotguess/', include('didnotguess.urls')),
]
16 changes: 16 additions & 0 deletions Task05/blagun_gordun_chuprin_stepanenko/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for blagun_gordun_chuprin_stepanenko 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/1.11/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "blagun_gordun_chuprin_stepanenko.settings")

application = get_wsgi_application()
Binary file added Task05/db.sqlite3
Binary file not shown.
Empty file added Task05/didnotguess/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions Task05/didnotguess/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
5 changes: 5 additions & 0 deletions Task05/didnotguess/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class DidnotguessConfig(AppConfig):
name = 'didnotguess'
35 changes: 35 additions & 0 deletions Task05/didnotguess/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.1 on 2017-06-03 21:02
from __future__ import unicode_literals

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


class Migration(migrations.Migration):

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='RequestType',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('typename', models.CharField(max_length=100)),
],
),
migrations.CreateModel(
name='UserRequest',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('request_date', models.DateTimeField(verbose_name='request date')),
('type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='didnotguess.RequestType')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]
Empty file.
11 changes: 11 additions & 0 deletions Task05/didnotguess/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django.db import models
from django.contrib.auth.models import User

# Create your models here.
class RequestType(models.Model):
typename = models.CharField(max_length=100)

class UserRequest(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
type = models.ForeignKey(RequestType, on_delete=models.CASCADE)
request_date = models.DateTimeField('request date')
43 changes: 43 additions & 0 deletions Task05/didnotguess/templates/didnotguess/app.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<a href="{% url 'didnotguess:index' %}">Back</a> <br />
{% if type == 'gen_random_number' %}
<p>{{ result }}</p>
<a href="{% url 'didnotguess:execution' %}">Generate number</a>
{% else %}
{% if type == 'gen_random_number_list' %}
{% if result %}
<ul>
{% for num in result %}
<li>{{ num }}</li>
{% endfor %}
</ul>
{% endif %}
<form action="{% url 'didnotguess:execution' %}" method="post">
{% csrf_token %}
<p>Range</p>
<input type="number" name="from" id="from" />
<label for="from">From</label><br />
<input type="number" name="to" id="to" />
<label for="to">To</label><br />
<input type="submit" value="Generate number list in range" /><br />
</form>
{% else %}
{% if type == 'get_random_word_from_text' %}
<form action="{% url 'didnotguess:execution' %}" method="post">
{% csrf_token %}
<label for="text">Text</label>
<input type="text" name="text" id="text" /><br />
<input type="submit" value="Get random word" /><br />
</form>
{% if result %}
<p>{{ result }}</p>
{% endif %}
{% else %}
{% if type == 'gen_random_password' %}
{% if result %}
<p>{{ result }}</p>
{% endif %}
<a href="{% url 'didnotguess:execution' %}">Generate password</a>
{% endif %}
{% endif %}
{% endif %}
{% endif %}
9 changes: 9 additions & 0 deletions Task05/didnotguess/templates/didnotguess/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<h1>Hello, {{ user.username }}!</h1>

<a href="{% url 'didnotguess:gen_random_number' %}">Generate random number</a><br />
<a href="{% url 'didnotguess:gen_random_number_list' %}">Generate random number list</a><br />
<a href="{% url 'didnotguess:get_random_word_from_text' %}">Get random word from text</a><br />
<a href="{% url 'didnotguess:gen_random_password' %}">Generate random password</a><br />
<a href="{% url 'didnotguess:gen_random_password_list' %}">Generate random password list</a><br />

<a href="{% url 'didnotguess:logout' %}">Log out</a>
11 changes: 11 additions & 0 deletions Task05/didnotguess/templates/didnotguess/login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{ message }}
<form action="{% url 'didnotguess:loginuser' %}" method="post">
{% csrf_token %}
<input type="text" name="username" id="name" />
<label for="name">Username</label><br />
<input type="password" name="userpassword" id="password" />
<label for="password">Password</label><br />
<input type="submit" value="Log in" /><br />
</form>

<a href="{% url 'didnotguess:registration' %}">Registration</a>
13 changes: 13 additions & 0 deletions Task05/didnotguess/templates/didnotguess/registration.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<form action="{% url 'didnotguess:registrationuser' %}" method="post">
{% csrf_token %}
<input type="text" name="username" id="name" />
<label for="name">Username</label><br />
<input type="password" name="userpassword" id="password" />
<label for="password">Password</label><br />
<input type="password" name="confirmpassword" id="confirmpassword" />
<label for="confirmpassword">Confirm password</label>
<input type="submit" value="Register!" /><br />
</form>
{% if error %}
<p>{{ error }}</p>
{% endif %}
3 changes: 3 additions & 0 deletions Task05/didnotguess/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
19 changes: 19 additions & 0 deletions Task05/didnotguess/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from django.conf.urls import url
from . import views

app_name = 'didnotguess'

urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^login/$', views.login, name='login'),
url(r'^loginuser/$', views.loginuser, name='loginuser'),
url(r'^registration/$', views.registration, name='registration'),
url(r'^registrationuser/$', views.registrationuser, name='registrationuser'),
url(r'^logout/$', views.logout, name='logout'),
url(r'^random_number/$', views.gen_random_number, name='gen_random_number'),
url(r'^random_number_list/$', views.gen_random_number_list, name='gen_random_number_list'),
url(r'^random_word_from_text/$', views.get_random_word_from_text, name='get_random_word_from_text'),
url(r'^random_password/$', views.gen_random_password, name="gen_random_password"),
url(r'^random_password_list/$', views.gen_random_password_list, name="gen_random_password_list"),
url(r'^execution/$', views.execution, name="execution"),
]
Loading

0 comments on commit 3c9c89d

Please sign in to comment.