From 84ec7a12f7ca408ff9937784b5ee309a5a765855 Mon Sep 17 00:00:00 2001
From: Sera Smith
Date: Thu, 2 Feb 2017 16:22:24 -0800
Subject: [PATCH 001/249] Update README.md
---
README.md | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/README.md b/README.md
index e2699bd..08e9ed0 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,29 @@
# NeuroPy
Personalized CBT-based priority planner
+
+Creators:
+
+Amos Bolder Claire Gatenby Patrick Saunders Sera Smith
+URL:
+
+http://
+
+A personalized priority app to support a *Cognitive Behavioral Therapy* (CBT) approach to efficiently organize your day according to a struggle/disorder that is effectively treated by CBT. CBT is a goal-oriented pyschotherapy treatment, taking a hands-on approach to problem solving. Goal of CBT is to change the patterns of thinking or behavior that are behind a person's difficulties, modifying their feelings and therefore their thinking and behavior overtime.
+
+*Neuropy* Considers what the habit/disorder the user wants to treat with CBT, along with medication, it's half-life and peak periods. Also works around black-out periods on user's schedule by syncing with Google Calender, personal preference or most productive period of the day for user, and finally considers time commitments for each activity. Each "TO-DO" will be ranked considering these aspects and will be worked into periods of the day.
+
+version-0.1 (in active development) Keywords: Python, Pyramid, Postgresql, Jinja2, JavaScript
+
+USER STORIES:
+
+As a USER I want to SEARCH so that I can FIND
+
+As a USER I want to POINT THE SEARCH so I can FIND BETTER
+
+As a USER I want to SEARCH CONTROLS so that I can POINT THE SEARCH
+
+As a USER I want to SEE HOW SEARCH WORKS so that I can POINT THE SEARCH BETTER
+
+As a DEVELOPER I want to INTEGRATE KEYWORD GATHERING, QUERY PARSING, AND KEYWORD URL DATA so that DEVELOPMENT IS ORDERLY
+
+As a DEVELOPER I want to use EXCELLENT NAMING CONVENTIONS so that DIRECTORY, FILE, DATABASE, AND FUNCTION PURPOSE ARE CLEAR
From 084fd0aeb859b75ba68683d97930f6a1f58e0605 Mon Sep 17 00:00:00 2001
From: Sera Smith
Date: Thu, 2 Feb 2017 16:22:47 -0800
Subject: [PATCH 002/249] Update README.md
---
README.md | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 08e9ed0..f55f8d7 100644
--- a/README.md
+++ b/README.md
@@ -4,9 +4,8 @@ Personalized CBT-based priority planner
Creators:
Amos Bolder Claire Gatenby Patrick Saunders Sera Smith
-URL:
-http://
+URL: http://
A personalized priority app to support a *Cognitive Behavioral Therapy* (CBT) approach to efficiently organize your day according to a struggle/disorder that is effectively treated by CBT. CBT is a goal-oriented pyschotherapy treatment, taking a hands-on approach to problem solving. Goal of CBT is to change the patterns of thinking or behavior that are behind a person's difficulties, modifying their feelings and therefore their thinking and behavior overtime.
From 8910398924db1c6d3322d8d98b6222166c70b523 Mon Sep 17 00:00:00 2001
From: Sera Smith
Date: Thu, 2 Feb 2017 16:24:24 -0800
Subject: [PATCH 003/249] Update
---
README.md | 11 -----------
1 file changed, 11 deletions(-)
diff --git a/README.md b/README.md
index f55f8d7..519b9f6 100644
--- a/README.md
+++ b/README.md
@@ -15,14 +15,3 @@ version-0.1 (in active development) Keywords: Python, Pyramid, Postgresql, Jinja
USER STORIES:
-As a USER I want to SEARCH so that I can FIND
-
-As a USER I want to POINT THE SEARCH so I can FIND BETTER
-
-As a USER I want to SEARCH CONTROLS so that I can POINT THE SEARCH
-
-As a USER I want to SEE HOW SEARCH WORKS so that I can POINT THE SEARCH BETTER
-
-As a DEVELOPER I want to INTEGRATE KEYWORD GATHERING, QUERY PARSING, AND KEYWORD URL DATA so that DEVELOPMENT IS ORDERLY
-
-As a DEVELOPER I want to use EXCELLENT NAMING CONVENTIONS so that DIRECTORY, FILE, DATABASE, AND FUNCTION PURPOSE ARE CLEAR
From 56a105584df7ca70de0785e607442561836838fc Mon Sep 17 00:00:00 2001
From: Sera Smith
Date: Thu, 2 Feb 2017 16:25:34 -0800
Subject: [PATCH 004/249] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 519b9f6..4ed033f 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@ A personalized priority app to support a *Cognitive Behavioral Therapy* (CBT) ap
*Neuropy* Considers what the habit/disorder the user wants to treat with CBT, along with medication, it's half-life and peak periods. Also works around black-out periods on user's schedule by syncing with Google Calender, personal preference or most productive period of the day for user, and finally considers time commitments for each activity. Each "TO-DO" will be ranked considering these aspects and will be worked into periods of the day.
-version-0.1 (in active development) Keywords: Python, Pyramid, Postgresql, Jinja2, JavaScript
+version-0.1 (in active development) Keywords:
USER STORIES:
From a991adbc855cca083eab6f30b941f365229494cd Mon Sep 17 00:00:00 2001
From: pasaunders
Date: Thu, 2 Feb 2017 16:27:13 -0800
Subject: [PATCH 005/249] medical data notice
---
README.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/README.md b/README.md
index 4ed033f..be62380 100644
--- a/README.md
+++ b/README.md
@@ -13,5 +13,7 @@ A personalized priority app to support a *Cognitive Behavioral Therapy* (CBT) ap
version-0.1 (in active development) Keywords:
+No medical data is stored by NeuroPy
+
USER STORIES:
From 67bb1d84d28c1c53c254b5cd5bd2956668a6c2b6 Mon Sep 17 00:00:00 2001
From: pasaunders
Date: Mon, 13 Feb 2017 10:50:45 -0800
Subject: [PATCH 006/249] django scaffold built
---
neuropy/manage.py | 22 ++++
neuropy/neuropy/__init__.py | 0
neuropy/neuropy/settings.py | 120 +++++++++++++++++++++
neuropy/neuropy/urls.py | 21 ++++
neuropy/neuropy/wsgi.py | 16 +++
neuropy/todo/__init__.py | 0
neuropy/todo/admin.py | 3 +
neuropy/todo/apps.py | 5 +
neuropy/todo/migrations/__init__.py | 0
neuropy/todo/models.py | 3 +
neuropy/todo/tests.py | 3 +
neuropy/todo/views.py | 3 +
neuropy/userprofile/__init__.py | 0
neuropy/userprofile/admin.py | 3 +
neuropy/userprofile/apps.py | 5 +
neuropy/userprofile/migrations/__init__.py | 0
neuropy/userprofile/models.py | 3 +
neuropy/userprofile/tests.py | 3 +
neuropy/userprofile/views.py | 3 +
requirements.pip | 2 +
20 files changed, 215 insertions(+)
create mode 100755 neuropy/manage.py
create mode 100644 neuropy/neuropy/__init__.py
create mode 100644 neuropy/neuropy/settings.py
create mode 100644 neuropy/neuropy/urls.py
create mode 100644 neuropy/neuropy/wsgi.py
create mode 100644 neuropy/todo/__init__.py
create mode 100644 neuropy/todo/admin.py
create mode 100644 neuropy/todo/apps.py
create mode 100644 neuropy/todo/migrations/__init__.py
create mode 100644 neuropy/todo/models.py
create mode 100644 neuropy/todo/tests.py
create mode 100644 neuropy/todo/views.py
create mode 100644 neuropy/userprofile/__init__.py
create mode 100644 neuropy/userprofile/admin.py
create mode 100644 neuropy/userprofile/apps.py
create mode 100644 neuropy/userprofile/migrations/__init__.py
create mode 100644 neuropy/userprofile/models.py
create mode 100644 neuropy/userprofile/tests.py
create mode 100644 neuropy/userprofile/views.py
create mode 100644 requirements.pip
diff --git a/neuropy/manage.py b/neuropy/manage.py
new file mode 100755
index 0000000..19d8b1d
--- /dev/null
+++ b/neuropy/manage.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+import os
+import sys
+
+if __name__ == "__main__":
+ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "neuropy.settings")
+ try:
+ from django.core.management import execute_from_command_line
+ except ImportError:
+ # The above import may fail for some other reason. Ensure that the
+ # issue is really that Django is missing to avoid masking other
+ # exceptions on Python 2.
+ try:
+ import django
+ except ImportError:
+ 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?"
+ )
+ raise
+ execute_from_command_line(sys.argv)
diff --git a/neuropy/neuropy/__init__.py b/neuropy/neuropy/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/neuropy/neuropy/settings.py b/neuropy/neuropy/settings.py
new file mode 100644
index 0000000..e0eed17
--- /dev/null
+++ b/neuropy/neuropy/settings.py
@@ -0,0 +1,120 @@
+"""
+Django settings for neuropy project.
+
+Generated by 'django-admin startproject' using Django 1.10.5.
+
+For more information on this file, see
+https://docs.djangoproject.com/en/1.10/topics/settings/
+
+For the full list of settings and their values, see
+https://docs.djangoproject.com/en/1.10/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.10/howto/deployment/checklist/
+
+# SECURITY WARNING: keep the secret key used in production secret!
+SECRET_KEY = 'y6o$5t_po!&22rrkc@-dewa4(us%g5k)fyrk-2ln)e!rlb#n^j'
+
+# SECURITY WARNING: don't run with debug turned on in production!
+DEBUG = True
+
+ALLOWED_HOSTS = []
+
+
+# Application definition
+
+INSTALLED_APPS = [
+ '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 = 'neuropy.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 = 'neuropy.wsgi.application'
+
+
+# Database
+# https://docs.djangoproject.com/en/1.10/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.10/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.10/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.10/howto/static-files/
+
+STATIC_URL = '/static/'
diff --git a/neuropy/neuropy/urls.py b/neuropy/neuropy/urls.py
new file mode 100644
index 0000000..338e55d
--- /dev/null
+++ b/neuropy/neuropy/urls.py
@@ -0,0 +1,21 @@
+"""neuropy URL Configuration
+
+The `urlpatterns` list routes URLs to views. For more information please see:
+ https://docs.djangoproject.com/en/1.10/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
+from django.contrib import admin
+
+urlpatterns = [
+ url(r'^admin/', admin.site.urls),
+]
diff --git a/neuropy/neuropy/wsgi.py b/neuropy/neuropy/wsgi.py
new file mode 100644
index 0000000..4d1a4fa
--- /dev/null
+++ b/neuropy/neuropy/wsgi.py
@@ -0,0 +1,16 @@
+"""
+WSGI config for neuropy 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.10/howto/deployment/wsgi/
+"""
+
+import os
+
+from django.core.wsgi import get_wsgi_application
+
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "neuropy.settings")
+
+application = get_wsgi_application()
diff --git a/neuropy/todo/__init__.py b/neuropy/todo/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/neuropy/todo/admin.py b/neuropy/todo/admin.py
new file mode 100644
index 0000000..8c38f3f
--- /dev/null
+++ b/neuropy/todo/admin.py
@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.
diff --git a/neuropy/todo/apps.py b/neuropy/todo/apps.py
new file mode 100644
index 0000000..6c85b8d
--- /dev/null
+++ b/neuropy/todo/apps.py
@@ -0,0 +1,5 @@
+from django.apps import AppConfig
+
+
+class TodoConfig(AppConfig):
+ name = 'todo'
diff --git a/neuropy/todo/migrations/__init__.py b/neuropy/todo/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/neuropy/todo/models.py b/neuropy/todo/models.py
new file mode 100644
index 0000000..71a8362
--- /dev/null
+++ b/neuropy/todo/models.py
@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.
diff --git a/neuropy/todo/tests.py b/neuropy/todo/tests.py
new file mode 100644
index 0000000..7ce503c
--- /dev/null
+++ b/neuropy/todo/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/neuropy/todo/views.py b/neuropy/todo/views.py
new file mode 100644
index 0000000..91ea44a
--- /dev/null
+++ b/neuropy/todo/views.py
@@ -0,0 +1,3 @@
+from django.shortcuts import render
+
+# Create your views here.
diff --git a/neuropy/userprofile/__init__.py b/neuropy/userprofile/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/neuropy/userprofile/admin.py b/neuropy/userprofile/admin.py
new file mode 100644
index 0000000..8c38f3f
--- /dev/null
+++ b/neuropy/userprofile/admin.py
@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.
diff --git a/neuropy/userprofile/apps.py b/neuropy/userprofile/apps.py
new file mode 100644
index 0000000..0252f18
--- /dev/null
+++ b/neuropy/userprofile/apps.py
@@ -0,0 +1,5 @@
+from django.apps import AppConfig
+
+
+class UserprofileConfig(AppConfig):
+ name = 'userprofile'
diff --git a/neuropy/userprofile/migrations/__init__.py b/neuropy/userprofile/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/neuropy/userprofile/models.py b/neuropy/userprofile/models.py
new file mode 100644
index 0000000..71a8362
--- /dev/null
+++ b/neuropy/userprofile/models.py
@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.
diff --git a/neuropy/userprofile/tests.py b/neuropy/userprofile/tests.py
new file mode 100644
index 0000000..7ce503c
--- /dev/null
+++ b/neuropy/userprofile/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/neuropy/userprofile/views.py b/neuropy/userprofile/views.py
new file mode 100644
index 0000000..91ea44a
--- /dev/null
+++ b/neuropy/userprofile/views.py
@@ -0,0 +1,3 @@
+from django.shortcuts import render
+
+# Create your views here.
diff --git a/requirements.pip b/requirements.pip
new file mode 100644
index 0000000..78da2c7
--- /dev/null
+++ b/requirements.pip
@@ -0,0 +1,2 @@
+Django==1.10.5
+pkg-resources==0.0.0
From 5e01dc7be5250ccab068b40aa938b7aebee05efc Mon Sep 17 00:00:00 2001
From: CLAIRE GATENBY
Date: Mon, 13 Feb 2017 11:08:38 -0800
Subject: [PATCH 007/249] added factory_boy, psycopg and ipython
---
requirements.pip | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/requirements.pip b/requirements.pip
index 78da2c7..3da52bb 100644
--- a/requirements.pip
+++ b/requirements.pip
@@ -1,2 +1,17 @@
+appnope==0.1.0
+decorator==4.0.11
Django==1.10.5
-pkg-resources==0.0.0
+factory-boy==2.8.1
+Faker==0.7.7
+ipython==5.2.2
+ipython-genutils==0.1.0
+pexpect==4.2.1
+prompt-toolkit==1.0.13
+psycopg2==2.6.2
+ptyprocess==0.5.1
+Pygments==2.2.0
+python-dateutil==2.6.0
+simplegeneric==0.8.1
+six==1.10.0
+traitlets==4.3.1
+wcwidth==0.1.7
From a3db20cf0d66d6148252662b14caac92538c2003 Mon Sep 17 00:00:00 2001
From: CLAIRE GATENBY
Date: Mon, 13 Feb 2017 11:23:16 -0800
Subject: [PATCH 008/249] changed settings for postgres db
---
neuropy/neuropy/settings.py | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/neuropy/neuropy/settings.py b/neuropy/neuropy/settings.py
index e0eed17..c5daa7f 100644
--- a/neuropy/neuropy/settings.py
+++ b/neuropy/neuropy/settings.py
@@ -75,8 +75,14 @@
DATABASES = {
'default': {
- 'ENGINE': 'django.db.backends.sqlite3',
- 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
+ 'ENGINE': 'django.db.backends.postgresql',
+ 'NAME': 'neuropy',
+ 'USER': os.environ.get("USER_NAME", ''),
+ 'HOST': '127.0.0.1',
+ 'PORT': '5432',
+ 'TEST': {
+ 'NAME': 'test_imager'
+ }
}
}
@@ -105,7 +111,7 @@
LANGUAGE_CODE = 'en-us'
-TIME_ZONE = 'UTC'
+TIME_ZONE = 'America/Los_Angeles'
USE_I18N = True
From da87be8ee24dc698eb570e715dfa3733e71b1f9b Mon Sep 17 00:00:00 2001
From: Amos Boldor
Date: Mon, 13 Feb 2017 11:27:17 -0800
Subject: [PATCH 009/249] add registration templates and routes
---
neuropy/neuropy/templates/neuropy/base.html | 14 ++++++++++++++
.../neuropy/templates/registration/activate.html | 4 ++++
.../registration/activation_complete.html | 4 ++++
.../templates/registration/activation_email.txt | 2 ++
.../registration/activation_email_subject.txt | 1 +
neuropy/neuropy/templates/registration/login.html | 14 ++++++++++++++
.../registration/registration_complete.html | 4 ++++
.../templates/registration/registration_form.html | 8 ++++++++
neuropy/neuropy/urls.py | 7 +++++--
9 files changed, 56 insertions(+), 2 deletions(-)
create mode 100644 neuropy/neuropy/templates/neuropy/base.html
create mode 100644 neuropy/neuropy/templates/registration/activate.html
create mode 100644 neuropy/neuropy/templates/registration/activation_complete.html
create mode 100644 neuropy/neuropy/templates/registration/activation_email.txt
create mode 100644 neuropy/neuropy/templates/registration/activation_email_subject.txt
create mode 100644 neuropy/neuropy/templates/registration/login.html
create mode 100644 neuropy/neuropy/templates/registration/registration_complete.html
create mode 100644 neuropy/neuropy/templates/registration/registration_form.html
diff --git a/neuropy/neuropy/templates/neuropy/base.html b/neuropy/neuropy/templates/neuropy/base.html
new file mode 100644
index 0000000..9d1431d
--- /dev/null
+++ b/neuropy/neuropy/templates/neuropy/base.html
@@ -0,0 +1,14 @@
+
+
+
+ NeuroPy
+
+
+
+
+{% endblock content %}
\ No newline at end of file
diff --git a/neuropy/neuropy/templates/registration/activation_complete.html b/neuropy/neuropy/templates/registration/activation_complete.html
new file mode 100644
index 0000000..2535819
--- /dev/null
+++ b/neuropy/neuropy/templates/registration/activation_complete.html
@@ -0,0 +1,4 @@
+{% extends 'neuropy/base.html' %}
+{% block content %}
+
Activation complete, welcome to neuropy
+{% endblock content %}
\ No newline at end of file
diff --git a/neuropy/neuropy/templates/registration/activation_email.txt b/neuropy/neuropy/templates/registration/activation_email.txt
new file mode 100644
index 0000000..3c13308
--- /dev/null
+++ b/neuropy/neuropy/templates/registration/activation_email.txt
@@ -0,0 +1,2 @@
+Click here to register at imagersite:
+http://{{ site.domain }}{% url "registration_activate" activation_key %}
\ No newline at end of file
diff --git a/neuropy/neuropy/templates/registration/activation_email_subject.txt b/neuropy/neuropy/templates/registration/activation_email_subject.txt
new file mode 100644
index 0000000..42fd665
--- /dev/null
+++ b/neuropy/neuropy/templates/registration/activation_email_subject.txt
@@ -0,0 +1 @@
+Account Activation
\ No newline at end of file
diff --git a/neuropy/neuropy/templates/registration/login.html b/neuropy/neuropy/templates/registration/login.html
new file mode 100644
index 0000000..bd68faf
--- /dev/null
+++ b/neuropy/neuropy/templates/registration/login.html
@@ -0,0 +1,14 @@
+{% extends 'neuropy/base.html' %}
+{% block content %}
+{% if form.errors %}
+
Your Username and password didn't match. Please try again.
We've sent you a confirmation email. Please check your email and click to confirm, in order to complete registration.
+
This link will expire in 7 days.
+ Home
{% endblock content %}
\ No newline at end of file
diff --git a/neuropy/neuropy/templates/registration/registration_form.html b/neuropy/neuropy/templates/registration/registration_form.html
index 500ca41..87df663 100644
--- a/neuropy/neuropy/templates/registration/registration_form.html
+++ b/neuropy/neuropy/templates/registration/registration_form.html
@@ -1,8 +1,9 @@
-{% extends 'neuropy/base.html' %}
+{% extends 'neuropy/layout.html' %}
{% block content %}
-
+ {{ form.as_p }}
+
+
{% endblock content %}
From 1b9b712e71f644088ecee3705c22bf7c53572280 Mon Sep 17 00:00:00 2001
From: pasaunders
Date: Mon, 13 Feb 2017 17:08:55 -0800
Subject: [PATCH 048/249] edit to views to avoid merge conflict
---
neuropy/userprofile/views.py | 26 +-------------------------
1 file changed, 1 insertion(+), 25 deletions(-)
diff --git a/neuropy/userprofile/views.py b/neuropy/userprofile/views.py
index da6375f..91ea44a 100644
--- a/neuropy/userprofile/views.py
+++ b/neuropy/userprofile/views.py
@@ -1,27 +1,3 @@
from django.shortcuts import render
-from django.contrib.auth.models import User
-from django.contrib.auth.mixins import LoginRequiredMixin, PermissionRequiredMixin
-from django.urls import reverse_lazy
-from django.views.generic import ListView, UpdateView
-PROFILE_TEMPLATE_PATH = "userprofile/profile.html"
-
-
-class Profile(LoginRequiredMixin, ListView):
- """View for the user's own profile."""
-
- login_url = reverse_lazy('login')
-
- model = User
- template_name = PROFILE_TEMPLATE_PATH
-
-
-class EditProfile(PermissionRequiredMixin, UpdateView):
- """Allows the User to edit their profile."""
-
- permission_required = "userprofile.change_profile"
-
- template_name = "userprofile/edit_album.html"
- model = Profile
- fields = ['active_period_start', 'active_period_end', 'peak_period', 'dose_time']
- success_url = reverse_lazy('userprofile:profile')
+# Create your views here.
From b3e922576e436e60d8eb1eab55bdf71688598c09 Mon Sep 17 00:00:00 2001
From: Amos Boldor
Date: Mon, 13 Feb 2017 17:12:19 -0800
Subject: [PATCH 049/249] test that /profile/ and /profile/edit show up with
the correct data
---
neuropy/userprofile/tests.py | 48 ++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/neuropy/userprofile/tests.py b/neuropy/userprofile/tests.py
index 9e602e1..a3f7db0 100644
--- a/neuropy/userprofile/tests.py
+++ b/neuropy/userprofile/tests.py
@@ -74,6 +74,24 @@ def setUp(self):
self.client = Client()
self.request = RequestFactory()
+ def make_user_and_login(self):
+ """Make user and login."""
+ add_user_group()
+ user_register = UserFactory.create()
+ user_register.is_active = True
+ user_register.username = "bobdole"
+ user_register.first_name = 'Bob'
+ user_register.last_name = 'Dole'
+ user_register.email = 'awesome@gmail.com'
+ user_register.set_password("rutabega")
+ user_register.save()
+ self.client.post("/login/", {
+ "username": user_register.username,
+ "password": "rutabega"
+
+ })
+ return self.client, user_register
+
def test_home_route_templates(self):
"""Test the home route templates are correct."""
response = self.client.get("/")
@@ -106,3 +124,33 @@ def test_registeration_has_input_fields(self):
response = self.client.get('/accounts/register/')
parsed_html = BeautifulSoup(response.content, "html5lib")
self.assertTrue(len(parsed_html.find_all('input')) == 5)
+
+ def test_profile_route_has_all_info(self):
+ """Test profile route has all info."""
+ client, user = self.make_user_and_login()
+ html = client.get('/profile/').content
+ html = str(html)
+ self.assertTrue('Bob Dole' in html)
+ self.assertTrue('bobdole' in html)
+ self.assertTrue('awesome@gmail.com' in html)
+ self.assertTrue('Active Period Start: 8 a.m.' in html)
+ self.assertTrue('Active Period End: 10 p.m.' in html)
+ self.assertTrue('Peak Period: Morning' in html)
+ self.assertTrue('Dose Time: 8 a.m.' in html)
+
+ def test_edit_route_shows_info(self):
+ """Test_edit_route_shows_info."""
+ client, user = self.make_user_and_login()
+ html = client.get('/profile/edit/').content
+ parsed_html = BeautifulSoup(html, "html5lib")
+
+ def return_value(id):
+ return parsed_html.find("input", {"id": id})['value']
+
+ self.assertTrue(return_value('id_First Name') == 'Bob')
+ self.assertTrue(return_value('id_Last Name') == 'Dole')
+ self.assertTrue(return_value('id_Email') == 'awesome@gmail.com')
+ self.assertTrue(return_value('id_active_period_start') == '08:00:00')
+ self.assertTrue(return_value('id_active_period_end') == '22:00:00')
+ self.assertTrue(len(parsed_html.find_all('option')) == 6)
+ self.assertTrue(return_value('id_dose_time') == '08:00:00')
From 8fd7950f09920989615768e9566ff0f2cb49f462 Mon Sep 17 00:00:00 2001
From: Amos Boldor
Date: Mon, 13 Feb 2017 18:03:17 -0800
Subject: [PATCH 050/249] update settings.py make more tests for profile views
---
neuropy/neuropy/settings.py | 4 ++--
neuropy/userprofile/tests.py | 44 ++++++++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+), 2 deletions(-)
diff --git a/neuropy/neuropy/settings.py b/neuropy/neuropy/settings.py
index b9d7fc8..fc09025 100644
--- a/neuropy/neuropy/settings.py
+++ b/neuropy/neuropy/settings.py
@@ -37,6 +37,7 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
+ 'neuropy',
'userprofile',
'todo',
]
@@ -56,8 +57,7 @@
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
- 'DIRS': [os.path.join(BASE_DIR, 'neuropy/templates'),
- os.path.join(BASE_DIR, 'userprofile/templates')],
+ 'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
diff --git a/neuropy/userprofile/tests.py b/neuropy/userprofile/tests.py
index a3f7db0..8eb1afe 100644
--- a/neuropy/userprofile/tests.py
+++ b/neuropy/userprofile/tests.py
@@ -154,3 +154,47 @@ def return_value(id):
self.assertTrue(return_value('id_active_period_end') == '22:00:00')
self.assertTrue(len(parsed_html.find_all('option')) == 6)
self.assertTrue(return_value('id_dose_time') == '08:00:00')
+
+ def test_that_edit_will_edit_the_model(self):
+ """Test that edit will edit the model."""
+ client, user = self.make_user_and_login()
+ html = client.get('/profile/edit/').content
+ html = BeautifulSoup(html, "html5lib")
+ csrf = html.find("input", {"name": 'csrfmiddlewaretoken'})['value']
+ client.post('/profile/edit/', {
+ "csrfmiddlewaretoken": csrf,
+ "First Name": "Sam",
+ "Last Name": "Glad",
+ "Email": "samglad@gmail.com",
+ "active_period_start": "09:00:00",
+ "active_period_end": "23:00:00",
+ "peak_period": "early_bird",
+ "dose_time": "09:00:00"
+ })
+ html = client.get('/profile/').content
+ html = str(html)
+ self.assertTrue('Sam Glad' in html)
+ self.assertTrue('bobdole' in html)
+ self.assertTrue('samglad@gmail.com' in html)
+ self.assertTrue('Active Period Start: 9 a.m.' in html)
+ self.assertTrue('Active Period End: 11 p.m.' in html)
+ self.assertTrue('Peak Period: early_bird' in html)
+ self.assertTrue('Dose Time: 9 a.m.' in html)
+
+ def test_edit_will_redirect_to_profile(self):
+ """Test edit will redirect to profile."""
+ client, user = self.make_user_and_login()
+ html = client.get('/profile/edit/').content
+ html = BeautifulSoup(html, "html5lib")
+ csrf = html.find("input", {"name": 'csrfmiddlewaretoken'})['value']
+ response = client.post('/profile/edit/', {
+ "csrfmiddlewaretoken": csrf,
+ "First Name": "Sam",
+ "Last Name": "Glad",
+ "Email": "samglad@gmail.com",
+ "active_period_start": "09:00:00",
+ "active_period_end": "23:00:00",
+ "peak_period": "early_bird",
+ "dose_time": "09:00:00"
+ })
+ self.assertRedirects(response, '/profile/')
From 036e29aba8420e63a0f09bd81aceba3c4ca35c1f Mon Sep 17 00:00:00 2001
From: pasaunders
Date: Mon, 13 Feb 2017 18:26:53 -0800
Subject: [PATCH 051/249] readme update
---
README.md | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 107 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index be62380..8c365c3 100644
--- a/README.md
+++ b/README.md
@@ -11,9 +11,114 @@ A personalized priority app to support a *Cognitive Behavioral Therapy* (CBT) ap
*Neuropy* Considers what the habit/disorder the user wants to treat with CBT, along with medication, it's half-life and peak periods. Also works around black-out periods on user's schedule by syncing with Google Calender, personal preference or most productive period of the day for user, and finally considers time commitments for each activity. Each "TO-DO" will be ranked considering these aspects and will be worked into periods of the day.
-version-0.1 (in active development) Keywords:
+version-0.1 (in active development) Keywords:
No medical data is stored by NeuroPy
-USER STORIES:
+##Getting Started
+
+Clone this repository into whatever directory you want to work from.
+```
+https://github.com/NeuroPyPlanner/NeuroPy.git
+```
+Assuming that you have access to Python 3 at the system level, start up a new virtual environment.
+```
+$ cd django-imager
+$ python3 -m venv ENV
+$ source ENV/bin/activate
+```
+Once your environment has been activated, make sure to install Django and all of this project's required packages.
+```
+(django-imager) $ pip install -r requirements.pip
+```
+Navigate to the project root, imagersite, and apply the migrations for the app.
+```
+(django-imager) $ cd imagersite
+
+(django-imager) $ ./manage.py migrate
+```
+Finally, run the server in order to server the app on localhost
+```
+(django-imager) $ ./manage.py runserver
+```
+Django will typically serve on port 8000, unless you specify otherwise. You can access the locally-served site at the address http://localhost:8000.
+
+
+##Current Models (outside of Django built-ins):
+
+This application allow users to store and organize photos.
+
+**The `Profile` model contains:**
+
+- The period which the user is up and active
+- The time of day when a user is best able to focus and work
+- The time of day when a user takes their medication
+
+**The `Todo` model contains:**
+
+- Date
+- Ease of accomplishing the task
+- Duration of task
+- Owner of the task
+- Title of the task
+- Description
+- Priority level
+
+**The `Medication` model contains:**
+
+- Name
+- Type
+- Use (on or off label)
+- Half life
+- Time to begin metabolizing
+
+##Current URL Routes
+
+- `/admin` Superuser admin page.
+- `/` Home page.
+- `/login` Login page.
+- `/logout` Logout route, no view.
+- `/accounts/register` Register a user form.
+- `/accounts/activate/complete/` Activation complete view.
+- `/accounts/register/complete/` Registration complete, email sent.
+
+
+##Running Tests
+
+Running tests for the django-imager is fairly straightforward. Navigate to the same directory as the manage.py file and type:
+```
+(django-imager) $ coverage run manage.py test
+```
+This will show you which tests have failed, which tests have passed. If you'd like a report of the actual coverage of your tests, type
+```
+(django-imager) $ coverage report
+```
+This will read from the included .coverage file, with configuration set in the .coveragerc file. Currently the configuration will show which lines were missing from the test coverage.
+
+
+### USER STORIES:
+
+#### User Stories
+
+- As a user I want the app to use good CBT principles so that I can effectively manage my energy.
+- As a user I want the app to take my medications into account so that I can work at my highest-focus time of day.
+- As a user I want the app to take in my personal preferences into account so that I don’t work on easy tasks when I have energy and hard tasks when I’m tired.
+- As a user I want the app to preserve my preferences so that I can conveniently generate new schedules.
+- As a user I want to be able to input my personal preferences and data easily and accurately so that the app can prioritize my day effectively.
+- As a user I want my medical data to be secure so that I can avoid fraud and identity theft.
+- As a user I want to be able to quickly generate schedules with minimal clicks so that I don’t have to spend all my energy organizing.
+- As a user I want my newly generated schedule to be integrated into my google calendar with notifications.
+- As a user I want the app to take into account my sleep schedule so that I can work when I have the most energy.
+
+
+#### Developer Stories
+
+- As a developer I want readable and well documented code to make maintenance easier.
+- As a developer I want to practise test driven development in building my app and spotting bugs early on.
+- As a developer I want to avoid storing any medical data so that I don’t have to deal with HIPAA violations.
+- As a developer I want to store data of users in appropriate models, with logical relationships.
+- As a developer I want to build for one disorder before expanding so that I can build on a strong foundation.
+- As a developer I want a narrow open source license so that we retain plenty of rights to our work.
+- As a developer I want to write an algorithm that prioritises todos based on a user’s profile.
+- As a developer I want to integrate the google calendars with my app using an api.
From c3d53af64c32e0aeed4639bdf8a60b05ddb40199 Mon Sep 17 00:00:00 2001
From: CLAIRE GATENBY
Date: Mon, 13 Feb 2017 19:21:54 -0800
Subject: [PATCH 052/249] added css for form and terms and conditions
---
.../neuropy/static/neuropy/sticky-footer-navbar.css | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/neuropy/neuropy/static/neuropy/sticky-footer-navbar.css b/neuropy/neuropy/static/neuropy/sticky-footer-navbar.css
index ee80380..ba725f0 100755
--- a/neuropy/neuropy/static/neuropy/sticky-footer-navbar.css
+++ b/neuropy/neuropy/static/neuropy/sticky-footer-navbar.css
@@ -32,8 +32,20 @@ body > .container {
.footer > .container {
padding-right: 15px;
padding-left: 15px;
+ margin-top: 30px;
}
code {
font-size: 80%;
}
+
+
+.terms {
+ width: 60%;
+ height: 300px;
+ border: 1px solid #ccc;
+ background: #f2f2f2;
+ padding: 6px;
+ overflow: auto;
+ margin-bottom: 30px;
+}
From 7af02349dd52546a73c8f2485edffae6c903dbac Mon Sep 17 00:00:00 2001
From: CLAIRE GATENBY
Date: Mon, 13 Feb 2017 19:22:30 -0800
Subject: [PATCH 053/249] added ts and cs and tick box
---
.../registration/registration_form.html | 40 ++++++++++++++++++-
1 file changed, 38 insertions(+), 2 deletions(-)
diff --git a/neuropy/neuropy/templates/registration/registration_form.html b/neuropy/neuropy/templates/registration/registration_form.html
index 87df663..df6a77c 100644
--- a/neuropy/neuropy/templates/registration/registration_form.html
+++ b/neuropy/neuropy/templates/registration/registration_form.html
@@ -1,9 +1,45 @@
{% extends 'neuropy/layout.html' %}
{% block content %}
Register
-
{% endblock content %}
From aaaf03c608b701b96a3a5fa8e0d4451112bcad49 Mon Sep 17 00:00:00 2001
From: CLAIRE GATENBY
Date: Mon, 13 Feb 2017 19:22:51 -0800
Subject: [PATCH 054/249] updated registration to overwrite the default for TOS
---
neuropy/neuropy/urls.py | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/neuropy/neuropy/urls.py b/neuropy/neuropy/urls.py
index 7478f7f..12dc523 100644
--- a/neuropy/neuropy/urls.py
+++ b/neuropy/neuropy/urls.py
@@ -1,4 +1,4 @@
-"""neuropy URL Configuration
+"""Neuropy URL Configuration.
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.10/topics/http/urls/
@@ -14,14 +14,21 @@
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url, include
-from django.contrib import admin, auth
+from django.contrib import admin
+from django.contrib.auth import views as auth_views
from django.views.generic import TemplateView
+from registration.backends.hmac.views import RegistrationView
+from registration.forms import RegistrationFormTermsOfService
urlpatterns = [
url(r'^admin/', admin.site.urls),
- url(r'^$', TemplateView.as_view(template_name="neuropy/home.html"), name='home'),
+ url(r'^$', TemplateView.as_view(template_name="neuropy/home.html"),
+ name='home'),
+ url(r'^accounts/register/$',
+ RegistrationView.as_view(form_class=RegistrationFormTermsOfService),
+ name='registration_register'),
url(r'^accounts/', include('registration.backends.hmac.urls')),
- url(r'^login/', auth.views.login, name='login'),
- url(r'^logout/', auth.views.logout, {'next_page': '/'}, name='logout'),
+ url(r'^login/', auth_views.login, name='login'),
+ url(r'^logout/', auth_views.logout, {'next_page': '/'}, name='logout'),
]
From b0565a8e2d5f097d40bbfc7e772c52f5e0ecee9c Mon Sep 17 00:00:00 2001
From: CLAIRE GATENBY
Date: Mon, 13 Feb 2017 19:23:38 -0800
Subject: [PATCH 055/249] had to comment out group until set up
---
.../neuropy/templates/registration/activation_complete.html | 1 -
neuropy/userprofile/models.py | 4 ++--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/neuropy/neuropy/templates/registration/activation_complete.html b/neuropy/neuropy/templates/registration/activation_complete.html
index 14a1bb9..c070b20 100644
--- a/neuropy/neuropy/templates/registration/activation_complete.html
+++ b/neuropy/neuropy/templates/registration/activation_complete.html
@@ -4,7 +4,6 @@
Congratulations!
You have successfully completed registration to IMAGE-Nation
To get started, why not edit your profile, so we can get to know you.
- Edit ProfileHome
{% endblock content %}
\ No newline at end of file
diff --git a/neuropy/userprofile/models.py b/neuropy/userprofile/models.py
index 7c368d2..bf5ede6 100644
--- a/neuropy/userprofile/models.py
+++ b/neuropy/userprofile/models.py
@@ -37,7 +37,7 @@ class Profile(models.Model):
def build_profile(sender, instance, **kwargs):
"""Attaches a profile to a user whenever a user is made."""
if kwargs["created"]:
- group = Group.objects.get(name='user')
- instance.groups.add(group)
+ # group = Group.objects.get(name='user')
+ # instance.groups.add(group)
new_profile = Profile(user=instance)
new_profile.save()
From 07e81bbc34712e695d9f32e078f0697cc677581c Mon Sep 17 00:00:00 2001
From: CLAIRE GATENBY
Date: Mon, 13 Feb 2017 22:03:04 -0800
Subject: [PATCH 056/249] removed unnecessary p tag
---
neuropy/neuropy/templates/registration/registration_form.html | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/neuropy/neuropy/templates/registration/registration_form.html b/neuropy/neuropy/templates/registration/registration_form.html
index df6a77c..51de4e5 100644
--- a/neuropy/neuropy/templates/registration/registration_form.html
+++ b/neuropy/neuropy/templates/registration/registration_form.html
@@ -11,9 +11,8 @@
The developers authorized to edit NeuroPy (NeuroPy devs) may alter augment or remove Neuropy’s source code and/or functionality at any time and at their sole discretion. This service is intended for personal use under the supervision of a qualified psychological or psychiatric professional. NeuroPy is intended for personal convenience only, and is not a substitute for qualified professional judgment. In cases where the user doubts the usefulness of NeuroPy’s scheduling advice, the user should exercise their own judgment or consult with a qualified professional.
From 131c13f3661384b7661e7d6ea063bb7a33d379c3 Mon Sep 17 00:00:00 2001
From: CLAIRE GATENBY
Date: Mon, 13 Feb 2017 22:03:21 -0800
Subject: [PATCH 057/249] uncommented out group
---
neuropy/userprofile/models.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/neuropy/userprofile/models.py b/neuropy/userprofile/models.py
index bf5ede6..7c368d2 100644
--- a/neuropy/userprofile/models.py
+++ b/neuropy/userprofile/models.py
@@ -37,7 +37,7 @@ class Profile(models.Model):
def build_profile(sender, instance, **kwargs):
"""Attaches a profile to a user whenever a user is made."""
if kwargs["created"]:
- # group = Group.objects.get(name='user')
- # instance.groups.add(group)
+ group = Group.objects.get(name='user')
+ instance.groups.add(group)
new_profile = Profile(user=instance)
new_profile.save()
From 4762468dfd0c3ac40ade05162b5835f1f10fc1bd Mon Sep 17 00:00:00 2001
From: CLAIRE GATENBY
Date: Mon, 13 Feb 2017 22:03:38 -0800
Subject: [PATCH 058/249] added test for tos on registration
---
neuropy/userprofile/tests.py | 31 ++++++++++++++++++++++---------
1 file changed, 22 insertions(+), 9 deletions(-)
diff --git a/neuropy/userprofile/tests.py b/neuropy/userprofile/tests.py
index 09c7ffb..f90c6f5 100644
--- a/neuropy/userprofile/tests.py
+++ b/neuropy/userprofile/tests.py
@@ -5,6 +5,7 @@
from userprofile.models import Profile
import factory
from django.core.urlresolvers import reverse_lazy
+
from bs4 import BeautifulSoup
@@ -87,7 +88,7 @@ def setUp(self):
def test_home_route_templates(self):
"""Test the home route templates are correct."""
- response = self.client.get("/")
+ response = self.client.get(reverse_lazy('home'))
self.assertTemplateUsed(response, "neuropy/base.html")
self.assertTemplateUsed(response, "neuropy/home.html")
@@ -95,25 +96,37 @@ def test_login_redirect_code(self):
"""Test built-in login route redirects properly."""
add_user_group()
user_register = UserFactory.create()
- user_register.is_active = True
user_register.username = "username"
user_register.set_password("rutabega")
user_register.save()
- response = self.client.post("/login/", {
+ response = self.client.post(reverse_lazy("login"), {
"username": user_register.username,
"password": "rutabega"
-
})
- self.assertRedirects(response, '/')
+ self.assertTrue(response.status_code == 302)
+ self.assertTrue(response.url == '/')
def test_login_has_input_fields(self):
"""Test login has input fields."""
- response = self.client.get('/login/')
+ response = self.client.get(reverse_lazy('login'))
parsed_html = BeautifulSoup(response.content, "html5lib")
- self.assertTrue(len(parsed_html.find_all('input')) == 4)
+ self.assertTrue(len(parsed_html.find_all('input')) == 3)
def test_registeration_has_input_fields(self):
"""Test registeration has input fields."""
- response = self.client.get('/accounts/register/')
+ response = self.client.get(reverse_lazy('registration_register'))
parsed_html = BeautifulSoup(response.content, "html5lib")
- self.assertTrue(len(parsed_html.find_all('input')) == 5)
+ self.assertTrue(len(parsed_html.find_all('input')) == 6)
+
+ def test_registration_has_tos(self):
+ """Test registration form has TOS."""
+ response = self.client.get(reverse_lazy('registration_register'))
+ parsed_html = BeautifulSoup(response.content, 'html5lib')
+ self.assertTrue(parsed_html.find('h3').text == ' Terms of Service ')
+
+ def test_registration_has_tos_tick_box(self):
+ """Test registration form has input for tos."""
+ response = self.client.get(reverse_lazy('registration_register'))
+ parsed_html = BeautifulSoup(response.content, 'html5lib')
+ tos = parsed_html.findAll('input', attrs={'name': 'tos'})
+ self.assertTrue(len(tos) == 1)
From 2ee0bc417b6a354a7d8737abb3d857bee4666638 Mon Sep 17 00:00:00 2001
From: Claire Gatenby
Date: Mon, 13 Feb 2017 22:33:31 -0800
Subject: [PATCH 059/249] Typo fix
---
README.md | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/README.md b/README.md
index 8c365c3..5645888 100644
--- a/README.md
+++ b/README.md
@@ -23,23 +23,23 @@ https://github.com/NeuroPyPlanner/NeuroPy.git
```
Assuming that you have access to Python 3 at the system level, start up a new virtual environment.
```
-$ cd django-imager
+$ cd NeuroPy
$ python3 -m venv ENV
$ source ENV/bin/activate
```
Once your environment has been activated, make sure to install Django and all of this project's required packages.
```
-(django-imager) $ pip install -r requirements.pip
+(NeuroPy) $ pip install -r requirements.pip
```
Navigate to the project root, imagersite, and apply the migrations for the app.
```
-(django-imager) $ cd imagersite
+(NeuroPy) $ cd imagersite
-(django-imager) $ ./manage.py migrate
+(NeuroPy) $ ./manage.py migrate
```
Finally, run the server in order to server the app on localhost
```
-(django-imager) $ ./manage.py runserver
+(NeuroPy) $ ./manage.py runserver
```
Django will typically serve on port 8000, unless you specify otherwise. You can access the locally-served site at the address http://localhost:8000.
@@ -87,11 +87,11 @@ This application allow users to store and organize photos.
Running tests for the django-imager is fairly straightforward. Navigate to the same directory as the manage.py file and type:
```
-(django-imager) $ coverage run manage.py test
+(NeuroPy) $ coverage run manage.py test
```
This will show you which tests have failed, which tests have passed. If you'd like a report of the actual coverage of your tests, type
```
-(django-imager) $ coverage report
+(NeuroPy) $ coverage report
```
This will read from the included .coverage file, with configuration set in the .coveragerc file. Currently the configuration will show which lines were missing from the test coverage.
From d2a20516de7d9524188a1e9ea9f89c3b81c4058f Mon Sep 17 00:00:00 2001
From: Your Name
Date: Tue, 14 Feb 2017 08:49:52 -0800
Subject: [PATCH 060/249] fixed test error. Added another test. Passing. minor
change to model format
---
neuropy/medication/models.py | 15 ++++++++++++---
neuropy/medication/tests.py | 22 ++++++++++++++--------
2 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/neuropy/medication/models.py b/neuropy/medication/models.py
index bf47d2f..ab06773 100644
--- a/neuropy/medication/models.py
+++ b/neuropy/medication/models.py
@@ -1,3 +1,5 @@
+"""Medication model- no user relation."""
+
from __future__ import unicode_literals
from django.db import models
@@ -6,7 +8,7 @@
@python_2_unicode_compatible
class Medication(models.Model):
- """."""
+ """Medication instace class."""
name = models.CharField(
max_length=20,
@@ -19,5 +21,12 @@ class Medication(models.Model):
# Ease_priority_matrix=models.CharField
def __str__(self):
- """."""
- return "name: {}, med_type: {}, treating_dis: {}, half_life: {}, ramp_up: {}, peak_period: {}".format(self.name, self.med_type, self.treating_dis, self.half_life, self.ramp_up, self.peak_period)
+ """String representation of Medication."""
+ return "name: {},med_type: {}, treating_dis: {}, half_life: {}, ramp_up: {}, peak_period: {}".format(
+ self.name,
+ self.med_type,
+ self.treating_dis,
+ self.half_life,
+ self.ramp_up,
+ self.peak_period
+ )
diff --git a/neuropy/medication/tests.py b/neuropy/medication/tests.py
index 840fcc8..15f2b17 100644
--- a/neuropy/medication/tests.py
+++ b/neuropy/medication/tests.py
@@ -25,7 +25,6 @@ def medication_instance(self):
ramp_up=ramp_up,
peak_period=peak_period
)
- import pdb; pdb.set_trace()
objects.save()
return objects.id
@@ -34,12 +33,19 @@ def test_name(self):
"""Test that a medication instance has a name."""
#med_id = self.medication_instance()
medication = Medication.objects.get(name="CONCERTA")
- import pdb; pdb.set_trace()
self.assertTrue(medication.name == "CONCERTA")
- # def test_med_type(self):
- # """Test that medication instanc."""
- # #med_id = self.medication_instance()
- # medication = Medication.objects.get(med_type="stimulant")
- # import pdb; pdb.set_trace()
- # assert medication.med_type == "stimulant"
+ def test_med_type(self):
+ """Test medication instance type."""
+ #med_id = self.medication_instance()
+ medications = Medication.objects.filter(med_type="stimulant")
+ for medication in medications:
+ assert medication.med_type == "stimulant"
+
+ def test_delete_med(self):
+ """Test fetching medication after delete throws an exception."""
+ #med_id = self.medication_instance()
+ medication = Medication.objects.get(name="CONCERTA")
+ medication.delete()
+ with self.assertRaises(Medication.DoesNotExist):
+ Medication.objects.get(name="CONCERTA")
From 8d834a280a5da9ab5a419c55b5fb996f2492757e Mon Sep 17 00:00:00 2001
From: CLAIRE GATENBY
Date: Tue, 14 Feb 2017 09:38:24 -0800
Subject: [PATCH 061/249] fixed error with profile templates
---
neuropy/userprofile/templates/userprofile/edit_profile.html | 2 +-
neuropy/userprofile/templates/userprofile/profile.html | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/neuropy/userprofile/templates/userprofile/edit_profile.html b/neuropy/userprofile/templates/userprofile/edit_profile.html
index cecc42c..85cd129 100644
--- a/neuropy/userprofile/templates/userprofile/edit_profile.html
+++ b/neuropy/userprofile/templates/userprofile/edit_profile.html
@@ -1,4 +1,4 @@
-{% extends 'neuropy/base.html' %}
+{% extends 'neuropy/layout.html' %}
{% block content %}
Welcome {{user.username}}!
From b3bd9b06f2c6362e5c333681d47836cde974b929 Mon Sep 17 00:00:00 2001
From: CLAIRE GATENBY
Date: Tue, 14 Feb 2017 16:14:13 -0800
Subject: [PATCH 101/249] added basic test for list todo route
---
neuropy/todo/tests.py | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/neuropy/todo/tests.py b/neuropy/todo/tests.py
index 7fb3eb6..3f97ab5 100644
--- a/neuropy/todo/tests.py
+++ b/neuropy/todo/tests.py
@@ -1,8 +1,10 @@
"""Test for todo app."""
-from django.test import TestCase
-from todo.models import Todo
from django.contrib.auth.models import User, Group
+from django.test import TestCase, Client, RequestFactory
+from django.urls import reverse_lazy
+
+from todo.models import Todo
from userprofile.models import Profile
import factory
@@ -97,6 +99,21 @@ class TodoFrontEndTestCase(TestCase):
def setUp(self):
"""The setup and buildout for users, todos."""
+ self.client = Client()
+ self.request = RequestFactory()
add_user_group()
self.users = [UserFactory.create() for i in range(20)]
self.todos = [TodoFactory.create() for i in range(20)]
+
+ def test_todo_list_route_is_status_ok(self):
+ """Funcional test for todo list."""
+ self.client.force_login(self.users[0])
+ response = self.client.get(reverse_lazy("list_todo"))
+ self.assertTrue(response.status_code == 200)
+
+ def test_todo_list_route_uses_right_templates(self):
+ """Test todo list returns the right templates."""
+ self.client.force_login(self.users[0])
+ response = self.client.get(reverse_lazy("list_todo"))
+ self.assertTemplateUsed(response, "neuropy/layout.html")
+ self.assertTemplateUsed(response, "todo/list_todo.html")
From d013d95689a019891abbc8b02aa64a752f4539e6 Mon Sep 17 00:00:00 2001
From: CLAIRE GATENBY
Date: Tue, 14 Feb 2017 16:14:30 -0800
Subject: [PATCH 102/249] fixed issues after update
---
neuropy/userprofile/tests.py | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/neuropy/userprofile/tests.py b/neuropy/userprofile/tests.py
index 495c348..266108d 100644
--- a/neuropy/userprofile/tests.py
+++ b/neuropy/userprofile/tests.py
@@ -157,10 +157,9 @@ def test_profile_route_has_all_info(self):
self.assertTrue('Bob Dole' in html)
self.assertTrue('bobdole' in html)
self.assertTrue('awesome@gmail.com' in html)
- self.assertTrue('Active Period Start: 8 a.m.' in html)
- self.assertTrue('Active Period End: 10 p.m.' in html)
- self.assertTrue('Peak Period: Morning' in html)
- self.assertTrue('Dose Time: 8 a.m.' in html)
+ self.assertTrue('8 a.m.' in html)
+ self.assertTrue('10 p.m.' in html)
+ self.assertTrue('Morning' in html)
def test_edit_route_shows_info(self):
"""Test_edit_route_shows_info."""
@@ -200,10 +199,9 @@ def test_that_edit_will_edit_the_model(self):
self.assertTrue('Sam Glad' in html)
self.assertTrue('bobdole' in html)
self.assertTrue('samglad@gmail.com' in html)
- self.assertTrue('Active Period Start: 9 a.m.' in html)
- self.assertTrue('Active Period End: 11 p.m.' in html)
- self.assertTrue('Peak Period: early_bird' in html)
- self.assertTrue('Dose Time: 9 a.m.' in html)
+ self.assertTrue('9 a.m.' in html)
+ self.assertTrue('11 p.m.' in html)
+ self.assertTrue('early_bird' in html)
def test_edit_will_redirect_to_profile(self):
"""Test edit will redirect to profile."""
From d11c4f2cfe53bd7918351f24500b000bf24f6dcd Mon Sep 17 00:00:00 2001
From: CLAIRE GATENBY
Date: Tue, 14 Feb 2017 16:20:32 -0800
Subject: [PATCH 103/249] added simple test for detail view
---
neuropy/todo/tests.py | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/neuropy/todo/tests.py b/neuropy/todo/tests.py
index 3f97ab5..85121b8 100644
--- a/neuropy/todo/tests.py
+++ b/neuropy/todo/tests.py
@@ -117,3 +117,22 @@ def test_todo_list_route_uses_right_templates(self):
response = self.client.get(reverse_lazy("list_todo"))
self.assertTemplateUsed(response, "neuropy/layout.html")
self.assertTemplateUsed(response, "todo/list_todo.html")
+
+ def test_todo_detail_route_is_status_ok(self):
+ """Funcional test for todo list."""
+ self.client.force_login(self.users[0])
+ todo = self.todos[0]
+ todo.owner = self.users[0].profile
+ todo.save()
+ response = self.client.get('/profile/todo/' + str(todo.pk))
+ self.assertTrue(response.status_code == 200)
+
+ def test_todo_detail_route_uses_right_templates(self):
+ """Test todo list returns the right templates."""
+ self.client.force_login(self.users[0])
+ todo = self.todos[0]
+ todo.owner = self.users[0].profile
+ todo.save()
+ response = self.client.get('/profile/todo/' + str(todo.pk))
+ self.assertTemplateUsed(response, "neuropy/layout.html")
+ self.assertTemplateUsed(response, "todo/detail_todo.html")
From 0c663905ba9cc465ec93dd1d0f476b6d56afea05 Mon Sep 17 00:00:00 2001
From: Amos Boldor
Date: Tue, 14 Feb 2017 16:56:18 -0800
Subject: [PATCH 104/249] add migration credentialsmodel
---
.../migrations/0002_credentialsmodel.py | 27 +++++++++++++++++++
1 file changed, 27 insertions(+)
create mode 100644 neuropy/userprofile/migrations/0002_credentialsmodel.py
diff --git a/neuropy/userprofile/migrations/0002_credentialsmodel.py b/neuropy/userprofile/migrations/0002_credentialsmodel.py
new file mode 100644
index 0000000..76a6c6f
--- /dev/null
+++ b/neuropy/userprofile/migrations/0002_credentialsmodel.py
@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.5 on 2017-02-14 19:14
+from __future__ import unicode_literals
+
+from django.conf import settings
+from django.db import migrations, models
+import django.db.models.deletion
+import oauth2client.contrib.django_util.models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ('userprofile', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='CredentialsModel',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('credential', oauth2client.contrib.django_util.models.CredentialsField(null=True)),
+ ('user_id', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
+ ],
+ ),
+ ]
From 6e06b8f54e3455d78b05845efe077ad5bbfd612a Mon Sep 17 00:00:00 2001
From: Your Name
Date: Tue, 14 Feb 2017 16:57:48 -0800
Subject: [PATCH 105/249] switching to algorithm branch.
---
neuropy/medication/admin.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/neuropy/medication/admin.py b/neuropy/medication/admin.py
index 1f27b4a..23c2c1f 100644
--- a/neuropy/medication/admin.py
+++ b/neuropy/medication/admin.py
@@ -1,5 +1,4 @@
from django.contrib import admin
from medication.models import Medication
-# Register your models here.
admin.site.register(Medication)
From dab519cb96c3b09dbe873e364e819f7875577b0b Mon Sep 17 00:00:00 2001
From: pasaunders
Date: Tue, 14 Feb 2017 16:58:43 -0800
Subject: [PATCH 106/249] 3 of 5 tuesday tests complete
---
neuropy/todo/templates/todo/edit_todo.html | 2 +-
neuropy/todo/tests.py | 26 ++++++++++++++++++++--
neuropy/todo/views.py | 4 ++--
3 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/neuropy/todo/templates/todo/edit_todo.html b/neuropy/todo/templates/todo/edit_todo.html
index 0ab5946..f45713f 100644
--- a/neuropy/todo/templates/todo/edit_todo.html
+++ b/neuropy/todo/templates/todo/edit_todo.html
@@ -6,7 +6,7 @@
-
Schedule a Todo item
+
Edit a To-Do item
diff --git a/neuropy/todo/tests.py b/neuropy/todo/tests.py
index 85121b8..0a73490 100644
--- a/neuropy/todo/tests.py
+++ b/neuropy/todo/tests.py
@@ -49,7 +49,7 @@ def add_user_group():
class TodoTestCase(TestCase):
- """The User Model test class."""
+ """The Todo Model test class."""
def setUp(self):
"""The setup and buildout for users, todos."""
@@ -63,6 +63,10 @@ def test_todo_exists(self):
this_todo.save()
self.assertTrue(self.todos[0])
+ def test_unique_todo_created(self):
+ """Test that the number of todos in the database equla the nuber of todos created."""
+ self.assertTrue(Todo.objects.count() == 20)
+
def test_todo_has_attributes(self):
"""Test todo is created with attributes."""
todo1 = self.todos[0]
@@ -93,9 +97,19 @@ def test_todo_str_method_returns_username(self):
todo = Todo.objects.first()
self.assertTrue(str(todo) == todo.title)
+ def test_assign_multiple_todos_to_single_user(self):
+ """Test the many-to-one relationship between todo and user works."""
+ todo1 = Todo.objects.all()[0]
+ todo2 = Todo.objects.all()[1]
+ owner = Profile.objects.first()
+ todo1.user, todo2.user = owner, owner
+ todo1.save()
+ todo2.save()
+ self.assertTrue(Profile.todo.count() == 2)
+
class TodoFrontEndTestCase(TestCase):
- """The User Model test class."""
+ """The Todo route and view test class."""
def setUp(self):
"""The setup and buildout for users, todos."""
@@ -136,3 +150,11 @@ def test_todo_detail_route_uses_right_templates(self):
response = self.client.get('/profile/todo/' + str(todo.pk))
self.assertTemplateUsed(response, "neuropy/layout.html")
self.assertTemplateUsed(response, "todo/detail_todo.html")
+
+ def test_edit_todo_default_values(self):
+ """Test that the response when calling the edit todo views includes default values."""
+ todo = self.todos[0]
+ response = self.client.get(reverse_lazy(
+ 'todo:edit_todo', kwargs={'pk': todo.id})
+ )
+ self.assertTrue('Edit a To-Do item' in response.content.decode())
diff --git a/neuropy/todo/views.py b/neuropy/todo/views.py
index 5d6b419..f92abdf 100644
--- a/neuropy/todo/views.py
+++ b/neuropy/todo/views.py
@@ -24,7 +24,7 @@ class AddTodo(LoginRequiredMixin, CreateView):
form_class = TodoForm
- success_url = reverse_lazy('todo:list_todo')
+ success_url = reverse_lazy('list_todo')
def form_valid(self, form):
"""Form should update the photographer to the user."""
@@ -45,7 +45,7 @@ class EditTodo(LoginRequiredMixin, UpdateView):
form_class = TodoForm
- success_url = reverse_lazy('todo:list_todo')
+ success_url = reverse_lazy('list_todo')
class ListTodo(LoginRequiredMixin, ListView):
From 19f6c6d2d6a9472c23886fb782d6da526471b159 Mon Sep 17 00:00:00 2001
From: Amos Boldor
Date: Tue, 14 Feb 2017 18:32:30 -0800
Subject: [PATCH 107/249] add functions for getting, adding and updateing users
calendar
---
neuropy/neuropy/settings.py | 8 ++++----
neuropy/neuropy/urls.py | 2 ++
neuropy/todo/views.py | 25 +++++++++++++++++++++++++
neuropy/userprofile/views.py | 1 -
4 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/neuropy/neuropy/settings.py b/neuropy/neuropy/settings.py
index 55b9f74..6a998e4 100644
--- a/neuropy/neuropy/settings.py
+++ b/neuropy/neuropy/settings.py
@@ -83,10 +83,10 @@
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'neuropy',
- 'USER': os.environ.get("USER_NAME", ''),
- 'PASSWORD': os.environ.get('DATABASE_PASSWORD', ''),
- 'HOST': '127.0.0.1',
- 'PORT': '5432',
+ # 'USER': os.environ.get("USER_NAME", ''),
+ # 'PASSWORD': os.environ.get('DATABASE_PASSWORD', ''),
+ # 'HOST': '127.0.0.1',
+ # 'PORT': '5432',
'TEST': {
'NAME': 'test_neuropy'
}
diff --git a/neuropy/neuropy/urls.py b/neuropy/neuropy/urls.py
index 7fd64da..000393b 100644
--- a/neuropy/neuropy/urls.py
+++ b/neuropy/neuropy/urls.py
@@ -19,9 +19,11 @@
from django.views.generic import TemplateView
from registration.backends.hmac.views import RegistrationView
from registration.forms import RegistrationFormTermsOfService
+import oauth2client.contrib.django_util.site as django_util_site
urlpatterns = [
+ url(r'^oauth2/', include(django_util_site.urls)),
url(r'^admin/', admin.site.urls),
url(r'^$', TemplateView.as_view(template_name="neuropy/home.html"),
name='home'),
diff --git a/neuropy/todo/views.py b/neuropy/todo/views.py
index f92abdf..11a78de 100644
--- a/neuropy/todo/views.py
+++ b/neuropy/todo/views.py
@@ -11,6 +11,8 @@
from todo.forms import TodoForm
from userprofile.models import Profile
from django.shortcuts import get_object_or_404
+from apiclient import discovery
+import datetime
class AddTodo(LoginRequiredMixin, CreateView):
@@ -75,3 +77,26 @@ def test_func(self):
"""Override the userpassestest test_func."""
todo = get_object_or_404(Todo, id=self.kwargs['pk'])
return todo.owner.user == self.request.user
+
+
+def calendar_get(http, now=datetime.datetime.utcnow().isoformat() + 'Z'):
+ """Get and return users calendar."""
+ service = discovery.build('calendar', 'v3', http=http)
+ events_result = service.events().list(
+ calendarId='primary', timeMin=now, singleEvents=True,
+ orderBy='startTime').execute()
+ return events_result.get('items', [])
+
+
+def calender_insert(http, event):
+ """Insert entries and calender."""
+ service = discovery.build('calendar', 'v3', http=http)
+ event = service.events().insert(calendarId='prmary', body=event).execute()
+ return event
+
+
+def calender_update(http, event):
+ """Insert entries and calender."""
+ service = discovery.build('calendar', 'v3', http=http)
+ event = service.events().update(calendarId='prmary', body=event).execute()
+ return event
diff --git a/neuropy/userprofile/views.py b/neuropy/userprofile/views.py
index 10bf0e9..be26f37 100644
--- a/neuropy/userprofile/views.py
+++ b/neuropy/userprofile/views.py
@@ -4,7 +4,6 @@
from django.http import HttpResponseRedirect
from django.urls import reverse_lazy
from django.views.generic import DetailView, UpdateView
-
from userprofile.forms import ProfileForm
from userprofile.models import Profile
From d7aa6d257f670e785bf3b8b6480746495efc784a Mon Sep 17 00:00:00 2001
From: Amos Boldor
Date: Tue, 14 Feb 2017 18:51:33 -0800
Subject: [PATCH 108/249] fix some tests and view
---
neuropy/todo/tests.py | 13 +++++++------
neuropy/todo/views.py | 2 +-
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/neuropy/todo/tests.py b/neuropy/todo/tests.py
index 0a73490..18b5a72 100644
--- a/neuropy/todo/tests.py
+++ b/neuropy/todo/tests.py
@@ -99,13 +99,13 @@ def test_todo_str_method_returns_username(self):
def test_assign_multiple_todos_to_single_user(self):
"""Test the many-to-one relationship between todo and user works."""
- todo1 = Todo.objects.all()[0]
- todo2 = Todo.objects.all()[1]
- owner = Profile.objects.first()
- todo1.user, todo2.user = owner, owner
+ todo1 = self.todos[4]
+ todo2 = self.todos[5]
+ owner = self.users[6].profile
+ todo1.owner, todo2.owner = owner, owner
todo1.save()
todo2.save()
- self.assertTrue(Profile.todo.count() == 2)
+ self.assertTrue(owner.todo.count() == 2)
class TodoFrontEndTestCase(TestCase):
@@ -154,7 +154,8 @@ def test_todo_detail_route_uses_right_templates(self):
def test_edit_todo_default_values(self):
"""Test that the response when calling the edit todo views includes default values."""
todo = self.todos[0]
+ self.client.force_login(self.users[0])
response = self.client.get(reverse_lazy(
- 'todo:edit_todo', kwargs={'pk': todo.id})
+ 'edit_todo', kwargs={'pk': todo.id})
)
self.assertTrue('Edit a To-Do item' in response.content.decode())
diff --git a/neuropy/todo/views.py b/neuropy/todo/views.py
index 11a78de..1919c09 100644
--- a/neuropy/todo/views.py
+++ b/neuropy/todo/views.py
@@ -43,7 +43,7 @@ class EditTodo(LoginRequiredMixin, UpdateView):
login_required = True
model = Todo
- template_name = "todo/add_todo.html"
+ template_name = "todo/edit_todo.html"
form_class = TodoForm
From fa9b05f5e3739c5dd48a48a8024805fdeb964a4f Mon Sep 17 00:00:00 2001
From: Amos Boldor
Date: Tue, 14 Feb 2017 18:56:23 -0800
Subject: [PATCH 109/249] uncomment settings
---
neuropy/neuropy/settings.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/neuropy/neuropy/settings.py b/neuropy/neuropy/settings.py
index 6a998e4..55b9f74 100644
--- a/neuropy/neuropy/settings.py
+++ b/neuropy/neuropy/settings.py
@@ -83,10 +83,10 @@
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'neuropy',
- # 'USER': os.environ.get("USER_NAME", ''),
- # 'PASSWORD': os.environ.get('DATABASE_PASSWORD', ''),
- # 'HOST': '127.0.0.1',
- # 'PORT': '5432',
+ 'USER': os.environ.get("USER_NAME", ''),
+ 'PASSWORD': os.environ.get('DATABASE_PASSWORD', ''),
+ 'HOST': '127.0.0.1',
+ 'PORT': '5432',
'TEST': {
'NAME': 'test_neuropy'
}
From 6b9ba59f1e577729e7370be56fdf1758b8460a75 Mon Sep 17 00:00:00 2001
From: Amos Boldor
Date: Tue, 14 Feb 2017 19:06:41 -0800
Subject: [PATCH 110/249] add tests for profile views
---
neuropy/userprofile/tests.py | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/neuropy/userprofile/tests.py b/neuropy/userprofile/tests.py
index 266108d..6516356 100644
--- a/neuropy/userprofile/tests.py
+++ b/neuropy/userprofile/tests.py
@@ -83,8 +83,10 @@ class FrontendTestCases(TestCase):
def setUp(self):
"""Set up client and request factory."""
+ add_user_group()
self.client = Client()
self.request = RequestFactory()
+ self.users = [UserFactory.create() for i in range(20)]
def make_user_and_login(self):
"""Make user and login."""
@@ -220,3 +222,19 @@ def test_edit_will_redirect_to_profile(self):
"dose_time": "09:00:00"
})
self.assertRedirects(response, '/profile/')
+
+ def test_profile_templates(self):
+ """Test the profile templates are correct."""
+ self.client.force_login(self.users[0])
+ response = self.client.get(reverse_lazy('profile'))
+ self.assertTemplateUsed(response, "neuropy/base.html")
+ self.assertTemplateUsed(response, "neuropy/layout.html")
+ self.assertTemplateUsed(response, "userprofile/profile.html")
+
+ def test_edit_profile_templates(self):
+ """Test the edit profile templates are correct."""
+ self.client.force_login(self.users[0])
+ response = self.client.get(reverse_lazy('edit-profile'))
+ self.assertTemplateUsed(response, "neuropy/base.html")
+ self.assertTemplateUsed(response, "neuropy/layout.html")
+ self.assertTemplateUsed(response, "userprofile/edit_profile.html")
From 64ad26104f647c14c3f5b4aea0bdce0960744e51 Mon Sep 17 00:00:00 2001
From: Amos Boldor
Date: Tue, 14 Feb 2017 19:22:14 -0800
Subject: [PATCH 111/249] add tests for CredentialsModel
---
neuropy/userprofile/tests.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/neuropy/userprofile/tests.py b/neuropy/userprofile/tests.py
index 6516356..ee9849e 100644
--- a/neuropy/userprofile/tests.py
+++ b/neuropy/userprofile/tests.py
@@ -2,7 +2,7 @@
from django.test import TestCase, Client, RequestFactory
from django.contrib.auth.models import User, Group, Permission
-from userprofile.models import Profile
+from userprofile.models import Profile, CredentialsModel
import factory
from django.core.urlresolvers import reverse_lazy
@@ -77,6 +77,14 @@ def test_profile_has_attributes(self):
for attribute in attributes:
self.assertTrue(hasattr(user.profile, attribute))
+ def test_credentials_model_has_user_id_attribute(self):
+ """Test Credentials Model has user_id attribute."""
+ self.assertTrue(hasattr(CredentialsModel, 'user_id'))
+
+ def test_credentials_model_has_credential_attribute(self):
+ """Test Credentials Model has credential attribute."""
+ self.assertTrue(hasattr(CredentialsModel, 'credential'))
+
class FrontendTestCases(TestCase):
"""Test the frontend of the imager_profile site."""
From 68c8f8daa7f406e94564858dd95fd7d7b3e90d4f Mon Sep 17 00:00:00 2001
From: Amos Boldor
Date: Tue, 14 Feb 2017 19:39:11 -0800
Subject: [PATCH 112/249] add test for todo list view
---
neuropy/todo/tests.py | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/neuropy/todo/tests.py b/neuropy/todo/tests.py
index 18b5a72..4d4d7f6 100644
--- a/neuropy/todo/tests.py
+++ b/neuropy/todo/tests.py
@@ -7,6 +7,7 @@
from todo.models import Todo
from userprofile.models import Profile
import factory
+from bs4 import BeautifulSoup
class TodoFactory(factory.django.DjangoModelFactory):
@@ -159,3 +160,14 @@ def test_edit_todo_default_values(self):
'edit_todo', kwargs={'pk': todo.id})
)
self.assertTrue('Edit a To-Do item' in response.content.decode())
+
+ def test_todo_list_route_displays_correctly(self):
+ """Test todo list route displays correctly."""
+ self.client.force_login(self.users[0])
+ user = self.users[0]
+ todo = self.todos[3]
+ todo.owner = user.profile
+ todo.save()
+ response = self.client.get(reverse_lazy("list_todo"))
+ parsed_html = BeautifulSoup(response.content, 'html5lib')
+ self.assertTrue(len(parsed_html.find_all('article')) == 1)
From cbe0eaa6dd43e587f44d15678cc11c85572be825 Mon Sep 17 00:00:00 2001
From: Your Name
Date: Wed, 15 Feb 2017 09:15:05 -0800
Subject: [PATCH 113/249] medication models and .json updated after algorithm
sudo.
---
neuropy/medication/fixtures/medication.json | 40 ++++++++++++++++++---
neuropy/medication/models.py | 17 +++++++--
2 files changed, 50 insertions(+), 7 deletions(-)
diff --git a/neuropy/medication/fixtures/medication.json b/neuropy/medication/fixtures/medication.json
index 0a4b8b9..9046946 100644
--- a/neuropy/medication/fixtures/medication.json
+++ b/neuropy/medication/fixtures/medication.json
@@ -8,7 +8,13 @@
"treating_dis":"ADD/ADHD",
"half_life":"03:30:00",
"ramp_up":"03:30:00",
- "peak_period":"07:00:00"
+ "peak_period":"04:30:00",
+ "easy_start":"0:00:00",
+ "easy_end":"16:00:00",
+ "medium_start":"03:30:00",
+ "medium_end":"12:00:00",
+ "peak_start":"05:00:00",
+ "peak_end":"09:30:00",
}
},
{
@@ -20,7 +26,13 @@
"treating_dis":"ADD/ADHD",
"half_life":"10:00:00",
"ramp_up":"07:00:00",
- "peak_period":"04:00:00"
+ "peak_period":"04:00:00",
+ "easy_start":"0:00:00",
+ "easy_end":"16:00:00",
+ "medium_start":"03:30:00",
+ "medium_end":"12:00:00",
+ "peak_start":"05:00:00",
+ "peak_end":"09:30:00",
}
},
{
@@ -32,7 +44,13 @@
"treating_dis":"ADD/ADHD",
"half_life":"07:00:00",
"ramp_up":"06:30:00",
- "peak_period":"06:00:00"
+ "peak_period":"06:00:00",
+ "easy_start":"00:00:00",
+ "easy_end":"16:00:00",
+ "medium_start":"00:45:00",
+ "medium_end":"11:00:00",
+ "peak_start":"01:30:00",
+ "peak_end":"08:0=0:00",
}
},
{
@@ -44,7 +62,13 @@
"treating_dis":"ADD/ADHD",
"half_life":"03:30:00",
"ramp_up":"07:00:00",
- "peak_period":"06:00:00"
+ "peak_period":"06:00:00",
+ "easy_start":"0:00:00",
+ "easy_end":"16:00:00",
+ "medium_start":"03:30:00",
+ "medium_end":"12:00:00",
+ "peak_start":"05:00:00",
+ "peak_end":"09:30:00",
}
},
{
@@ -56,7 +80,13 @@
"treating_dis":"ADD/ADHD",
"half_life":"11:00:00",
"ramp_up":"02:00:00",
- "peak_period":"04:00:00"
+ "peak_period":"04:00:00",
+ "easy_start":"0:00:00",
+ "easy_end":"16:00:00",
+ "medium_start":"00:45:00",
+ "medium_end":"12:00:00",
+ "peak_start":"01:15:00",
+ "peak_end":"06:45:00",
}
}
]
\ No newline at end of file
diff --git a/neuropy/medication/models.py b/neuropy/medication/models.py
index ab06773..8b9bfec 100644
--- a/neuropy/medication/models.py
+++ b/neuropy/medication/models.py
@@ -4,6 +4,7 @@
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
+from django.core.validators import validate_comma_separated_integer_list
@python_2_unicode_compatible
@@ -18,15 +19,27 @@ class Medication(models.Model):
half_life = models.DurationField()
ramp_up = models.DurationField()
peak_period = models.DurationField()
+ easy_start = models.CharField(validators=validate_comma_separated_integer_list, max_length=50)
+ easy_end = models.CharField(validators=validate_comma_separated_integer_list, max_length=50)
+ medium_start = models.CharField(validators=validate_comma_separated_interger_list, max_length=50)
+ medium_end = models.CharField(validators=validate_comma_separated_integer_list, max_length=50)
+ peak_start = models.CharField(validators=validate_comma_separated_integer_list, max_length=50)
+ peak_end = models.CharField(validators=validate_comma_separated_integer_list, max_length=50)
# Ease_priority_matrix=models.CharField
def __str__(self):
"""String representation of Medication."""
- return "name: {},med_type: {}, treating_dis: {}, half_life: {}, ramp_up: {}, peak_period: {}".format(
+ return "name: {},med_type: {}, treating_dis: {}, half_life: {}, ramp_up: {}, peak_period: {}, easy_start: {}, easy_end: {}, medium_start: {}, medium_end: {}, peak_start: {}, peak_end: {} ".format(
self.name,
self.med_type,
self.treating_dis,
self.half_life,
self.ramp_up,
- self.peak_period
+ self.peak_period,
+ self.easy_start,
+ self.easy_end,
+ self.medium_start,
+ self.medium_end,
+ self.peak_start,
+ self.peak_end,
)
From c8c6650b874140d28a0d70dcf9a1d86eb1dc198b Mon Sep 17 00:00:00 2001
From: Your Name
Date: Wed, 15 Feb 2017 09:21:42 -0800
Subject: [PATCH 114/249] fixed validator bug.
---
neuropy/medication/models.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/neuropy/medication/models.py b/neuropy/medication/models.py
index 8b9bfec..a44198c 100644
--- a/neuropy/medication/models.py
+++ b/neuropy/medication/models.py
@@ -19,12 +19,12 @@ class Medication(models.Model):
half_life = models.DurationField()
ramp_up = models.DurationField()
peak_period = models.DurationField()
- easy_start = models.CharField(validators=validate_comma_separated_integer_list, max_length=50)
- easy_end = models.CharField(validators=validate_comma_separated_integer_list, max_length=50)
- medium_start = models.CharField(validators=validate_comma_separated_interger_list, max_length=50)
- medium_end = models.CharField(validators=validate_comma_separated_integer_list, max_length=50)
- peak_start = models.CharField(validators=validate_comma_separated_integer_list, max_length=50)
- peak_end = models.CharField(validators=validate_comma_separated_integer_list, max_length=50)
+ easy_start = models.CharField(validators=[validate_comma_separated_integer_list], max_length=50)
+ easy_end = models.CharField(validators=[validate_comma_separated_integer_list], max_length=50)
+ medium_start = models.CharField(validators=[validate_comma_separated_integer_list], max_length=50)
+ medium_end = models.CharField(validators=[validate_comma_separated_integer_list], max_length=50)
+ peak_start = models.CharField(validators=[validate_comma_separated_integer_list], max_length=50)
+ peak_end = models.CharField(validators=[validate_comma_separated_integer_list], max_length=50)
# Ease_priority_matrix=models.CharField
def __str__(self):
From 258855d67eabe208ee3804cfe50992f4e33a09a6 Mon Sep 17 00:00:00 2001
From: Your Name
Date: Wed, 15 Feb 2017 10:08:47 -0800
Subject: [PATCH 115/249] migration
---
.../migrations/0003_auto_20170215_0925.py | 58 +++++++++++++++++++
1 file changed, 58 insertions(+)
create mode 100644 neuropy/medication/migrations/0003_auto_20170215_0925.py
diff --git a/neuropy/medication/migrations/0003_auto_20170215_0925.py b/neuropy/medication/migrations/0003_auto_20170215_0925.py
new file mode 100644
index 0000000..63fa5bf
--- /dev/null
+++ b/neuropy/medication/migrations/0003_auto_20170215_0925.py
@@ -0,0 +1,58 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.5 on 2017-02-15 17:25
+from __future__ import unicode_literals
+
+import django.core.validators
+from django.db import migrations, models
+import re
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('medication', '0002_auto_20170213_1612'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='medication',
+ name='easy_end',
+ field=models.CharField(default='', max_length=50, validators=[django.core.validators.RegexValidator(re.compile('^\\d+(?:\\,\\d+)*\\Z', 32), code='invalid', message='Enter only digits separated by commas.')]),
+ preserve_default=False,
+ ),
+ migrations.AddField(
+ model_name='medication',
+ name='easy_start',
+ field=models.CharField(default='', max_length=50, validators=[django.core.validators.RegexValidator(re.compile('^\\d+(?:\\,\\d+)*\\Z', 32), code='invalid', message='Enter only digits separated by commas.')]),
+ preserve_default=False,
+ ),
+ migrations.AddField(
+ model_name='medication',
+ name='medium_end',
+ field=models.CharField(default='', max_length=50, validators=[django.core.validators.RegexValidator(re.compile('^\\d+(?:\\,\\d+)*\\Z', 32), code='invalid', message='Enter only digits separated by commas.')]),
+ preserve_default=False,
+ ),
+ migrations.AddField(
+ model_name='medication',
+ name='medium_start',
+ field=models.CharField(default='', max_length=50, validators=[django.core.validators.RegexValidator(re.compile('^\\d+(?:\\,\\d+)*\\Z', 32), code='invalid', message='Enter only digits separated by commas.')]),
+ preserve_default=False,
+ ),
+ migrations.AddField(
+ model_name='medication',
+ name='peak_end',
+ field=models.CharField(default='', max_length=50, validators=[django.core.validators.RegexValidator(re.compile('^\\d+(?:\\,\\d+)*\\Z', 32), code='invalid', message='Enter only digits separated by commas.')]),
+ preserve_default=False,
+ ),
+ migrations.AddField(
+ model_name='medication',
+ name='peak_start',
+ field=models.CharField(default='', max_length=50, validators=[django.core.validators.RegexValidator(re.compile('^\\d+(?:\\,\\d+)*\\Z', 32), code='invalid', message='Enter only digits separated by commas.')]),
+ preserve_default=False,
+ ),
+ migrations.AlterField(
+ model_name='medication',
+ name='half_life',
+ field=models.DurationField(),
+ ),
+ ]
From 61ab2e38fe5a90a8170b53a0b34cbb6524cc1edf Mon Sep 17 00:00:00 2001
From: Your Name
Date: Wed, 15 Feb 2017 10:54:20 -0800
Subject: [PATCH 116/249] README formatting.
---
.gitignore | 7 +++++++
README.md | 10 ++++++----
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/.gitignore b/.gitignore
index adb7f0d..b015f41 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,6 +24,13 @@ var/
.installed.cfg
*.egg
neuroEnv/
+.DS_Store
+bin/
+man/
+medication/
+pip-selfcheck.json
+pyvenv.cfg
+share/
# PyInstaller
# Usually these files are written by a python script from a template
diff --git a/README.md b/README.md
index 8c365c3..aed1e3b 100644
--- a/README.md
+++ b/README.md
@@ -1,17 +1,19 @@
# NeuroPy
Personalized CBT-based priority planner
-Creators:
+## Creators:
-Amos Bolder Claire Gatenby Patrick Saunders Sera Smith
+Amos Bolder | Claire Gatenby | Patrick Saunders | Sera Smith
-URL: http://
+### URL: http://
+### About the App:
A personalized priority app to support a *Cognitive Behavioral Therapy* (CBT) approach to efficiently organize your day according to a struggle/disorder that is effectively treated by CBT. CBT is a goal-oriented pyschotherapy treatment, taking a hands-on approach to problem solving. Goal of CBT is to change the patterns of thinking or behavior that are behind a person's difficulties, modifying their feelings and therefore their thinking and behavior overtime.
*Neuropy* Considers what the habit/disorder the user wants to treat with CBT, along with medication, it's half-life and peak periods. Also works around black-out periods on user's schedule by syncing with Google Calender, personal preference or most productive period of the day for user, and finally considers time commitments for each activity. Each "TO-DO" will be ranked considering these aspects and will be worked into periods of the day.
-version-0.1 (in active development) Keywords:
+##### version-0.1 (in active development)
+##### Keywords:
No medical data is stored by NeuroPy
From 1eb9e71b078697df7203692c47b2084692a4f189 Mon Sep 17 00:00:00 2001
From: Your Name
Date: Wed, 15 Feb 2017 10:54:45 -0800
Subject: [PATCH 117/249] minor typo
---
README.md | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/README.md b/README.md
index aed1e3b..b495503 100644
--- a/README.md
+++ b/README.md
@@ -25,23 +25,23 @@ https://github.com/NeuroPyPlanner/NeuroPy.git
```
Assuming that you have access to Python 3 at the system level, start up a new virtual environment.
```
-$ cd django-imager
+$ cd NeuroPy
$ python3 -m venv ENV
$ source ENV/bin/activate
```
Once your environment has been activated, make sure to install Django and all of this project's required packages.
```
-(django-imager) $ pip install -r requirements.pip
+(NeuroPy) $ pip install -r requirements.pip
```
Navigate to the project root, imagersite, and apply the migrations for the app.
```
-(django-imager) $ cd imagersite
+(NeuroPy) $ cd imagersite
-(django-imager) $ ./manage.py migrate
+(NeuroPy) $ ./manage.py migrate
```
Finally, run the server in order to server the app on localhost
```
-(django-imager) $ ./manage.py runserver
+(NeuroPy) $ ./manage.py runserver
```
Django will typically serve on port 8000, unless you specify otherwise. You can access the locally-served site at the address http://localhost:8000.
@@ -87,13 +87,13 @@ This application allow users to store and organize photos.
##Running Tests
-Running tests for the django-imager is fairly straightforward. Navigate to the same directory as the manage.py file and type:
+Running tests for the NeuroPy is fairly straightforward. Navigate to the same directory as the manage.py file and type:
```
-(django-imager) $ coverage run manage.py test
+(NeuroPy) $ coverage run manage.py test
```
This will show you which tests have failed, which tests have passed. If you'd like a report of the actual coverage of your tests, type
```
-(django-imager) $ coverage report
+(NeuroPy) $ coverage report
```
This will read from the included .coverage file, with configuration set in the .coveragerc file. Currently the configuration will show which lines were missing from the test coverage.
@@ -123,4 +123,3 @@ This will read from the included .coverage file, with configuration set in the .
- As a developer I want a narrow open source license so that we retain plenty of rights to our work.
- As a developer I want to write an algorithm that prioritises todos based on a user’s profile.
- As a developer I want to integrate the google calendars with my app using an api.
-
From 127737c5787c920d0c41b510488a85ce45aa732a Mon Sep 17 00:00:00 2001
From: Your Name
Date: Wed, 15 Feb 2017 11:04:27 -0800
Subject: [PATCH 118/249] .gitignore.
---
.gitignore | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/.gitignore b/.gitignore
index 72364f9..4cf9978 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,6 +23,12 @@ var/
*.egg-info/
.installed.cfg
*.egg
+bin/
+man/
+pip-selfcheck.json
+pyvenv.cfg
+share/
+.DS_Store
# PyInstaller
# Usually these files are written by a python script from a template
From ee11b7a5d054c6257ab430d33981efb5e321e99e Mon Sep 17 00:00:00 2001
From: pasaunders
Date: Wed, 15 Feb 2017 11:39:43 -0800
Subject: [PATCH 119/249] mid-debugging, adding a radio button form to user
profile
---
neuropy/todo/forms.py | 1 -
neuropy/userprofile/forms.py | 26 +++++++++++++++++++
.../templates/userprofile/profile.html | 6 +++++
neuropy/userprofile/urls.py | 5 ++--
neuropy/userprofile/views.py | 14 ++++++++--
5 files changed, 47 insertions(+), 5 deletions(-)
diff --git a/neuropy/todo/forms.py b/neuropy/todo/forms.py
index 664e30f..8253c66 100644
--- a/neuropy/todo/forms.py
+++ b/neuropy/todo/forms.py
@@ -23,7 +23,6 @@ def __init__(self, *args, **kwargs):
(2, 'Medium'),
(3, 'Difficult'),
)
- # import pdb; pdb.set_trace()
self.fields['title'] = forms.CharField(initial=self.instance.title)
self.fields['description'] = forms.CharField(widget=forms.Textarea, initial=self.instance.description)
self.fields['date'] = forms.DateField(widget=forms.SelectDateWidget(), initial=self.instance.date)
diff --git a/neuropy/userprofile/forms.py b/neuropy/userprofile/forms.py
index ca1690c..d41288d 100644
--- a/neuropy/userprofile/forms.py
+++ b/neuropy/userprofile/forms.py
@@ -2,6 +2,7 @@
from django import forms
from userprofile.models import Profile
+from medication.models import Medication
class ProfileForm(forms.ModelForm):
@@ -23,3 +24,28 @@ class Meta:
model = Profile
exclude = []
+
+
+class MedicationForm(forms.ModelForm):
+ """Create a form allowing the user to base the schedule on a medication."""
+
+ def __init__(self, *args, **kwargs):
+ """Set up form fields."""
+ MEDICATION_CHOICES = (
+ ("CONCERTA", "Concerta"),
+ ("ADDERALL", "Adderall"),
+ ("FOCALIN", "Focalin"),
+ ("Ritalin LA", "Ritalin LA"),
+ ("Vyvanse", "Vyvanse")
+ )
+ super(ProfileForm, self).__init__(*args, **kwargs)
+ self.fields["Medication: "] = forms.ChoiceField(
+ widget=forms.RadioSelect,
+ choices=MEDICATION_CHOICES,
+ )
+
+ class Meta:
+ """Model for form and fields to exclude."""
+
+ model = Medication
+ exclude = []
\ No newline at end of file
diff --git a/neuropy/userprofile/templates/userprofile/profile.html b/neuropy/userprofile/templates/userprofile/profile.html
index 92ac24c..d7d7952 100644
--- a/neuropy/userprofile/templates/userprofile/profile.html
+++ b/neuropy/userprofile/templates/userprofile/profile.html
@@ -21,4 +21,10 @@
Welcome {{user.username}}!
Peak Period: {{ user.profile.peak_period }}
Dose Time: {{ user.profile.dose_time }}
+
+ {% csrf_token %}
+ {{ form.as_p }}
+
+
{% endblock %}
+g
\ No newline at end of file
diff --git a/neuropy/userprofile/urls.py b/neuropy/userprofile/urls.py
index 3c8672e..e2ec816 100644
--- a/neuropy/userprofile/urls.py
+++ b/neuropy/userprofile/urls.py
@@ -1,8 +1,9 @@
"""Profile urls."""
from django.conf.urls import url
-from .views import ProfileView, EditProfile
+from .views import ProfileView, EditProfile, ProfileFormView
urlpatterns = [
url(r'^edit/$', EditProfile.as_view(), name='edit-profile'),
- url(r'^$', ProfileView.as_view(), name='profile')
+ url(r'^$', ProfileView.as_view(), name='profile'),
+ url(r'submission_form/$', require_POST(ProfileFormView.as_view()), name='profile_form')
]
diff --git a/neuropy/userprofile/views.py b/neuropy/userprofile/views.py
index be26f37..01fab22 100644
--- a/neuropy/userprofile/views.py
+++ b/neuropy/userprofile/views.py
@@ -3,8 +3,8 @@
from django.contrib.auth.mixins import LoginRequiredMixin
from django.http import HttpResponseRedirect
from django.urls import reverse_lazy
-from django.views.generic import DetailView, UpdateView
-from userprofile.forms import ProfileForm
+from django.views.generic import DetailView, UpdateView, FormView
+from userprofile.forms import ProfileForm, MedicationForm
from userprofile.models import Profile
@@ -16,10 +16,20 @@ class ProfileView(LoginRequiredMixin, DetailView):
template_name = 'userprofile/profile.html'
slug_field = 'id'
+ def get_context_data(self, **kwargs):
+ context = super(ProfileView, self).get_context_data(**kwargs)
+ context['form'] = MedicationForm
+ return context
+
def get_object(self):
"""Return logged in user."""
return self.request.user
+class ProfileFormView(LoginRequiredMixin, FormView):
+ """Form view for reference by profile view so we can include a form."""
+ form_class = MedicationForm
+ success_url = reverse_lazy('profile')
+
class EditProfile(LoginRequiredMixin, UpdateView):
"""Edit users profile."""
From a9ca239f880aaf0fb2caf8086f77f4958389fff0 Mon Sep 17 00:00:00 2001
From: CLAIRE GATENBY
Date: Wed, 15 Feb 2017 11:58:14 -0800
Subject: [PATCH 120/249] updated the medication form class to inhert from
basic form
---
neuropy/userprofile/forms.py | 34 ++++++++++++++--------------------
1 file changed, 14 insertions(+), 20 deletions(-)
diff --git a/neuropy/userprofile/forms.py b/neuropy/userprofile/forms.py
index d41288d..cebcda4 100644
--- a/neuropy/userprofile/forms.py
+++ b/neuropy/userprofile/forms.py
@@ -26,26 +26,20 @@ class Meta:
exclude = []
-class MedicationForm(forms.ModelForm):
- """Create a form allowing the user to base the schedule on a medication."""
- def __init__(self, *args, **kwargs):
- """Set up form fields."""
- MEDICATION_CHOICES = (
- ("CONCERTA", "Concerta"),
- ("ADDERALL", "Adderall"),
- ("FOCALIN", "Focalin"),
- ("Ritalin LA", "Ritalin LA"),
- ("Vyvanse", "Vyvanse")
- )
- super(ProfileForm, self).__init__(*args, **kwargs)
- self.fields["Medication: "] = forms.ChoiceField(
- widget=forms.RadioSelect,
- choices=MEDICATION_CHOICES,
- )
- class Meta:
- """Model for form and fields to exclude."""
+class MedicationForm(forms.Form):
+ """Create a form allowing the user to base the schedule on a medication."""
- model = Medication
- exclude = []
\ No newline at end of file
+ MEDICATION_CHOICES = (
+ ("CONCERTA", "Concerta"),
+ ("ADDERALL", "Adderall"),
+ ("FOCALIN", "Focalin"),
+ ("Ritalin LA", "Ritalin LA"),
+ ("Vyvanse", "Vyvanse")
+ )
+
+ medication = forms.ChoiceField(
+ widget=forms.RadioSelect,
+ choices=MEDICATION_CHOICES,
+ )
From 1c0e53e1bed58d3b8bdf19e7c086bc0a6149d88c Mon Sep 17 00:00:00 2001
From: CLAIRE GATENBY
Date: Wed, 15 Feb 2017 11:58:33 -0800
Subject: [PATCH 121/249] fixed a typo
---
neuropy/userprofile/templates/userprofile/profile.html | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/neuropy/userprofile/templates/userprofile/profile.html b/neuropy/userprofile/templates/userprofile/profile.html
index d7d7952..0c3df6a 100644
--- a/neuropy/userprofile/templates/userprofile/profile.html
+++ b/neuropy/userprofile/templates/userprofile/profile.html
@@ -26,5 +26,4 @@