commit 6b6f5ff1f4b2f964d6a75fb72093211a3a0db724 Author: bradybodily Date: Fri Apr 27 10:12:40 2018 -0600 finished product diff --git a/.idea/cs2610hw7.iml b/.idea/cs2610hw7.iml new file mode 100644 index 0000000..267edfb --- /dev/null +++ b/.idea/cs2610hw7.iml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..c23ecac --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..0ed3b43 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..aaeaeee --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..d1e7012 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,744 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + DEFINITION_ORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1524703109530 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + file://$PROJECT_DIR$/main/templates/main/index.html + 65 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DjangoModelDependency + #cs2610hw7 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/conversion/__init__.py b/conversion/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/conversion/__pycache__/__init__.cpython-36.pyc b/conversion/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000..db37fcf Binary files /dev/null and b/conversion/__pycache__/__init__.cpython-36.pyc differ diff --git a/conversion/__pycache__/admin.cpython-36.pyc b/conversion/__pycache__/admin.cpython-36.pyc new file mode 100644 index 0000000..ea08a42 Binary files /dev/null and b/conversion/__pycache__/admin.cpython-36.pyc differ diff --git a/conversion/__pycache__/apps.cpython-36.pyc b/conversion/__pycache__/apps.cpython-36.pyc new file mode 100644 index 0000000..e778580 Binary files /dev/null and b/conversion/__pycache__/apps.cpython-36.pyc differ diff --git a/conversion/__pycache__/models.cpython-36.pyc b/conversion/__pycache__/models.cpython-36.pyc new file mode 100644 index 0000000..3800034 Binary files /dev/null and b/conversion/__pycache__/models.cpython-36.pyc differ diff --git a/conversion/__pycache__/urls.cpython-36.pyc b/conversion/__pycache__/urls.cpython-36.pyc new file mode 100644 index 0000000..721e2c9 Binary files /dev/null and b/conversion/__pycache__/urls.cpython-36.pyc differ diff --git a/conversion/__pycache__/views.cpython-36.pyc b/conversion/__pycache__/views.cpython-36.pyc new file mode 100644 index 0000000..6531e67 Binary files /dev/null and b/conversion/__pycache__/views.cpython-36.pyc differ diff --git a/conversion/admin.py b/conversion/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/conversion/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/conversion/apps.py b/conversion/apps.py new file mode 100644 index 0000000..7bf9e48 --- /dev/null +++ b/conversion/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ConversionConfig(AppConfig): + name = 'conversion' + diff --git a/conversion/migrations/0001_initial.py b/conversion/migrations/0001_initial.py new file mode 100644 index 0000000..3d35c7c --- /dev/null +++ b/conversion/migrations/0001_initial.py @@ -0,0 +1,22 @@ +# Generated by Django 2.0.2 on 2018-04-27 03:22 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Converter', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('units', models.CharField(max_length=200)), + ('value', models.FloatField()), + ], + ), + ] diff --git a/conversion/migrations/__init__.py b/conversion/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/conversion/migrations/__pycache__/0001_initial.cpython-36.pyc b/conversion/migrations/__pycache__/0001_initial.cpython-36.pyc new file mode 100644 index 0000000..c74ed69 Binary files /dev/null and b/conversion/migrations/__pycache__/0001_initial.cpython-36.pyc differ diff --git a/conversion/migrations/__pycache__/__init__.cpython-36.pyc b/conversion/migrations/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000..3dbf701 Binary files /dev/null and b/conversion/migrations/__pycache__/__init__.cpython-36.pyc differ diff --git a/conversion/models.py b/conversion/models.py new file mode 100644 index 0000000..f9eac2e --- /dev/null +++ b/conversion/models.py @@ -0,0 +1,10 @@ +from django.db import models + +# Create your models here. + +class Converter(models.Model): + units = models.CharField(max_length=200) + value = models.FloatField() + +def __str__(self): + return '%s, %f' % (self.units, self.value) \ No newline at end of file diff --git a/conversion/tests.py b/conversion/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/conversion/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/conversion/urls.py b/conversion/urls.py new file mode 100644 index 0000000..2955ccc --- /dev/null +++ b/conversion/urls.py @@ -0,0 +1,8 @@ +from django.urls import path + +from . import views + +urlpatterns = [ + path('json', views.get, name='get'), + path('', views.init, name='init'), +] \ No newline at end of file diff --git a/conversion/views.py b/conversion/views.py new file mode 100644 index 0000000..70d2893 --- /dev/null +++ b/conversion/views.py @@ -0,0 +1,32 @@ +from django.shortcuts import render +from django.http import HttpResponse +from conversion.models import Converter +import math +import json + + +# Create your views here. +def get(request): + print(request) + value = request.GET.get('value') + frm = request.GET['from'] + to = request.GET['to'] + print(value, " ", to, " ", frm) + tmp = Converter.objects.get(units=frm) + print(tmp) + total = tmp.value * float(value) + print(str(total)) + + data = {} + data['units'] = to + data['value'] = total + json_data = json.dumps(data) + print(json_data) + return HttpResponse(json_data) + +def init(request): + Converter.objects.all().delete(); + this = Converter(units='lbs', value='14.5833') + this.save() + + return HttpResponse('Data Base Initialized') diff --git a/cs2610hw7/__init__.py b/cs2610hw7/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/cs2610hw7/__pycache__/__init__.cpython-36.pyc b/cs2610hw7/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000..9a0380a Binary files /dev/null and b/cs2610hw7/__pycache__/__init__.cpython-36.pyc differ diff --git a/cs2610hw7/__pycache__/settings.cpython-36.pyc b/cs2610hw7/__pycache__/settings.cpython-36.pyc new file mode 100644 index 0000000..13bab24 Binary files /dev/null and b/cs2610hw7/__pycache__/settings.cpython-36.pyc differ diff --git a/cs2610hw7/__pycache__/urls.cpython-36.pyc b/cs2610hw7/__pycache__/urls.cpython-36.pyc new file mode 100644 index 0000000..77f0b45 Binary files /dev/null and b/cs2610hw7/__pycache__/urls.cpython-36.pyc differ diff --git a/cs2610hw7/__pycache__/wsgi.cpython-36.pyc b/cs2610hw7/__pycache__/wsgi.cpython-36.pyc new file mode 100644 index 0000000..9e0e03f Binary files /dev/null and b/cs2610hw7/__pycache__/wsgi.cpython-36.pyc differ diff --git a/cs2610hw7/settings.py b/cs2610hw7/settings.py new file mode 100644 index 0000000..ff28e9f --- /dev/null +++ b/cs2610hw7/settings.py @@ -0,0 +1,122 @@ +""" +Django settings for cs2610hw7 project. + +Generated by 'django-admin startproject' using Django 2.0.2. + +For more information on this file, see +https://docs.djangoproject.com/en/2.0/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/2.0/ref/settings/ +""" + +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = '%xq&nsb#h6gum^9m_sz$xsr9#u=-27o=nzsnx1so4$7w%#pe43' + +# 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', + 'main.apps.MainConfig', + 'conversion.apps.ConversionConfig', +] + +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 = 'cs2610hw7.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 = 'cs2610hw7.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/2.0/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/2.0/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/2.0/howto/static-files/ + +STATIC_URL = '/static/' diff --git a/cs2610hw7/urls.py b/cs2610hw7/urls.py new file mode 100644 index 0000000..f444b02 --- /dev/null +++ b/cs2610hw7/urls.py @@ -0,0 +1,26 @@ +"""cs2610hw7 URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/2.0/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import path, include + + +urlpatterns = [ + path('admin/', admin.site.urls), + path('index/', include('main.urls')), + path('conversion/', include('conversion.urls')), + path('init/', include('conversion.urls')), + +] diff --git a/cs2610hw7/wsgi.py b/cs2610hw7/wsgi.py new file mode 100644 index 0000000..940908b --- /dev/null +++ b/cs2610hw7/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for cs2610hw7 project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cs2610hw7.settings") + +application = get_wsgi_application() diff --git a/db.sqlite3 b/db.sqlite3 new file mode 100644 index 0000000..c165907 Binary files /dev/null and b/db.sqlite3 differ diff --git a/main/__init__.py b/main/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/main/__pycache__/__init__.cpython-36.pyc b/main/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000..fb610a9 Binary files /dev/null and b/main/__pycache__/__init__.cpython-36.pyc differ diff --git a/main/__pycache__/admin.cpython-36.pyc b/main/__pycache__/admin.cpython-36.pyc new file mode 100644 index 0000000..b7324bd Binary files /dev/null and b/main/__pycache__/admin.cpython-36.pyc differ diff --git a/main/__pycache__/apps.cpython-36.pyc b/main/__pycache__/apps.cpython-36.pyc new file mode 100644 index 0000000..8e7a8df Binary files /dev/null and b/main/__pycache__/apps.cpython-36.pyc differ diff --git a/main/__pycache__/models.cpython-36.pyc b/main/__pycache__/models.cpython-36.pyc new file mode 100644 index 0000000..ea3a184 Binary files /dev/null and b/main/__pycache__/models.cpython-36.pyc differ diff --git a/main/__pycache__/urls.cpython-36.pyc b/main/__pycache__/urls.cpython-36.pyc new file mode 100644 index 0000000..3ffa176 Binary files /dev/null and b/main/__pycache__/urls.cpython-36.pyc differ diff --git a/main/__pycache__/views.cpython-36.pyc b/main/__pycache__/views.cpython-36.pyc new file mode 100644 index 0000000..e8858b8 Binary files /dev/null and b/main/__pycache__/views.cpython-36.pyc differ diff --git a/main/admin.py b/main/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/main/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/main/apps.py b/main/apps.py new file mode 100644 index 0000000..833bff6 --- /dev/null +++ b/main/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class MainConfig(AppConfig): + name = 'main' diff --git a/main/migrations/__init__.py b/main/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/main/migrations/__pycache__/__init__.cpython-36.pyc b/main/migrations/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000..27c2050 Binary files /dev/null and b/main/migrations/__pycache__/__init__.cpython-36.pyc differ diff --git a/main/models.py b/main/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/main/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/main/static/main/styles.css b/main/static/main/styles.css new file mode 100644 index 0000000..b632af4 --- /dev/null +++ b/main/static/main/styles.css @@ -0,0 +1,79 @@ +#fib { + display: inline-block; +} + +.fib { + background-color: rgba(0,0,255,0.1); +} + +.fib-left { + float: left; + display: inline-block; + margin-right: 4px; +} + +.fib-right { + float: right; + display: inline-block; + margin-left: 4px; +} + +.shadowed { + text-shadow: 1px 1px 2px black; + color: white; +} + +.nice-box { + font-family: 'helvetica neue', helvetica, sans-serif; + padding: 3px 10px; + margin: 10px; + border-radius: 10px; + border-width: 2px; + border-style: solid; +} + +.flex-rows { + display: flex; + flex-direction: row; +} + +#quandl { + margin: 10px; +} + +.stuff-box { + font-family: 'helvetica neue', helvetica, sans-serif; + letter-spacing: 1px; + text-transform: capitalize; + text-align: center; + padding: 3px 10px; + margin: 10px; + cursor: pointer; + border-radius: 10px; + border-width: 2px; + border-style: solid; +} + +.red { + border-color: rgb(255,0,0); + background: rgb(180,60,60); + box-shadow: 1px 1px 2px rgba(200,0,0,0.4); +} + +.yellow { + border-color: rgb(255,255,0); + background: rgb(180,180,60); + box-shadow: 1px 1px 2px rgba(200,200,0,0.4); +} + +.blue { + border-color: rgb(0,0,255); + background: rgb(60,60,180); + box-shadow: 1px 1px 2px rgba(0,0,200,0.4); +} + +.green { + border-color: rgb(0,255,0); + background: rgb(60,180,60); + box-shadow: 1px 1px 2px rgba(0,200,0,0.4); +} \ No newline at end of file diff --git a/main/templates/main/index.html b/main/templates/main/index.html new file mode 100644 index 0000000..1b4f3c4 --- /dev/null +++ b/main/templates/main/index.html @@ -0,0 +1,97 @@ + + + + + {% load static %} + Fetching data from Quandl + + + +
+

Worth Your Weight In Gold

+
+ +
+ +
+ +
+
+

+
+
+ + + + + + \ No newline at end of file diff --git a/main/tests.py b/main/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/main/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/main/urls.py b/main/urls.py new file mode 100644 index 0000000..3ef24d9 --- /dev/null +++ b/main/urls.py @@ -0,0 +1,7 @@ +from django.urls import path + +from . import views + +urlpatterns = [ + path('', views.index, name='index'), +] \ No newline at end of file diff --git a/main/views.py b/main/views.py new file mode 100644 index 0000000..af6b743 --- /dev/null +++ b/main/views.py @@ -0,0 +1,14 @@ +from django.shortcuts import render +from django.http import HttpResponse +from django.template import loader +from django.utils import timezone +from django.urls import reverse +from django.http import HttpResponseRedirect + +# Create your views here. +def index(request): + template = loader.get_template('main/index.html') + context = { + + } + return HttpResponse(template.render(context, request)) diff --git a/manage.py b/manage.py new file mode 100755 index 0000000..4edeae8 --- /dev/null +++ b/manage.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cs2610hw7.settings") + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv)