diff --git a/.gitignore b/.gitignore index 8ee7f16..61132ee 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,21 @@ ### Python Files ### *.pyc +### Environments ### +djangoenv +djangoEnv +DjangoEnv +flaskenv +flaskEnv +FlaskEnv +venv +denv +env + ### Workspace Files ### *.idea *.vscode +*.sublime-workspace ### System Files ### .DS_Store @@ -11,4 +23,11 @@ Thumbs.db ehthumbs.db ehthumbs_vista.db Desktop.ini -$RECYCLE.BIN/ \ No newline at end of file +$RECYCLE.BIN/ + +### Compressed Files ### +*.zip +*.7z +*.rar +*.gzip +*.gz diff --git a/jessica_hart/Django/session_words/apps/__init__.py b/jessica_hart/Django/session_words/apps/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/jessica_hart/Django/session_words/apps/main_app/__init__.py b/jessica_hart/Django/session_words/apps/main_app/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/jessica_hart/Django/session_words/apps/main_app/admin.py b/jessica_hart/Django/session_words/apps/main_app/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/jessica_hart/Django/session_words/apps/main_app/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/jessica_hart/Django/session_words/apps/main_app/apps.py b/jessica_hart/Django/session_words/apps/main_app/apps.py new file mode 100644 index 0000000..feab95d --- /dev/null +++ b/jessica_hart/Django/session_words/apps/main_app/apps.py @@ -0,0 +1,7 @@ +from __future__ import unicode_literals + +from django.apps import AppConfig + + +class MainAppConfig(AppConfig): + name = 'main_app' diff --git a/jessica_hart/Django/session_words/apps/main_app/migrations/__init__.py b/jessica_hart/Django/session_words/apps/main_app/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/jessica_hart/Django/session_words/apps/main_app/models.py b/jessica_hart/Django/session_words/apps/main_app/models.py new file mode 100644 index 0000000..bd4b2ab --- /dev/null +++ b/jessica_hart/Django/session_words/apps/main_app/models.py @@ -0,0 +1,5 @@ +from __future__ import unicode_literals + +from django.db import models + +# Create your models here. diff --git a/jessica_hart/Django/session_words/apps/main_app/static/main_app/style.css b/jessica_hart/Django/session_words/apps/main_app/static/main_app/style.css new file mode 100644 index 0000000..aabbaac --- /dev/null +++ b/jessica_hart/Django/session_words/apps/main_app/static/main_app/style.css @@ -0,0 +1,17 @@ +/* Class for big fonts */ +.big_font { + font-size: 25px; +} + +/* Classes that match the color radio button values */ +.red { + color: red; +} + +.green { + color: green; +} + +.blue { + color: blue; +} diff --git a/jessica_hart/Django/session_words/apps/main_app/templates/main_app/index.html b/jessica_hart/Django/session_words/apps/main_app/templates/main_app/index.html new file mode 100644 index 0000000..8a9187d --- /dev/null +++ b/jessica_hart/Django/session_words/apps/main_app/templates/main_app/index.html @@ -0,0 +1,37 @@ + + + + + Session Words + + {% load static %} + + + + +

Add a new word

+ +
+ + {% csrf_token %} + + + + + + + show in BIG fonts! + +
+ Clear Session + + + \ No newline at end of file diff --git a/jessica_hart/Django/session_words/apps/main_app/tests.py b/jessica_hart/Django/session_words/apps/main_app/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/jessica_hart/Django/session_words/apps/main_app/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/jessica_hart/Django/session_words/apps/main_app/urls.py b/jessica_hart/Django/session_words/apps/main_app/urls.py new file mode 100644 index 0000000..6524238 --- /dev/null +++ b/jessica_hart/Django/session_words/apps/main_app/urls.py @@ -0,0 +1,7 @@ +from django.conf.urls import url +from . import views +urlpatterns = [ + url(r'^$', views.index), + url(r'^add_word$', views.add_word), + url(r'^clear$', views.clear) +] \ No newline at end of file diff --git a/jessica_hart/Django/session_words/apps/main_app/views.py b/jessica_hart/Django/session_words/apps/main_app/views.py new file mode 100644 index 0000000..367152a --- /dev/null +++ b/jessica_hart/Django/session_words/apps/main_app/views.py @@ -0,0 +1,46 @@ +from django.shortcuts import render, HttpResponse, redirect +# Import required to use datetime +from datetime import datetime + +def index(request): + # If no word list is in session, create empty array to append them into + if 'words' not in request.session: + request.session['words'] = [] + + return render(request, "main_app/index.html") + +def add_word(request): + # Set size to empty unless checkbox was selected + size = '' + if 'big_font' in request.POST: + size = 'big_font' + + # Set color to empty unless a radio button was selected + color = '' + if 'color' in request.POST: + color = request.POST['color'] + + # Gets the current time and formats it into a string + # See http://strftime.org/ or https://www.foragoodstrftime.com/ for more info + # Note the datetime import at top + date = datetime.now().strftime("%I:%M:%S%p, %B %e, %Y") + + # Collect data on word and enter into dictionary + word = { + 'word': request.POST['word'], + 'color': color, + 'size': size, + 'created_at': date + } + + # Can't append word into request.session directly + temp = request.session['words'] + temp.append(word) + request.session['words'] = temp + + return redirect(index) + +def clear(request): + # Clear the session of the entire word list + del request.session['words'] + return redirect(index) \ No newline at end of file diff --git a/jessica_hart/Django/session_words/db.sqlite3 b/jessica_hart/Django/session_words/db.sqlite3 new file mode 100644 index 0000000..e03cc4d Binary files /dev/null and b/jessica_hart/Django/session_words/db.sqlite3 differ diff --git a/jessica_hart/Django/session_words/manage.py b/jessica_hart/Django/session_words/manage.py new file mode 100755 index 0000000..fe8c8a4 --- /dev/null +++ b/jessica_hart/Django/session_words/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "session_words.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/jessica_hart/Django/session_words/session_words/__init__.py b/jessica_hart/Django/session_words/session_words/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/jessica_hart/Django/session_words/session_words/settings.py b/jessica_hart/Django/session_words/session_words/settings.py new file mode 100644 index 0000000..153f6e7 --- /dev/null +++ b/jessica_hart/Django/session_words/session_words/settings.py @@ -0,0 +1,121 @@ +""" +Django settings for session_words project. + +Generated by 'django-admin startproject' using Django 1.10. + +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 = 'hoa@46(y9xwwimts(lc(o#+31m-^$kwn#@yzkqj(=u@e5pk=%n' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'apps.main_app', + '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 = 'session_words.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 = 'session_words.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/jessica_hart/Django/session_words/session_words/urls.py b/jessica_hart/Django/session_words/session_words/urls.py new file mode 100644 index 0000000..3a9dd0b --- /dev/null +++ b/jessica_hart/Django/session_words/session_words/urls.py @@ -0,0 +1,7 @@ +from django.conf.urls import url, include +from django.contrib import admin +urlpatterns = [ + # Common name in routes can be entered here + # All routes in main_app will now start with "session_words/" (completely optional) + url(r'^session_words/', include('apps.main_app.urls')) +] diff --git a/jessica_hart/Django/session_words/session_words/wsgi.py b/jessica_hart/Django/session_words/session_words/wsgi.py new file mode 100644 index 0000000..e44b172 --- /dev/null +++ b/jessica_hart/Django/session_words/session_words/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for session_words 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", "session_words.settings") + +application = get_wsgi_application()