Skip to content

Commit 9200967

Browse files
initial commit
0 parents  commit 9200967

File tree

135 files changed

+36090
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+36090
-0
lines changed

homepage/__init__.py

Whitespace-only changes.

homepage/urls.py

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from django.conf.urls import patterns,include, url
2+
from django.contrib.auth.models import User
3+
4+
5+
from django.contrib import admin
6+
admin.autodiscover()
7+
8+
from django.conf import settings
9+
from django.conf.urls.static import static
10+
11+
12+
urlpatterns = patterns('',
13+
14+
url(r'^$', 'homepage.views.home', name='home'),
15+
url(r'^thank-you/$', 'homepage.views.thankyou', name='thankyou'),
16+
url(r'^learnmore/$', 'homepage.views.learnmore', name='learnmore'),
17+
url(r'^about-us/$', 'signups.views.aboutus', name='aboutus'),
18+
url(r'^admin/', include(admin.site.urls)),
19+
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
20+
21+
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
22+
url(r'^selectionsortabout/$', 'signups.views.selectionsortabout', name='selectionsortabout'),
23+
url(r'^pythonabout/$', 'signups.views.pythonabout', name='pythonabout'),
24+
url(r'^.*/$', 'signups.views.fourzerofour', name='fourzerofour')
25+
)
26+
27+
28+
if settings.DEBUG:
29+
urlpatterns += static(settings.STATIC_URL,
30+
document_root=settings.STATIC_ROOT)
31+
urlpatterns += static(settings.MEDIA_URL,
32+
document_root=settings.MEDIA_ROOT)
33+
34+

homepage/views.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from django.shortcuts import render_to_response, RequestContext, HttpResponseRedirect
2+
3+
4+
def aboutus(request):
5+
return render_to_response("aboutus.html",
6+
locals(),
7+
context_instance=RequestContext(request))
8+
9+
10+
def learnmore(request):
11+
return render_to_response("learnmore.html",
12+
locals(),
13+
context_instance=RequestContext(request))
14+
15+
16+
def pythonabout(request):
17+
return render_to_response("pythonabout.html",
18+
locals(),
19+
context_instance=RequestContext(request))
20+
21+
22+
def fourzerofour(request):
23+
return render_to_response("404.html",
24+
locals(),
25+
context_instance=RequestContext(request))

manage.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env python
2+
import os
3+
import sys
4+
5+
if __name__ == "__main__":
6+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mvp_landing.settings")
7+
8+
from django.core.management import execute_from_command_line
9+
10+
execute_from_command_line(sys.argv)

pip-selfcheck.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"last_check":"2015-06-20T03:52:23Z","pypi_version":"7.0.3"}

requirements.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Django==1.8.5
2+
numpy==1.13.1
3+
simplejson==3.8.0
4+
virtualenv==13.1.2
5+
wheel==0.26.0

settings.py

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
"""
2+
Django settings for mvp_landing project.
3+
4+
Generated by 'django-admin startproject' using Django 1.8.2.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/1.8/topics/settings/
8+
9+
For the full list of settings and their values, see
10+
https://docs.djangoproject.com/en/1.8/ref/settings/
11+
"""
12+
13+
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
14+
import os
15+
16+
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
17+
18+
19+
# Quick-start development settings - unsuitable for production
20+
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
21+
22+
# SECURITY WARNING: keep the secret key used in production secret!
23+
SECRET_KEY = '=aci89qhfnz2owcw55h4^ua(aedsg56u5efny&fo6m3ujiq%39'
24+
25+
# SECURITY WARNING: don't run with debug turned on in production!
26+
DEBUG = True
27+
28+
TEMPLATE_DEBUG = DEBUG
29+
30+
ALLOWED_HOSTS = []
31+
32+
33+
EMAIL_USE_TLS = True
34+
EMAIL_HOST = 'smtp.gmail.com'
35+
EMAIL_HOST_USER ='[email protected]'
36+
EMAIL_HOST_PASSWORD = 'Nycl1ving'
37+
EMAIL_PORT = 587
38+
39+
# Application definition
40+
41+
INSTALLED_APPS = (
42+
'django.contrib.admin',
43+
'django.contrib.auth',
44+
'django.contrib.contenttypes',
45+
'django.contrib.sessions',
46+
'django.contrib.messages',
47+
'django.contrib.staticfiles',
48+
'signups',
49+
'rest_framework',
50+
)
51+
52+
MIDDLEWARE_CLASSES = (
53+
'django.contrib.sessions.middleware.SessionMiddleware',
54+
'django.middleware.common.CommonMiddleware',
55+
'django.middleware.csrf.CsrfViewMiddleware',
56+
'django.contrib.auth.middleware.AuthenticationMiddleware',
57+
#'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
58+
'django.contrib.messages.middleware.MessageMiddleware',
59+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
60+
# 'django.middleware.security.SecurityMiddleware',
61+
)
62+
APPEND_SLASH=True
63+
ROOT_URLCONF = 'mvp_landing.urls'
64+
65+
66+
WSGI_APPLICATION = 'wsgi.application'
67+
68+
69+
# Database
70+
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
71+
72+
DATABASES = {
73+
'default': {
74+
'ENGINE': 'django.db.backends.sqlite3',
75+
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
76+
}
77+
}
78+
79+
80+
# Internationalization
81+
# https://docs.djangoproject.com/en/1.8/topics/i18n/
82+
83+
LANGUAGE_CODE = 'en-us'
84+
85+
TIME_ZONE = 'UTC'
86+
87+
USE_I18N = True
88+
89+
USE_L10N = True
90+
91+
USE_TZ = True
92+
93+
94+
# Static files (CSS, JavaScript, Images)
95+
# https://docs.djangoproject.com/en/1.8/howto/static-files/
96+
97+
STATIC_URL = '/static/'
98+
99+
#Template location
100+
101+
TEMPLATE_DIRS = (os.path.join(os.path.dirname(BASE_DIR),"static","templates")),
102+
103+
if DEBUG:
104+
MEDIA_URL = '/media/'
105+
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR),"static","static-only")
106+
MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR),"static","media")
107+
STATICFILES_DIRS = (
108+
os.path.join(os.path.dirname(BASE_DIR), "static", "static"),
109+
)
110+
111+
112+
REST_FRAMEWORK = {
113+
# Use Django's standard `django.contrib.auth` permissions,
114+
# or allow read-only access for unauthenticated users.
115+
'DEFAULT_PERMISSION_CLASSES': [
116+
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
117+
]
118+
}

signups/__init__.py

Whitespace-only changes.

signups/admin.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from django.contrib import admin
2+
3+
4+
5+
from .models import SignUp
6+
7+
class SignUpAdmin(admin.ModelAdmin):
8+
class Meta:
9+
model = SignUp
10+
fields = "__all__"
11+
12+
admin.site.register(SignUp, SignUpAdmin)

signups/db.sqlite3

42 KB
Binary file not shown.

signups/forms.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from django import forms
2+
3+
from .models import SignUp
4+
5+
class SignUpForm(forms.ModelForm):
6+
class Meta:
7+
model = SignUp
8+
fields = "__all__"

signups/mail.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
from django.contrib import messages
3+
from django.conf import settings
4+
from django.core.mail import send_mail
5+
6+
class MailSender(object):
7+
8+
def get_signup_message(self, save_it):
9+
self.signup_message = 'Hello ' + save_it.first_name + ', '\
10+
' \n\n Thanks for taking the time to look around the algorithm demo website.' \
11+
' Let me know of any feed back you have and how I can make the website better.' \
12+
' If you would like to reach me just reply to this email and I will get back to you promptly. ' \
13+
'\n\n Thank you and have a good day!'\
14+
'\n\n Michael Scotto\n Web Developer\nNew York City Metropolitan Area\n\n' \
15+
'\"More important than the height of the ladder is the wall it is leaning against.\"'
16+
17+
18+
def send_mail_to_signup(self, form, request):
19+
if form.is_valid():
20+
save_it = form.save(commit=False)
21+
save_it.save()
22+
messages.success(request, 'We will be in touch.')
23+
subject='Thank you for taking a look at our website'
24+
message = self.get_sign_up_message(save_it)
25+
from_email = settings.EMAIL_HOST_USER
26+
to_list = [save_it.email]
27+
send_mail(subject, message, from_email, to_list, fail_silently=True)

signups/models.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from django.db import models
2+
3+
class SignUp(models.Model):
4+
first_name = models.CharField(max_length=120, null=True, blank=True)
5+
last_name = models.CharField(max_length=120, null=True, blank=True )
6+
email=models.EmailField()
7+
timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
8+
updated=models.DateTimeField(auto_now_add=False, auto_now=True)
9+
10+
def __unicode__(self):
11+
return self.email

signups/serializers.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
from rest_framework import serializers
3+
from models import SignUp
4+
5+
6+
class SignUpSerializer(serializers.ModelSerializer):
7+
class Meta:
8+
model = SignUp
9+
field = ('first_name', 'last_name')

signups/tests.py

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
2+
from django.shortcuts import HttpResponse
3+
4+
import json
5+
import sort
6+
import time
7+
8+
from multiprocessing import Process, Queue
9+
import threading
10+
import multiprocessing
11+
12+
def mergesort():
13+
timeout = .00000001
14+
input = [33,6,7,2,78,2,7,3,2,7,3,2,23,234,234,234,234,6,2,7,2,21,7,2,234,7,8,235,23,2,5,235]
15+
global timeout
16+
que = Queue()
17+
thr = threading.Thread(target = lambda q, arg : q.put(sort.startMergeSort(input)), args = (que, 2))
18+
19+
thr.start()
20+
thr.join(timeout)
21+
if thr.is_alive():
22+
thr._Thread__stop()
23+
print "thread weas killed!"
24+
data = json.dumps({
25+
"array": input,
26+
"time": 0
27+
})
28+
return HttpResponse(json.dumps(data), content_type='application/json')
29+
else:
30+
returnarr = que.get()
31+
data = json.dumps({
32+
"array": returnarr,
33+
"time": 6
34+
})
35+
print "data to return is " +json.dumps(data)
36+
return HttpResponse(json.dumps(data), content_type='application/json')
37+
38+
39+
def test():
40+
41+
42+
input = [33,6,7,2,78,2,7,3,2,7,3,2,23,234,234,234,234,6,2,7,2,21,7,2,234,7,8,235,23,2,5,235]
43+
# decoded = json.loads(input)
44+
45+
time_begin = time.clock()
46+
print "time begin" + str(time_begin)
47+
48+
p = multiprocessing.Process(target=sort.mergeSort(input,))
49+
#decoded = sort.startMergeSort(decoded)
50+
p.start()
51+
p.join(.000001)
52+
if p.is_alive():
53+
p.terminate()
54+
print "thread weas killed!"
55+
56+
print ""
57+
time_end = time.clock()
58+
print "time end: " + str(time_end)
59+
time_elapsed = time_end - time_begin
60+
print "time elapsed" + str(time_elapsed)
61+
62+
# pretty printing of json-formatted string
63+
print json.dumps(input, sort_keys=True, indent=4)
64+
65+
data = json.dumps({
66+
"array": input,
67+
"time": time_elapsed
68+
})
69+
return HttpResponse(json.dumps(data), content_type='application/json')
70+
71+
72+
mergesort()

signups/urls.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
3+
from django.conf.urls import patterns, include, url
4+
from rest_framework.urlpatterns import format_suffix_patterns
5+
import views
6+
7+
urlpatterns = patterns('',
8+
url(r'^api/$', views.SignUpList.as_view()),
9+
url(r'^signups/', include('signups.urls')),
10+
)
11+
12+
urlpatterns = format_suffix_patterns(urlpatterns)

signups/views.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from django.shortcuts import render_to_response, RequestContext, HttpResponseRedirect
2+
from .forms import SignUpForm
3+
from rest_framework import generics
4+
from models import SignUp
5+
from serializers import SignUpSerializer
6+
from mail import MailSender
7+
8+
9+
def signup(request):
10+
form = SignUpForm(request.POST or None)
11+
MailSender().send_mail_to_signup(form, request)
12+
return HttpResponseRedirect('/thank-you/')
13+
14+
15+
def thankyou(request):
16+
return render_to_response("thankyou.html",
17+
locals(),
18+
context_instance =RequestContext(request))
19+
20+
class SignUpList(generics.ListCreateAPIView):
21+
queryset = SignUp.objects.all()
22+
serializer_class = SignUpSerializer
23+

sorting/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

0 commit comments

Comments
 (0)