Commit 73f89454 authored by Daniel W Bond's avatar Daniel W Bond
Browse files

added initial requirements txt

parent cb17bf74
from django.contrib import admin
from api.models import Class, Building, Address, Room
# Register your models here.
admin.site.register(Class)
admin.site.register(Building)
admin.site.register(Address)
admin.site.register(Room)
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
]
operations = [
migrations.CreateModel(
name='Address',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('street', models.CharField(max_length=100)),
('zip_code', models.IntegerField()),
('state', models.CharField(max_length=2)),
],
options={
},
bases=(models.Model,),
),
migrations.CreateModel(
name='Building',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=100)),
('address', models.ForeignKey(to='api.Address')),
],
options={
},
bases=(models.Model,),
),
migrations.CreateModel(
name='Class',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('year_int', models.IntegerField()),
('year_in_school', models.CharField(default=b'FR', max_length=2, choices=[(b'FR', b'Freshman'), (b'SO', b'Sophomore'), (b'JR', b'Junior'), (b'SR', b'Senior')])),
],
options={
},
bases=(models.Model,),
),
migrations.CreateModel(
name='Room',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('number', models.IntegerField()),
('floor', models.IntegerField()),
('bedA', models.CharField(max_length=80)),
('bedB', models.CharField(max_length=80)),
('bedC', models.CharField(max_length=80)),
('bedD', models.CharField(max_length=80)),
('building', models.ForeignKey(to='api.Building')),
],
options={
},
bases=(models.Model,),
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('api', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='address',
name='zip_code',
field=models.IntegerField(max_length=5),
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('api', '0002_auto_20141009_2325'),
]
operations = [
migrations.AddField(
model_name='building',
name='neighbourhood',
field=models.CharField(default=None, max_length=100, blank=True),
preserve_default=False,
),
migrations.AlterField(
model_name='room',
name='bedB',
field=models.CharField(max_length=80, blank=True),
),
migrations.AlterField(
model_name='room',
name='bedC',
field=models.CharField(max_length=80, blank=True),
),
migrations.AlterField(
model_name='room',
name='bedD',
field=models.CharField(max_length=80, blank=True),
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('api', '0003_auto_20141015_0308'),
]
operations = [
migrations.RemoveField(
model_name='building',
name='neighbourhood',
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('api', '0004_remove_building_neighbourhood'),
]
operations = [
migrations.AddField(
model_name='building',
name='neighbourhood',
field=models.CharField(default=b'None', max_length=100, blank=True),
preserve_default=True,
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('api', '0005_building_neighbourhood'),
]
operations = [
migrations.AlterField(
model_name='building',
name='neighbourhood',
field=models.CharField(default=b'NA', max_length=100, choices=[(b'NA', b'None'), (b'AQ', b'Aquia'), (b'RA', b'Rappahannock'), (b'SH', b'Shenandoah')]),
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('api', '0006_auto_20141015_0319'),
]
operations = [
migrations.AlterField(
model_name='building',
name='neighbourhood',
field=models.CharField(default=b'na', max_length=100, choices=[(b'na', b'None'), (b'aq', b'Aquia'), (b'ra', b'Rappahannock'), (b'sh', b'Shenandoah')]),
),
]
from django.db import models
# Create your models here.
class Class(models.Model):
year_int = models.IntegerField()
FRESHMAN = 'FR'
SOPHOMORE = 'SO'
JUNIOR = 'JR'
SENIOR = 'SR'
YEAR_IN_SCHOOL_CHOICES = (
(FRESHMAN, 'Freshman'),
(SOPHOMORE, 'Sophomore'),
(JUNIOR, 'Junior'),
(SENIOR, 'Senior'),
)
year_in_school = models.CharField(max_length=2,
choices=YEAR_IN_SCHOOL_CHOICES,
default=FRESHMAN)
def __str__(self): # __unicode__ on Python 2
return self.year_int
class Building(models.Model):
name = models.CharField(max_length=100)
NONE = 'na'
AQUIA = 'aq'
RAPPAHANNOCK = 'ra'
SHENANDOAH = 'sh'
NEIGHBOURHOOD_CHOICES = (
(NONE, 'None'),
(AQUIA, 'Aquia'),
(RAPPAHANNOCK, 'Rappahannock'),
(SHENANDOAH, 'Shenandoah'),
)
neighbourhood = models.CharField(max_length=100, choices=NEIGHBOURHOOD_CHOICES,
default=NONE)
address = models.ForeignKey('Address')
def __str__(self): # __unicode__ on Python 2
return self.name
def __unicode__(self): # __unicode__ on Python 2
return unicode(self.name)
class Room(models.Model):
number = models.IntegerField()
floor = models.IntegerField()
bedA = models.CharField(max_length=80)
bedB = models.CharField(max_length=80, blank=True)
bedC = models.CharField(max_length=80, blank=True)
bedD = models.CharField(max_length=80, blank=True)
building = models.ForeignKey('Building')
def __str__(self): # __unicode__ on Python 2
return self.building.__str__()+" "+self.number.__str__()
class Address(models.Model):
street = models.CharField(max_length=100)
zip_code = models.IntegerField(max_length=5)
state = models.CharField(max_length=2)
def __str__(self): # __unicode__ on Python 2
return self.street
from django.test import TestCase
# Create your tests here.
from django.conf.urls import patterns, url
from api import views
urlpatterns = patterns('',
url(r'^$', views.index, name='index'),
url(r'^building/(?P<building>.+)/(?P<room_number>\d+)$', views.room, name='room'),
url(r'^building/(?P<buildingName>[a-zA-Z]+)$', views.building, name='building'),
url(r'^buildings/$', views.buildings_list, name='buildings_list'),
url(r'^neighbourhood/(?P<nhood>[a-zA-Z]+)$', views.neighbourhood, name='neighbourhood'),
url(r'^room/(?P<building>[a-zA-Z]+)/(?P<room_number>\d+)$', views.room, name='room'),
)
from django.http import HttpResponse
import json
from api.models import Building, Room
# Create your views here.
def index(request):
return HttpResponse("Hello, world. You're at the RoomList index.")
def buildings_list(request):
building_list = Building.objects.order_by('name')[:5]
jsons = '{"buildings":['
for p in building_list:
jsons += '"'+p.__str__()+'":"'+p.address.__str__()+'",'
jsons = jsons[:-1]+']}'
return HttpResponse(jsons)
def building(request, buildingName):
room_list = Room.objects.filter(building__name=''+buildingName).order_by('number')
jsons = 'Building does not exist'
if room_list:
jsons = '{"name":"'+buildingName+'","rooms":['
for p in room_list:
jsons += '"'+p.number.__str__()+'":['
jsons += '"floor":'+p.floor.__str__()+',"bedA":"'+p.bedA.__str__()+'"'
if p.bedB.__str__() is not '':
jsons += ',"bedB":"'+p.bedB.__str__()+'"'
if p.bedC.__str__() is not '':
jsons += ',"bedC":"'+p.bedC.__str__()+'"'
if p.bedD.__str__() is not '':
jsons += ',"bedD":"'+p.bedD.__str__()+'"'
jsons += '],'
jsons = jsons[:-1] + ']}'
return HttpResponse(jsons)
def room(request, building, room_number):
room_obj = Room.objects.filter(building__name=''+building, number=room_number)
jsons = "This room does not exist or has not been created"
if room_obj:
jsons = '{"building":"'+building+'","number":'+room_number+','
for p in room_obj:
jsons += '"floor":'+p.floor.__str__()+',"residents":["bedA":"'+p.bedA.__str__()+'"'
if p.bedB.__str__() is not '':
jsons += ',"bedB":"'+p.bedB.__str__()+'"'
if p.bedC.__str__() is not '':
jsons += ',"bedC":"'+p.bedC.__str__()+'"'
if p.bedD.__str__() is not '':
jsons += ',"bedD":"'+p.bedD.__str__()+'"'
jsons += ']'
jsons += ']}'
return HttpResponse(jsons)
###################JASON trying to JSON in python, so confuzed:
# if room_obj:
# jsons = {'building':building, 'number':room_number, 'residents': []}
# for p in room_obj:
# jsons.residents[0] = 'bedA':p.bedA.__str__()
# if p.bedB.__str__() is not '':
# jsons.residents[1] = 'bedB':p.bedB.__str__()
# if p.bedC.__str__() is not '':
# jsons.residents[2] = 'bedC':p.bedC.__str__()
# if p.bedD.__str__() is not '':
# jsons.residents[3] = 'bedD':p.bedD.__str__()
# return HttpResponse(json.dumps(jsons))
def neighbourhood(request, nhood):
building_list = Building.objects.filter(neighbourhood=''+nhood).order_by('name')
jsons = 'That neighbourhood has no buildings or does not exist'
code = 404
if building_list:
code = 200
jsons = '{"neighbourhood":"'+nhood+'","buildings":['
for p in building_list:
jsons += '"'+p.__str__()+'",'
jsons = jsons[:-1]+']}'
return HttpResponse(jsons, status=code)
"""
Django settings for django_project project.
For more information on this file, see
https://docs.djangoproject.com/en/1.6/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.6/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
print TEMPLATE_DIRS
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'fGTL0pyk8MRq9YLXIOzFKZlneTdg3etdRxXs1FN2FqlVk595Ix'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_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',
'api',
)
MIDDLEWARE_CLASSES = (
'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 = 'django_project.urls'
WSGI_APPLICATION = 'django_project.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'django',
'USER': 'django',
'PASSWORD': 'H0jrp0llTJ',
'HOST': 'localhost',
'PORT': '',
}
}
# Internationalization
# https://docs.djangoproject.com/en/1.6/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.6/howto/static-files/
STATIC_URL = '/static/'
"""
Django settings for django_project project.
For more information on this file, see
https://docs.djangoproject.com/en/1.6/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.6/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '@SECRET_KEY@'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_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_CLASSES = (
'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 = 'django_project.urls'
WSGI_APPLICATION = 'django_project.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'django',
'USER': 'django',
'PASSWORD': 'H0jrp0llTJ',
'HOST': 'localhost',
'PORT': '',
}
}
# Internationalization
# https://docs.djangoproject.com/en/1.6/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.6/howto/static-files/
STATIC_URL = '/static/'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment