Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
.git
*.pyc

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
env/
bin/
build/
develop-eggs/
dist/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml

# Translations
*.mo

# Mr Developer
.mr.developer.cfg
.project
.pydevproject

# Rope
.ropeproject

# Django stuff:
*.log
*.pot

# Sphinx documentation
docs/_build/

# Custom
.idea
db.sqlite3
.DS_Store
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ This test includes two parts.
}
```

You may assume the input will only contain words and standard punctuation.
You may assume the input will only contain words and standard punctuation
Empty file added ToDo/apps/__init__.py
Empty file.
Empty file added ToDo/apps/public/__init__.py
Empty file.
4 changes: 4 additions & 0 deletions ToDo/apps/public/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from django.contrib import admin
from apps.public.models import Task

admin.site.register(Task)
24 changes: 24 additions & 0 deletions ToDo/apps/public/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


class Migration(migrations.Migration):

dependencies = [
]

operations = [
migrations.CreateModel(
name='Task',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('task_name', models.CharField(max_length=100)),
('task_complete', models.BooleanField(default=False)),
],
options={
},
bases=(models.Model,),
),
]
Empty file.
18 changes: 18 additions & 0 deletions ToDo/apps/public/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from django.db import models
from django import forms


class Task(models.Model):
task_name = models.CharField(max_length=100)
task_complete = models.BooleanField(default=False)

def __unicode__(self):
return self.task_name



class TaskForm(forms.ModelForm):

class Meta:
model = Task
fields = ['task_name']
21 changes: 21 additions & 0 deletions ToDo/apps/public/templates/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<h1>To Do List</h1>


<h3>Create a Task:</h3>
<form action="/task_list/get_task/" method="post">
{% csrf_token %}
<input id="task_name" type="text" name="task_name">
<input type="submit" value="Submit">
</form>



{% if list_of_tasks %}
<h3>List of Tasks to Complete:</h3>
<ul>
{% for task in list_of_tasks %}
<li style="font-size">{{ task.task_name }}&nbsp; &nbsp; <a style="font-size:12px" href="/task_list/{{ task.id }}/complete">[Complete Task]</a></li>
{% endfor %}
</ul>

{% endif %}
3 changes: 3 additions & 0 deletions ToDo/apps/public/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
13 changes: 13 additions & 0 deletions ToDo/apps/public/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from django.conf.urls import patterns, url
from apps.public import views


urlpatterns = patterns('',
# ex. /task_list/
url(r'^$', views.task_list, name='task_list'),
# ex. /task_list/5/complete
url(r'^(?P<task_id>\d+)/complete/$', views.complete_task, name='complete_task'),
# ex./task_list/get_task
url(r'^get_task/', views.get_task, name='get_task'),

)
37 changes: 37 additions & 0 deletions ToDo/apps/public/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from django.shortcuts import render
from django.http import HttpResponse, HttpResponseRedirect
from django.template import RequestContext, loader

from apps.public.models import Task, TaskForm


def task_list(request):
list_of_tasks = Task.objects.filter(task_complete=False)
template = loader.get_template('public/index.html')
context = RequestContext(request, {
'list_of_tasks': list_of_tasks,
})
return HttpResponse(template.render(context))


def get_task(request):
if request.method == 'POST':
form = TaskForm(request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect('/task_list')

else: # mostly to prevent blank responses, but will prevent other problematic inputs if they exist
return HttpResponse("Not a valid task name. <a href='/task_list'>Click Here to try again</a>")

else: # creates a blank form if receiving a non-POST request
form = TaskForm()

return HttpResponseRedirect("/task_list")


def complete_task(request, task_id):
task = Task.objects.get(pk=task_id)
task.task_complete = True
task.save()
return HttpResponseRedirect('/task_list')
Binary file added ToDo/db.sqlite3
Binary file not shown.
10 changes: 10 additions & 0 deletions ToDo/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")

from django.core.management import execute_from_command_line

execute_from_command_line(sys.argv)
Empty file added ToDo/project/__init__.py
Empty file.
85 changes: 85 additions & 0 deletions ToDo/project/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
"""
Django settings for ToDo project.

For more information on this file, see
https://docs.djangoproject.com/en/1.7/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.7/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.7/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '(^%6-cisvne6&tta7$8j2ne1x6(d&1yal0*0*q1k#8ht4%ec^6'

# 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',
'apps.public',
)

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'project.urls'

WSGI_APPLICATION = 'project.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}

# Internationalization
# https://docs.djangoproject.com/en/1.7/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.7/howto/static-files/

STATIC_URL = '/static/'

12 changes: 12 additions & 0 deletions ToDo/project/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from django.conf.urls import patterns, include, url
from django.contrib import admin

urlpatterns = patterns('',
# Examples:
# url(r'^$', 'ToDo.views.home', name='home'),
url(r'^task_list/', include('apps.public.urls')),
url(r'^', include('apps.public.urls')),

url(r'^admin/', include(admin.site.urls)),

)
14 changes: 14 additions & 0 deletions ToDo/project/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""
WSGI config for ToDo 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.7/howto/deployment/wsgi/
"""

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ToDo.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
3 changes: 3 additions & 0 deletions ToDo/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Django==1.7.1
argparse==1.2.1
wsgiref==0.1.2
24 changes: 24 additions & 0 deletions word_cloud.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
punctuation = ('\'', '"', ',', '.', '?', '!')
word_cloud = {}

long_string = raw_input("Enter a string: ")
long_string = long_string.lower()


split_string = long_string.split()


for word in split_string:

if word[0] in punctuation: #checks for punctuation at the beginning of a word and removes it
word = word[1: len(word)]

if word[len(word) -1] in punctuation: #checks for punctuation at the end of a word and removes it. Mostly for removing unnecessary punctuation
word = word[:len(word) - 1]

if word in word_cloud.keys():
word_cloud[word] += 1
else:
word_cloud[word] = 1

print word_cloud