diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..40bcfbc --- /dev/null +++ b/.gitignore @@ -0,0 +1,148 @@ +#led / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class +secrets.py +static_files +.idea/ +.vscode/ + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# bruh windows +*:Zone.Identifier + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +#VSCODE +.vscode/* diff --git a/config/__init__.py b/config/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/config/asgi.py b/config/asgi.py new file mode 100644 index 0000000..8a9fda7 --- /dev/null +++ b/config/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for config 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/3.1/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings') + +application = get_asgi_application() diff --git a/config/settings.py b/config/settings.py new file mode 100644 index 0000000..395780d --- /dev/null +++ b/config/settings.py @@ -0,0 +1,135 @@ +""" +Django settings for config project. + +Generated by 'django-admin startproject' using Django 3.1.2. + +For more information on this file, see +https://docs.djangoproject.com/en/3.1/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/3.1/ref/settings/ +""" + +from pathlib import Path +from my_secrets.secrets import * + +# 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/3.1/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! + +# SECURITY WARNING: don't run with debug turned on in production! + +if DEBUG: + ALLOWED_HOSTS = ["*"] +else: + ALLOWED_HOSTS = ["HOST"] + + +# Application definition + +INSTALLED_APPS = [ + 'drive', + + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + + 'django_extensions', + 'django_secrets', + 'crispy_forms' +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'whitenoise.middleware.WhiteNoiseMiddleware', + '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 = 'config.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 = 'config.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/3.1/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/3.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/3.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/3.1/howto/static-files/ + +STATIC_URL = '/static/' + +import os +STATIC_ROOT = os.path.join(BASE_DIR, 'static') + +CRISPY_TEMPLATE_PACK = 'bootstrap4' +CRISPY_FAIL_SILENTLY = not DEBUG \ No newline at end of file diff --git a/config/urls.py b/config/urls.py new file mode 100644 index 0000000..9e981cd --- /dev/null +++ b/config/urls.py @@ -0,0 +1,22 @@ +"""config URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/3.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, include + +urlpatterns = [ + path('admin/', admin.site.urls), + path('', include('drive.urls')) +] diff --git a/config/wsgi.py b/config/wsgi.py new file mode 100644 index 0000000..94fcaf1 --- /dev/null +++ b/config/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for config 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/3.1/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings') + +application = get_wsgi_application() diff --git a/drive/__init__.py b/drive/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/drive/admin.py b/drive/admin.py new file mode 100644 index 0000000..2bab9d4 --- /dev/null +++ b/drive/admin.py @@ -0,0 +1,6 @@ +from django.contrib import admin + +from .models import Response + +# Register your models here. +admin.site.register(Response) \ No newline at end of file diff --git a/drive/apps.py b/drive/apps.py new file mode 100644 index 0000000..d41078d --- /dev/null +++ b/drive/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class DriveConfig(AppConfig): + name = 'drive' diff --git a/drive/choices.py b/drive/choices.py new file mode 100644 index 0000000..dc914d6 --- /dev/null +++ b/drive/choices.py @@ -0,0 +1,186 @@ +CHOICES = ( + ('n/a', "N/A"), + ('progress', "In Progress"), + ('complete', "Complete") +) + +DECISION_QUESTIONS = [ + "Who is/are the decision maker(s)?", + "Who is the end user?", + "Who is/are the influencer(s)?", + "Who signs the contract?", + "What is the decision-making process?", + "Does the solution have to go through committee (board) approval?", + "If so, who is on the committee (board)?", + "What is important to them?", +] + +DECISION_WEIGHT = [ + 3, + 2, + 2, + 2, + 3, + 2, + 1, + 1, +] + +DECISION_IT_QUESTIONS = [ + "Who is/are the contact(s)?", + "How long is the IT review process on the customers end?", + "What is the backlog?", + "Did we send them over our IT requirements?", + "Have they reviewed our IT requirements?", + "What questions do they have?", + "Is there are call needed to go over IT requirements?", + "When is that call?", + "Who wll be involved in that call on our end/their end?", + "What customer IT requirements (if any) can we not meet or may be a sticking point? ", + "Why is this a concern?", +] + +DECISION_IT_WEIGHT = [ + 2, + 2, + 1, + 2, + 2, + 1, + 1, + 1, + 1, + 2, + 2, +] + +DECISION_LEGAL_QUESTIONS = [ + "Who is/are the contact(s)?", + "How long is the review process on customers end?", + "What is the backlog?", + "Did we send them our contract?", + "Have they reviewed our contract?", + "Did they amend our contract?", + "Who is responsible for reviewing the amendments on our end?", + "When will have our response to their changes done?", + "Is there are call needed to go over legal/the contract?", + "When is that call?", + "Who will be involved in that call from our end/their end?", + "Do they have their own version of the contract or an MSA?", + "What other paperwork is required from their end that we need to fill out?", + "If so, what is the paperwork?", + "Who on our end is responsible for filling out?", + "When do we need to get this paperwork back to them?", + "What specific clauses may be of concern in moving forward with the contract?", + "Why is this a concern?", +] + +DECISION_LEGAL_WEIGHT = [ + 2, + 2, + 1, + 2, + 2, + 2, + 1, + 1, + 1, + 1, + 1, + 2, + 1, + 1, + 1, + 1, + 2, + 2, +] + +RESOURCES_QUESTIONS = [ + + "What is their budget?", + "Who is reponsible for the budget? ", + "Who decides on the budget?", + "What department(s) will fund the initiative?", + "What other initiatives are competing for that budget?", + "When will the budget be determined? ", + "When will the budget be approved?", + "When will the funds be available?", + "Who will implement the solution on the customer side?", + "Do they have the human capital bandwidth to implement the solution?", + "How are they planning on implementing/rolling out the solution? ", + "Is it a phased approach or all at once?", + "What other initiatives could affect implementation of our solution?", + +] + +RESOURCES_WEIGHT = [ + 3, + 2, + 2, + 1, + 2, + 1, + 1, + 1, + 2, + 3, + 3, + 1, + 2, +] + +IMPACT_QUESTIONS = [ + "Why are they doing this?", + "How are they addressing this issue now?", + "What other solutions are they looking at?", + "How much time are they spending on dealing with issue?", + "What else could they be doing (money, time, etc.) if issue were resolved?", + "What is ideal end state? ", + "What does their version of \"good\" look like?", + "What happens they don't resolve this issue?", +] + +IMPACT_WEIGHT = [ + + 3, + 2, + 2, + 2, + 2, + 2, + 2, + 3, +] + +VELOCITY_QUESTIONS = [ + "What is their timeline?", + "What date do they need the solution implemented?", + "What date does the customer need to see results?", + "What is the driver for that date/Why did they choose that date? ", +] + +VELOCITY_WEIGHT = [ + 3, + 2, + 2, + 3, +] + +EXPECTATIONS_QUESTIONS = [ + "What is the personal \"why\" for your specific prospect for resolving the issue?", + "What is their personal motivation?", + "What roadblocks (physical or emotional) exist that may affect the prospect moving forward? ", + "Who's situation would the solution be affecting if implemented (positive)?", + "Who's situation would the solution be affecting if implemented (negative)?", + "What upcoming event(s) may affect the decision making process? (DM out of office, conferences, board meeting, etc) ", +] + +EXPECTATIONS_WEIGHT = [ + 3, + 2, + 3, + 1, + 2, + 1, +] diff --git a/drive/forms.py b/drive/forms.py new file mode 100644 index 0000000..8d4f881 --- /dev/null +++ b/drive/forms.py @@ -0,0 +1,142 @@ +from django import forms +from crispy_forms.helper import FormHelper +from crispy_forms.layout import Layout, Submit, Div, MultiField, Fieldset, ButtonHolder + +from .choices import * + +class PollForm(forms.Form): + + # User Data + first_name = forms.CharField(label="First name:", max_length=30) + last_name = forms.CharField(label="Last name:", max_length=30) + email = forms.EmailField(max_length=254) + + # Decision Making + d0 = forms.ChoiceField(label=DECISION_QUESTIONS[0], choices = CHOICES, required = False) + d1 = forms.ChoiceField(label=DECISION_QUESTIONS[1], choices = CHOICES, required = False) + d2 = forms.ChoiceField(label=DECISION_QUESTIONS[2], choices = CHOICES, required = False) + d3 = forms.ChoiceField(label=DECISION_QUESTIONS[3], choices = CHOICES, required = False) + d4 = forms.ChoiceField(label=DECISION_QUESTIONS[4], choices = CHOICES, required = False) + d5 = forms.ChoiceField(label=DECISION_QUESTIONS[5], choices = CHOICES, required = False) + d6 = forms.ChoiceField(label=DECISION_QUESTIONS[6], choices = CHOICES, required = False) + d7 = forms.ChoiceField(label=DECISION_QUESTIONS[7], choices = CHOICES, required = False) + + # Decision Making IT + dit0 = forms.ChoiceField(label=DECISION_IT_QUESTIONS[0], choices = CHOICES, required = False) + dit1 = forms.ChoiceField(label=DECISION_IT_QUESTIONS[1], choices = CHOICES, required = False) + dit2 = forms.ChoiceField(label=DECISION_IT_QUESTIONS[2], choices = CHOICES, required = False) + dit3 = forms.ChoiceField(label=DECISION_IT_QUESTIONS[3], choices = CHOICES, required = False) + dit4 = forms.ChoiceField(label=DECISION_IT_QUESTIONS[4], choices = CHOICES, required = False) + dit5 = forms.ChoiceField(label=DECISION_IT_QUESTIONS[5], choices = CHOICES, required = False) + dit6 = forms.ChoiceField(label=DECISION_IT_QUESTIONS[6], choices = CHOICES, required = False) + dit7 = forms.ChoiceField(label=DECISION_IT_QUESTIONS[7], choices = CHOICES, required = False) + dit8 = forms.ChoiceField(label=DECISION_IT_QUESTIONS[8], choices = CHOICES, required = False) + dit9 = forms.ChoiceField(label=DECISION_IT_QUESTIONS[9], choices = CHOICES, required = False) + dit10 = forms.ChoiceField(label=DECISION_IT_QUESTIONS[10], choices = CHOICES, required = False) + + # Decision Making Legal + dl0 = forms.ChoiceField(label=DECISION_LEGAL_QUESTIONS[0], choices = CHOICES, required = False) + dl1 = forms.ChoiceField(label=DECISION_LEGAL_QUESTIONS[1], choices = CHOICES, required = False) + dl2 = forms.ChoiceField(label=DECISION_LEGAL_QUESTIONS[2], choices = CHOICES, required = False) + dl3 = forms.ChoiceField(label=DECISION_LEGAL_QUESTIONS[3], choices = CHOICES, required = False) + dl4 = forms.ChoiceField(label=DECISION_LEGAL_QUESTIONS[4], choices = CHOICES, required = False) + dl5 = forms.ChoiceField(label=DECISION_LEGAL_QUESTIONS[5], choices = CHOICES, required = False) + dl6 = forms.ChoiceField(label=DECISION_LEGAL_QUESTIONS[6], choices = CHOICES, required = False) + dl7 = forms.ChoiceField(label=DECISION_LEGAL_QUESTIONS[7], choices = CHOICES, required = False) + dl8 = forms.ChoiceField(label=DECISION_LEGAL_QUESTIONS[8], choices = CHOICES, required = False) + dl9 = forms.ChoiceField(label=DECISION_LEGAL_QUESTIONS[9], choices = CHOICES, required = False) + dl10 = forms.ChoiceField(label=DECISION_LEGAL_QUESTIONS[10], choices = CHOICES, required = False) + dl11 = forms.ChoiceField(label=DECISION_LEGAL_QUESTIONS[11], choices = CHOICES, required = False) + dl12 = forms.ChoiceField(label=DECISION_LEGAL_QUESTIONS[12], choices = CHOICES, required = False) + dl13 = forms.ChoiceField(label=DECISION_LEGAL_QUESTIONS[13], choices = CHOICES, required = False) + dl14 = forms.ChoiceField(label=DECISION_LEGAL_QUESTIONS[14], choices = CHOICES, required = False) + dl15 = forms.ChoiceField(label=DECISION_LEGAL_QUESTIONS[15], choices = CHOICES, required = False) + dl16 = forms.ChoiceField(label=DECISION_LEGAL_QUESTIONS[16], choices = CHOICES, required = False) + dl17 = forms.ChoiceField(label=DECISION_LEGAL_QUESTIONS[17], choices = CHOICES, required = False) + + # Resources + r0 = forms.ChoiceField(label=RESOURCES_QUESTIONS[0], choices = CHOICES, required = False) + r1 = forms.ChoiceField(label=RESOURCES_QUESTIONS[1], choices = CHOICES, required = False) + r2 = forms.ChoiceField(label=RESOURCES_QUESTIONS[2], choices = CHOICES, required = False) + r3 = forms.ChoiceField(label=RESOURCES_QUESTIONS[3], choices = CHOICES, required = False) + r4 = forms.ChoiceField(label=RESOURCES_QUESTIONS[4], choices = CHOICES, required = False) + r5 = forms.ChoiceField(label=RESOURCES_QUESTIONS[5], choices = CHOICES, required = False) + r6 = forms.ChoiceField(label=RESOURCES_QUESTIONS[6], choices = CHOICES, required = False) + r7 = forms.ChoiceField(label=RESOURCES_QUESTIONS[7], choices = CHOICES, required = False) + r8 = forms.ChoiceField(label=RESOURCES_QUESTIONS[8], choices = CHOICES, required = False) + r9 = forms.ChoiceField(label=RESOURCES_QUESTIONS[9], choices = CHOICES, required = False) + r10 = forms.ChoiceField(label=RESOURCES_QUESTIONS[10], choices = CHOICES, required = False) + r11 = forms.ChoiceField(label=RESOURCES_QUESTIONS[11], choices = CHOICES, required = False) + r12 = forms.ChoiceField(label=RESOURCES_QUESTIONS[12], choices = CHOICES, required = False) + + # Impact + i0 = forms.ChoiceField(label=IMPACT_QUESTIONS[0], choices = CHOICES, required = False) + i1 = forms.ChoiceField(label=IMPACT_QUESTIONS[1], choices = CHOICES, required = False) + i2 = forms.ChoiceField(label=IMPACT_QUESTIONS[2], choices = CHOICES, required = False) + i3 = forms.ChoiceField(label=IMPACT_QUESTIONS[3], choices = CHOICES, required = False) + i4 = forms.ChoiceField(label=IMPACT_QUESTIONS[4], choices = CHOICES, required = False) + i5 = forms.ChoiceField(label=IMPACT_QUESTIONS[5], choices = CHOICES, required = False) + i6 = forms.ChoiceField(label=IMPACT_QUESTIONS[6], choices = CHOICES, required = False) + i7 = forms.ChoiceField(label=IMPACT_QUESTIONS[7], choices = CHOICES, required = False) + + # Velocity + v0 = forms.ChoiceField(label=VELOCITY_QUESTIONS[0], choices = CHOICES, required = False) + v1 = forms.ChoiceField(label=VELOCITY_QUESTIONS[1], choices = CHOICES, required = False) + v2 = forms.ChoiceField(label=VELOCITY_QUESTIONS[2], choices = CHOICES, required = False) + v3 = forms.ChoiceField(label=VELOCITY_QUESTIONS[3], choices = CHOICES, required = False) + + # Expectations + e0 = forms.ChoiceField(label=EXPECTATIONS_QUESTIONS[0], choices = CHOICES, required = False) + e1 = forms.ChoiceField(label=EXPECTATIONS_QUESTIONS[1], choices = CHOICES, required = False) + e2 = forms.ChoiceField(label=EXPECTATIONS_QUESTIONS[2], choices = CHOICES, required = False) + e3 = forms.ChoiceField(label=EXPECTATIONS_QUESTIONS[3], choices = CHOICES, required = False) + e4 = forms.ChoiceField(label=EXPECTATIONS_QUESTIONS[4], choices = CHOICES, required = False) + e5 = forms.ChoiceField(label=EXPECTATIONS_QUESTIONS[5], choices = CHOICES, required = False) + + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.form_method = 'post' + self.helper.form_class = 'form-horizontal' + self.helper.label_class = 'col-md' + self.helper.field_class = 'col-md' + self.helper.layout = Layout( + Fieldset( + 'Some quick info', + 'first_name', + 'last_name', + 'email' + ), + Fieldset( + 'Decisions', + *[f'd{i}' for i in range(len(DECISION_QUESTIONS))] + ), + Fieldset( + 'Decisions (IT)', + *[f'dit{i}' for i in range(len(DECISION_IT_QUESTIONS))] + ), + Fieldset( + 'Decisions (Legal/Procurement)', + *[f'dl{i}' for i in range(len(DECISION_LEGAL_QUESTIONS))] + ), + Fieldset( + 'Resources', + *[f'r{i}' for i in range(len(RESOURCES_QUESTIONS))] + ), + Fieldset( + 'Impact', + *[f'i{i}' for i in range(len(IMPACT_QUESTIONS))] + ), + Fieldset( + 'Velocity', + *[f'v{i}' for i in range(len(VELOCITY_QUESTIONS))] + ), + Fieldset( + 'Expectations', + *[f'e{i}' for i in range(len(EXPECTATIONS_QUESTIONS))] + ), + ButtonHolder( + Submit('submit', 'Submit', css_class='btn-lg btn-block') + ) + ) \ No newline at end of file diff --git a/drive/migrations/0001_initial.py b/drive/migrations/0001_initial.py new file mode 100644 index 0000000..a7fd744 --- /dev/null +++ b/drive/migrations/0001_initial.py @@ -0,0 +1,34 @@ +# Generated by Django 3.1.2 on 2020-10-23 01:04 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Response', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('first_name', models.CharField(max_length=50)), + ('last_name', models.CharField(max_length=50)), + ('email', models.EmailField(max_length=254)), + ('expectations', models.PositiveIntegerField()), + ('velocity', models.PositiveIntegerField()), + ('impact', models.PositiveIntegerField()), + ('resources', models.PositiveIntegerField()), + ('decision', models.PositiveIntegerField()), + ('decision_it', models.PositiveIntegerField()), + ('decision_legal', models.PositiveIntegerField()), + ], + options={ + 'verbose_name': 'Response', + 'verbose_name_plural': 'Responses', + }, + ), + ] diff --git a/drive/migrations/__init__.py b/drive/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/drive/models.py b/drive/models.py new file mode 100644 index 0000000..cd8ab64 --- /dev/null +++ b/drive/models.py @@ -0,0 +1,28 @@ +from django.db import models + +# Create your models here. +class Response(models.Model): + # user data + first_name = models.CharField(max_length=50) + last_name = models.CharField(max_length=50) + email = models.EmailField(max_length=254) + + # scores + expectations = models.PositiveIntegerField() + velocity = models.PositiveIntegerField() + impact = models.PositiveIntegerField() + resources = models.PositiveIntegerField() + decision = models.PositiveIntegerField() + decision_it = models.PositiveIntegerField() + decision_legal = models.PositiveIntegerField() + + + class Meta: + verbose_name = "Response" + verbose_name_plural = "Responses" + + def __str__(self): + return f'{self.first_name} {self.last_name}\'s Response' + + def get_absolute_url(self): + return reverse("Response_detail", kwargs={"pk": self.pk}) diff --git a/drive/static/css/styles.css b/drive/static/css/styles.css new file mode 100644 index 0000000..80438ab --- /dev/null +++ b/drive/static/css/styles.css @@ -0,0 +1,3 @@ +.asteriskField { + display: none; +} \ No newline at end of file diff --git a/drive/templates/drive/base.html b/drive/templates/drive/base.html new file mode 100644 index 0000000..9ea060b --- /dev/null +++ b/drive/templates/drive/base.html @@ -0,0 +1,32 @@ +{% load static %} + + + + + + + + + + DRIVE Pipeline + + + + + + + + + + + {% block content %}{% endblock content %} + + + + + + + + diff --git a/drive/templates/drive/index.html b/drive/templates/drive/index.html new file mode 100644 index 0000000..549c968 --- /dev/null +++ b/drive/templates/drive/index.html @@ -0,0 +1,10 @@ +{% extends 'drive/base.html' %} +{% load crispy_forms_tags %} +{% block content %} +
+
+ {% csrf_token %} + {% crispy form %} +
+
+{% endblock content %} diff --git a/drive/templates/drive/results.html b/drive/templates/drive/results.html new file mode 100644 index 0000000..35cbf07 --- /dev/null +++ b/drive/templates/drive/results.html @@ -0,0 +1,4 @@ +{% extends 'drive/base.html' %} +{% block content %} +

here's your results

+{% endblock content %} \ No newline at end of file diff --git a/drive/tests.py b/drive/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/drive/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/drive/urls.py b/drive/urls.py new file mode 100644 index 0000000..ecca7c3 --- /dev/null +++ b/drive/urls.py @@ -0,0 +1,7 @@ +from django.urls import path +from . import views + +urlpatterns = [ + path('', views.index, name='index'), + path('results/', views.results, name='results') +] diff --git a/drive/views.py b/drive/views.py new file mode 100644 index 0000000..ce1bb9a --- /dev/null +++ b/drive/views.py @@ -0,0 +1,61 @@ +from django.shortcuts import render, redirect, get_object_or_404 + +from .forms import PollForm +from .models import Response +from .choices import * + +# Create your views here. +def index(request): + form = PollForm() + if request.method=='POST': + form = PollForm(request.POST) + print(request.POST) + print("hi!") + if form.is_valid(): + data = form.cleaned_data + + decision_score = round(sum([DECISION_WEIGHT[i] for i in range(len(DECISION_QUESTIONS)) if data[f'd{i}'] == 'n/a' or data[f'd{i}'] == 'complete'])/sum(DECISION_WEIGHT)*100) + it_score = round(sum([DECISION_IT_WEIGHT[i] for i in range(len(DECISION_IT_QUESTIONS)) if data[f'dit{i}'] == 'n/a' or data[f'dit{i}'] == 'complete'])/sum(DECISION_IT_WEIGHT)*100) + legal_score = round(sum([DECISION_LEGAL_WEIGHT[i] for i in range(len(DECISION_LEGAL_QUESTIONS)) if data[f'dl{i}'] == 'n/a' or data[f'dl{i}'] == 'complete'])/sum(DECISION_LEGAL_WEIGHT)*100) + resources_score = round(sum([RESOURCES_WEIGHT[i] for i in range(len(RESOURCES_QUESTIONS)) if data[f'r{i}'] == 'n/a' or data[f'r{i}'] == 'complete'])/sum(RESOURCES_WEIGHT)*100) + impact_score = round(sum([IMPACT_WEIGHT[i] for i in range(len(IMPACT_QUESTIONS)) if data[f'i{i}'] == 'n/a' or data[f'i{i}'] == 'complete'])/sum(IMPACT_WEIGHT)*100) + velocity_score = round(sum([VELOCITY_WEIGHT[i] for i in range(len(VELOCITY_QUESTIONS)) if data[f'v{i}'] == 'n/a' or data[f'v{i}'] == 'complete'])/sum(VELOCITY_WEIGHT)*100) + expectations_score = round(sum([EXPECTATIONS_WEIGHT[i] for i in range(len(EXPECTATIONS_QUESTIONS)) if data[f'e{i}'] == 'n/a' or data[f'e{i}'] == 'complete'])/sum(EXPECTATIONS_WEIGHT)*100) + + response = Response( + first_name=data['first_name'], + last_name=data['last_name'], + email=data['email'], + expectations=expectations_score, + velocity=velocity_score, + impact=impact_score, + resources=resources_score, + decision=decision_score, + decision_it=it_score, + decision_legal=legal_score + ) + + response.save() + + request.session['_response'] = response.id + return redirect('results') + + context = { + 'form': form + } + + return render(request, 'drive/index.html', context=context) + +def results (request): + responseID = request.session.get('_response') + print(responseID) + if responseID: + return redirect('/') + + response = get_object_or_404(Response, id=responseID) + print(response) + + context = { + 'response': response + } + return render(request, 'drive/results.html', context=context) \ No newline at end of file diff --git a/manage.py b/manage.py new file mode 100755 index 0000000..31e03d9 --- /dev/null +++ b/manage.py @@ -0,0 +1,24 @@ +#!/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', 'config.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__': + from django_secrets.startup import check + check() + main() diff --git a/my_secrets/.gitignore b/my_secrets/.gitignore new file mode 100644 index 0000000..ef418f5 --- /dev/null +++ b/my_secrets/.gitignore @@ -0,0 +1 @@ +secrets.py diff --git a/my_secrets/__init__.py b/my_secrets/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/my_secrets/definitions.py b/my_secrets/definitions.py new file mode 100644 index 0000000..24ced76 --- /dev/null +++ b/my_secrets/definitions.py @@ -0,0 +1,12 @@ +# coding=utf-8 + +# Add your secrets to this list and run manage.py to set their values. +# Use them in settings.py like this: +# from secrets import secrets +# SECRET_KEY = secrets.SECRET_KEY + +SECRET_KEYS = [ + # start with your Django secret key like this: + "SECRET_KEY", + "DEBUG", +] diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..ddb6ea1 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,10 @@ +asgiref==3.2.10 +Django==3.1.2 +django-extensions==3.0.9 +django-secrets==1.0.2 +future==0.18.2 +gunicorn==20.0.4 +pytz==2020.1 +six==1.15.0 +sqlparse==0.4.1 +whitenoise==5.2.0