Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
221 commits
Select commit Hold shift + click to select a range
1695441
Updated README for project description.
CCallahanIV Dec 22, 2016
0d4db3e
Update README.md
CCallahanIV Dec 22, 2016
afe8489
Added user stories.
CCallahanIV Jan 4, 2017
ebc2ced
Update README.md
rveeblefetzer Jan 5, 2017
3848ac1
Initial commit, scaffold created.
CCallahanIV Jan 9, 2017
e35da75
Initial Commit of roughed out structure.
CCallahanIV Jan 9, 2017
fd35e27
changed manage route for username specific, added login, logout and r…
ellezv Jan 9, 2017
343de25
add auth policies, credential check, CSRF protection
rveeblefetzer Jan 9, 2017
6ca11e5
added csrf token field
ellezv Jan 10, 2017
88ac0e5
Merge branch 'views' of https://github.com/PyListener/CF401-Project-1…
rveeblefetzer Jan 10, 2017
d660d0f
Merge branch 'security' of https://github.com/PyListener/CF401-Projec…
ellezv Jan 10, 2017
1e1e947
template for manage page
ellezv Jan 10, 2017
57c7538
basic main template
rveeblefetzer Jan 10, 2017
c7b6b3f
Merge branch 'home_template' of https://github.com/PyListener/CF401-P…
ellezv Jan 10, 2017
2a2a9ed
Wrote structure of model and updated components of other files to imp…
CCallahanIV Jan 10, 2017
bb567ad
merge models
ellezv Jan 10, 2017
66666a4
uncommented Categories in import statement.
CCallahanIV Jan 10, 2017
e7ab6cd
Merge pull request #26 from PyListener/manage_template
CCallahanIV Jan 10, 2017
e859ed7
Updated .gitignore with *.sqlite
CCallahanIV Jan 10, 2017
f887e92
Merge pull request #27 from PyListener/models
CCallahanIV Jan 10, 2017
92e6fff
manage template modified to fit models
ellezv Jan 10, 2017
cedf056
added psycopg2 to requires
rveeblefetzer Jan 10, 2017
7365645
Wrote basic set of categories and attributes.
CCallahanIV Jan 10, 2017
8be261b
added environment variable for database
rveeblefetzer Jan 10, 2017
4e96ed8
added environ variable to initdb
rveeblefetzer Jan 10, 2017
4de7b51
Merge pull request #28 from PyListener/init_db
CCallahanIV Jan 10, 2017
76c0cd3
Merge pull request #1 from rveeblefetzer/patch-1
CCallahanIV Jan 10, 2017
6bd3fc6
manage view with file upload for new contact
ellezv Jan 10, 2017
8bdf16b
Added sample data set and began writing code to load that data into t…
CCallahanIV Jan 10, 2017
12d1417
Merge pull request #30 from PyListener/home_tests
ellezv Jan 10, 2017
c30633c
Merge pull request #29 from PyListener/manage_view
CCallahanIV Jan 10, 2017
8a2f135
added sample categories and attributes
ellezv Jan 10, 2017
eeb088d
group programming DB
ellezv Jan 10, 2017
0f5799f
Changed model to create user attribute link class.
CCallahanIV Jan 10, 2017
7fcb46d
manage view post now updates database
ellezv Jan 10, 2017
42a7c29
merge
ellezv Jan 10, 2017
15ee17e
Merge branch 'models-rel' of https://github.com/PyListener/CF401-Proj…
ellezv Jan 10, 2017
56ad454
changed tmp file
ellezv Jan 10, 2017
d3dc69c
merging
ellezv Jan 10, 2017
783ce4d
Merge pull request #31 from PyListener/group_db
CCallahanIV Jan 10, 2017
41bb13e
Implementing new view schema, preparing to add images to sample db.
CCallahanIV Jan 11, 2017
94388c1
first unit tests.
ellezv Jan 11, 2017
84ed742
got pictures to save to database as binary and retrieve/serve to view
rveeblefetzer Jan 11, 2017
60041ac
Merge pull request #36 from PyListener/pictures
ellezv Jan 11, 2017
5d47d14
Added files necessary for heroku deployment.
CCallahanIV Jan 11, 2017
db9ada5
Converted run script to executable
CCallahanIV Jan 11, 2017
430de62
Merge pull request #37 from PyListener/development
CCallahanIV Jan 11, 2017
0b80544
Removed reference to DATABASE_URL
CCallahanIV Jan 11, 2017
dce6a93
moved procfile
CCallahanIV Jan 11, 2017
33fbc38
removed Procfile
CCallahanIV Jan 11, 2017
5a60f5c
moved requirements.txt
CCallahanIV Jan 11, 2017
f09d005
changed run pointers
CCallahanIV Jan 11, 2017
5d90afa
attempt 1
CCallahanIV Jan 11, 2017
fe69bf1
attempt 2
CCallahanIV Jan 11, 2017
65a7206
attempt 3
CCallahanIV Jan 11, 2017
26aadb9
attempt 4
CCallahanIV Jan 11, 2017
3165adc
attempt 5
CCallahanIV Jan 11, 2017
a2a2812
attempt 6
CCallahanIV Jan 11, 2017
7438b62
attempt 8
CCallahanIV Jan 11, 2017
fa366d7
attempt 9
CCallahanIV Jan 11, 2017
9734bc5
attempt 10 won't work
CCallahanIV Jan 11, 2017
020a16c
attempt 11 minus the DB
CCallahanIV Jan 11, 2017
db09a75
attempt 12
CCallahanIV Jan 11, 2017
2ab3a7b
attempt 13ish
CCallahanIV Jan 11, 2017
74a3af1
moved all files up one level to repo level.
CCallahanIV Jan 11, 2017
283bed3
returned run and runapp.py to initial settings.
CCallahanIV Jan 11, 2017
9884f37
attemp 15
CCallahanIV Jan 11, 2017
bd740d8
Attemp 16
CCallahanIV Jan 11, 2017
921fd04
Attempt 17
CCallahanIV Jan 11, 2017
cf8920a
Merge branch 'development' of https://github.com/PyListener/CF401-Pro…
ellezv Jan 11, 2017
d1201a8
Adding pictures to data.json
CCallahanIV Jan 11, 2017
54f3617
added pictograms for questions and creative commons images for needs,…
rveeblefetzer Jan 11, 2017
c02ba98
Added another user with new contacts, updated initializedb.
CCallahanIV Jan 11, 2017
4692d4e
Merge branch 'master' into development
rveeblefetzer Jan 11, 2017
7e59226
Merge branch 'development' of https://github.com/PyListener/CF401-Pro…
CCallahanIV Jan 11, 2017
410ddbc
Added remaining pictures and refactored initializedb.
CCallahanIV Jan 11, 2017
d3be595
troubelshot initializedb.py and moved some pictures around to match w…
CCallahanIV Jan 11, 2017
66068e2
Merge pull request #38 from PyListener/pictures
ellezv Jan 11, 2017
2e00424
Wrote out rest of picture view handler.
CCallahanIV Jan 11, 2017
d896df2
Merge branch 'development' of https://github.com/PyListener/CF401-Pro…
CCallahanIV Jan 11, 2017
16675d0
worked on display view:
ellezv Jan 11, 2017
8e147f8
views for attributes working
rveeblefetzer Jan 11, 2017
577c551
changed display sentence
ellezv Jan 11, 2017
6133f23
merging
ellezv Jan 11, 2017
33b342c
Merge pull request #39 from PyListener/display_view
CCallahanIV Jan 11, 2017
b0fcb3e
Added filter by category to attribute view.
CCallahanIV Jan 11, 2017
1ee9b46
Merge branch 'development' of https://github.com/PyListener/CF401-Pro…
ellezv Jan 11, 2017
5915c3b
unit tests
ellezv Jan 12, 2017
42a491d
starting on fixtures for functional tests and first few tests
ellezv Jan 12, 2017
6f56b26
initial CSS stylings set, in progress
rveeblefetzer Jan 12, 2017
dbfcfb2
Merge pull request #40 from PyListener/testing
CCallahanIV Jan 12, 2017
b44258c
Merge pull request #41 from PyListener/frontend
CCallahanIV Jan 12, 2017
0f15921
Merge branch 'master' of https://github.com/PyListener/CF401-Project-…
rveeblefetzer Jan 12, 2017
1e66fb1
stashing changes before commit.
CCallahanIV Jan 12, 2017
a697389
Merge branch 'development' of https://github.com/PyListener/CF401-Pro…
CCallahanIV Jan 12, 2017
a17205a
Merge pull request #44 from PyListener/development
CCallahanIV Jan 12, 2017
4c2e019
Updated requirements.txt for new dependencies.
CCallahanIV Jan 12, 2017
bbd873d
commented out if sqlalchemy.url not in settings in __init__.py might …
CCallahanIV Jan 12, 2017
01a0ee1
functional tests
ellezv Jan 12, 2017
6594a4e
category and attribute li's line up; manage icon working, but need to…
rveeblefetzer Jan 12, 2017
cf431db
resized navbar fa icons
rveeblefetzer Jan 12, 2017
c5553cd
Merge pull request #46 from PyListener/frontend
CCallahanIV Jan 12, 2017
0664a3d
Merge branch 'master' of https://github.com/PyListener/CF401-Project-…
CCallahanIV Jan 12, 2017
df31e37
Merge branch 'master' into development
CCallahanIV Jan 12, 2017
09f1d95
home and manage icon color change, manage icon now hides if not logge…
rveeblefetzer Jan 12, 2017
312056c
merged
ellezv Jan 12, 2017
db5976f
Working on join with UserAttributeLink for attributes view.
CCallahanIV Jan 12, 2017
8a9f2b1
Merge pull request #47 from PyListener/db_relative_table
ellezv Jan 12, 2017
42f32a7
reverts var for user, unbreaks login
rveeblefetzer Jan 12, 2017
234386f
Merge pull request #45 from PyListener/testing
CCallahanIV Jan 12, 2017
b37c473
Merge pull request #48 from PyListener/frontend
ellezv Jan 12, 2017
3f58b08
Now displaying attribute images based on priority.
CCallahanIV Jan 12, 2017
2919556
Merge branch 'development' of https://github.com/PyListener/CF401-Pro…
CCallahanIV Jan 12, 2017
d5b3aa7
Changed route for manage to allow for usernames with multiple letters.
CCallahanIV Jan 12, 2017
5a6b5f1
Merge pull request #49 from PyListener/db_relative_table
rveeblefetzer Jan 12, 2017
30a53ee
display elements centered
rveeblefetzer Jan 12, 2017
784f63b
Changed formatting for final message, added sub_user to User model so…
CCallahanIV Jan 12, 2017
82293e3
refactored manage view:
ellezv Jan 12, 2017
6b7403b
Merge pull request #50 from PyListener/format_message
ellezv Jan 12, 2017
b17f716
Added pic_mime column to all tables with pictures, refactored image h…
CCallahanIV Jan 12, 2017
3e6ae12
Cured merge conflicts in data.json
CCallahanIV Jan 12, 2017
37dd9b7
styled manage forms
rveeblefetzer Jan 12, 2017
03ee036
Merge branch 'development' into upload_validation
CCallahanIV Jan 12, 2017
73b9f11
Merge pull request #51 from PyListener/upload_validation
CCallahanIV Jan 12, 2017
ff64af7
Merge branch 'development' into frontend
CCallahanIV Jan 12, 2017
d2c4d4d
Merge pull request #52 from PyListener/frontend
CCallahanIV Jan 12, 2017
01fcfa8
add style on final message page
rveeblefetzer Jan 12, 2017
938f1a6
Merge pull request #53 from PyListener/frontend
CCallahanIV Jan 12, 2017
f67aa9a
deleted an extra curly brace that broke manage page styles
rveeblefetzer Jan 12, 2017
b4d2799
flash messages after uploads.
ellezv Jan 12, 2017
204cb38
Merge branch 'frontend' of https://github.com/PyListener/CF401-Projec…
CCallahanIV Jan 12, 2017
9d70cbe
Adding list of contacts and views to manage page.
CCallahanIV Jan 12, 2017
0324dfe
implementing features to allow AJAX deletion of elements from contact…
CCallahanIV Jan 12, 2017
9969b63
Merge pull request #54 from PyListener/del_functionality
ellezv Jan 12, 2017
f9a7704
fixed up failing tests due to refactoring.
ellezv Jan 12, 2017
d7725d3
fixed tox and tests
ellezv Jan 13, 2017
b002689
Added functionality to delete contacts and attributes. Need to troub…
CCallahanIV Jan 13, 2017
4daa374
Merge pull request #56 from PyListener/del_functionality
ellezv Jan 13, 2017
368cd48
Merge pull request #55 from PyListener/tests
rveeblefetzer Jan 13, 2017
2ceff35
Merge pull request #57 from PyListener/development
CCallahanIV Jan 13, 2017
48e3d4c
Changed pic_mime to field type text from unicode.
CCallahanIV Jan 13, 2017
0345373
encoding pic_mime to byte string
CCallahanIV Jan 13, 2017
539594d
logout resolved, register logs in and redirects to manage
ellezv Jan 13, 2017
1ab7403
Merge pull request #58 from PyListener/permission
CCallahanIV Jan 13, 2017
0f769f4
Merge branch 'master' of https://github.com/PyListener/CF401-Project-…
CCallahanIV Jan 13, 2017
fb6b798
register view will now also create a default contact, log in and vali…
ellezv Jan 13, 2017
7037022
resized main pictograms, restyled manage/delete pictograms
rveeblefetzer Jan 13, 2017
17fa83b
Succesfully troubleshot deleting attributes. Developed new method fo…
CCallahanIV Jan 13, 2017
d5bd3f3
Merge pull request #59 from PyListener/register_new_contact
CCallahanIV Jan 13, 2017
e853f27
Merge branch 'development' into man_att_debug
ellezv Jan 13, 2017
ba3acd7
Merge pull request #61 from PyListener/man_att_debug
ellezv Jan 13, 2017
b85dd4f
starting on readme
ellezv Jan 13, 2017
a157485
added logout icon/link, centered text in a few places
rveeblefetzer Jan 13, 2017
ef04d01
Merge pull request #60 from PyListener/frontend
CCallahanIV Jan 13, 2017
81bb351
Merge pull request #62 from PyListener/development
CCallahanIV Jan 13, 2017
99dd503
encoding mime type in picture handler.
CCallahanIV Jan 13, 2017
96e333e
pylistener/templates/manage.jinja2
CCallahanIV Jan 13, 2017
0bcee53
Troubleshooting delete functionality, deleted class in link was culprit.
CCallahanIV Jan 13, 2017
e123ce0
Added initializing for a newly registered user. Fixed... some other …
CCallahanIV Jan 13, 2017
82a62cd
encoding
CCallahanIV Jan 13, 2017
411a260
Fixed conditional for image handler, fixed function import for initia…
CCallahanIV Jan 13, 2017
7d0188d
Merge pull request #63 from PyListener/development-last-second
CCallahanIV Jan 13, 2017
9c04123
docstring edits
rveeblefetzer Jan 13, 2017
ba3fc71
Changed Test DB address back to Maelle's
CCallahanIV Jan 13, 2017
e9a4e74
Merge pull request #64 from PyListener/tests_day_5
CCallahanIV Jan 13, 2017
3cf1f90
css changes.
ellezv Jan 13, 2017
f05fc8b
Merge branch 'flashes_css' of https://github.com/PyListener/CF401-Pro…
CCallahanIV Jan 13, 2017
778b336
Changed css class of login form to manage_form.
CCallahanIV Jan 13, 2017
b9ff7ff
Merge pull request #65 from PyListener/css-review
ellezv Jan 13, 2017
bbf91ab
test
ellezv Jan 13, 2017
c26f619
added info about Apraxia, Apraxia of speech
rveeblefetzer Jan 13, 2017
3fa6f4b
Merge pull request #66 from PyListener/readme
CCallahanIV Jan 16, 2017
96433d1
Attempted to write tests. Ran out of time.
CCallahanIV Jan 16, 2017
23bab95
Merge pull request #67 from PyListener/development
CCallahanIV Jan 16, 2017
408d9bb
removed harcoded contact addresses for yagmail and textbelt apis
ellezv Jan 26, 2017
f4cc69f
Merge branch 'development' of https://github.com/PyListener/CF401-Pro…
ellezv Jan 26, 2017
3141b1d
fixed bug in handle_new_contact
ellezv Jan 26, 2017
2e96fb8
css changes to display main
ellezv Jan 29, 2017
f82275c
Fixed Add Attribute form on manage page. Fixed add_attribute_handler…
CCallahanIV Jan 29, 2017
4e351bd
changed input submit for buttons with icons. Changed the view to adap…
ellezv Jan 29, 2017
0ad7fe1
display css: buttons styling and refresh button added
ellezv Jan 29, 2017
f0aaca7
Added status bar on category and attribute pages.
CCallahanIV Jan 29, 2017
8bae74c
Merge pull request #76 from PyListener/display_front_end
CCallahanIV Jan 29, 2017
3e3bc0a
Merge pull request #77 from PyListener/hotfix-manageform
ellezv Jan 29, 2017
d2ccaba
changed images, resized some
rveeblefetzer Jan 29, 2017
ffc5a9f
Fixed css for navbar and some layout issues.
CCallahanIV Jan 31, 2017
ab52a23
Fixed login form button.
CCallahanIV Jan 31, 2017
725ee68
edited json entries for new pics, pic filetype changes
rveeblefetzer Jan 31, 2017
aa5a601
style on forms: submit are input, now centered, restyled. Forms are n…
ellezv Jan 31, 2017
5dfb4c5
Merge pull request #78 from PyListener/form_css
ellezv Jan 31, 2017
695833d
resized image for play, fixed more json entries
rveeblefetzer Jan 31, 2017
d93fb18
Merge branch 'newpics' of https://github.com/PyListener/CF401-Project…
CCallahanIV Jan 31, 2017
d796fe9
Fixed errors in data.json.
CCallahanIV Feb 1, 2017
7df5d7f
Merge pull request #79 from PyListener/dev-test
CCallahanIV Feb 1, 2017
760300b
Merge pull request #80 from PyListener/development
CCallahanIV Feb 1, 2017
ecab3ad
added lines to production.ini for https compatibilitiy.
CCallahanIV Feb 1, 2017
96970e8
troubleshooting production.ini
CCallahanIV Feb 1, 2017
4cb2ad3
Added 'pylistener:' to static route.
CCallahanIV Feb 1, 2017
c890212
working over https
CCallahanIV Feb 1, 2017
7ac7824
troubleshooting AddressError from yagmail, suspect python 2/3 incompa…
CCallahanIV Feb 2, 2017
dacf54c
updated requirements.
CCallahanIV Feb 2, 2017
8962105
please god work
CCallahanIV Feb 2, 2017
0ed57c7
please god work
CCallahanIV Feb 2, 2017
d736569
Because this always happens.
CCallahanIV Feb 2, 2017
1c381e5
replaced textbelt with twilio
ellezv Feb 2, 2017
83cb10d
Merge branch 'master' of https://github.com/PyListener/CF401-Project-…
ellezv Feb 2, 2017
bbb003c
Merge pull request #81 from PyListener/textbelt-hotfix
CCallahanIV Feb 2, 2017
154693e
deleted unused readme.txt
ellezv Feb 22, 2017
e43b153
blank line at end of file
ellezv Feb 22, 2017
3a03e5e
breaking down and renaming functions
ellezv Feb 22, 2017
6c4a00f
refactored display view, now broken down in helper functions
ellezv Feb 22, 2017
f999553
code cleanup, linetoolong errors
ellezv Feb 22, 2017
74a4105
minor fixes in setup.py and test_db change in tests.py
ellezv Feb 23, 2017
fe4da89
non-passing tests fixed. Need more tests.
ellezv Feb 23, 2017
39b1521
test cleanup
ellezv Feb 23, 2017
a7c0a29
updated readme.
ellezv Feb 23, 2017
6ba373f
Merge pull request #82 from PyListener/views_refactoring
ellezv Feb 23, 2017
d2ba54f
Merge pull request #84 from PyListener/tests_fix
ellezv Feb 23, 2017
fe3033d
readme typos fix
ellezv Feb 23, 2017
ec293dc
readme edit
ellezv Feb 23, 2017
1c31d0b
Merge pull request #83 from PyListener/readme
ellezv Feb 23, 2017
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var/
*.egg-info/
.installed.cfg
*.egg
*.sqlite

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0.0
---

- Initial version
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include *.txt *.ini *.cfg *.rst
recursive-include pylistener *.ico *.png *.css *.gif *.jpg *.jinja2 *.pt *.txt *.mak *.mako *.js *.html *.xml
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: ./run
89 changes: 88 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,88 @@
# CF401-Project-1---PyListener
# PyListener

PyListener is an application written on the Python Pyramid framework, designed to assist people with apraxia communicate with loved-ones and caretakers using a series of pictograms translated to text and shareable via email or sms.

The purpose of this project was to create a visual communication tool in the form of a web-based app intended for use on mobile platforms to assist users with communication disabilities.
Instances include users with a communication disability such as Apraxia, a motor disorder in which the patient is unable to perform certain tasks or movements despite full understanding and willingness. In [Apraxia of speech](https://en.wikipedia.org/wiki/Apraxia_of_speech), patients have difficulty conveying ideas and thoughts from the brain to the spoken words. Apraxia of speech can manifest itself after incidents such as a stroke or trauma or be present in early infancy (Childhood Apraxia of Speech).


# How it works

A caregiver can register with a username, password, email, phone number and a profile picture. The caregiver is also prompted to enter the user's name.
Once registered, the caregiver becomes the primary contact for the user and a pictogram is created in the address book.

The account is immediately logged in and taken to the configuration page.
There, the caregiver can add or delete pictograms for contacts, categories and/or attributes. Fill the form with an image file, label, description (which will be used to build the sentence) and upload your customized pictogram.
Once done, simply click on the home button and you are ready to go!

The app comes with pre-loaded pictograms so any user can create an account and start building sentences right away.

The first screen for the user is the Address Book. There, the user can pick whom they wish to talk to. Once selected, it takes you to the second screen: Categories. There, the user can select the subject of the sentence. Which takes you to the third screen: Attributes. Attributes are always related to the category selected.

Once the sentence fully built, the user is taken to the fourth and final screen: Display.
The sentence will be, indeed, displayed and the user is offered three choices:
Send an SMS, send an Email or start over.

If the user picks SMS or Email, a message will immediately be sent to the contact selected at the begining of the sentence. If the user chooses to start over, they will be taken back to the first screen and can pick a new contact to talk to.

# How we built it

PyListener was created during our Code Fellows advanced python development midterm project by Ted Callahan, Maelle Vance and Rick Valenzuela. We had four days total to build the full application.

We chose the Pyramid framework for its robustness. We are currently looking to rebuild the application using Django as we have plan to expand.

We used Postgresql and sqlalchemy to build our database. The main challenge was to build all the relational databases as well as handling image uploads by users.

To send sms and emails, we used two external apis: [Twilio](https://github.com/twilio/twilio-python) and [Yagmail](https://github.com/kootenpv/yagmail). We are very thankful for their extensive documentation!

We deployed on Heroku: (http://pylistener.herokuapp.com/)

# How to run it yourself

Clone this repository into whatever directory you want to work from.

```bash
$ git clone https://github.com/PyListener/CF401-Project-1---PyListener.git
```

Assuming that you have access to Python 3 at the system level, start up a new virtual environment.

```bash
$ cd CF401-Project-1---PyListener
$ python3 -m venv venv
```

Open `venv/bin/activate` in your editor and pass your own environment variable as following :
- export DATABASE_URL= *your chosen database*
- export TEST_DB= *your test database*
- export EMAIL= *the gmail account you want to user to send emails from the app.*
- export PASSWORD= *your gmail password*
- export TWILIO_SID= *the twilio account sid you want to use to send emails from the app.*
- export TWILIO_TOKEN= *your twilio token*
- export TWILIO_NUMBER= *your twilio number in the following format: "+12345678910"*

Then activate your environment:

```bash
$ source venv/bin/activate
```

Once your environment has been activated, make sure to install the requirements:

```bash
(venv) $ pip install -e .
```

You are then ready to initialize your database and run the app!

```bash
$ initialize_db development.ini
$ pserve development.ini
```

# Special Thanks:

[Nicholas Hunt-Walker](https://github.com/nhuntwalker/)
[Twilio](https://github.com/twilio/twilio-python)
[Yagmail](https://github.com/kootenpv/yagmail)
Charlie, Maelle's son, who suffers from Apraxia
71 changes: 71 additions & 0 deletions development.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
###
# app configuration
# http://docs.pylonsproject.org/projects/pyramid/en/1.7-branch/narr/environment.html
###

[app:main]
use = egg:pylistener

pyramid.reload_templates = true
pyramid.debug_authorization = false
pyramid.debug_notfound = false
pyramid.debug_routematch = false
pyramid.default_locale_name = en
pyramid.includes =
pyramid_debugtoolbar

; sqlalchemy.url = os.environ["DATABASE_URL"]


# By default, the toolbar only appears for clients from IP addresses
# '127.0.0.1' and '::1'.
# debugtoolbar.hosts = 127.0.0.1 ::1

###
# wsgi server configuration
###

[server:main]
use = egg:waitress#main
host = 127.0.0.1
port = 6543

###
# logging configuration
# http://docs.pylonsproject.org/projects/pyramid/en/1.7-branch/narr/logging.html
###

[loggers]
keys = root, pylistener, sqlalchemy

[handlers]
keys = console

[formatters]
keys = generic

[logger_root]
level = INFO
handlers = console

[logger_pylistener]
level = DEBUG
handlers =
qualname = pylistener

[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine
# "level = INFO" logs SQL queries.
# "level = DEBUG" logs SQL queries and results.
# "level = WARN" logs neither. (Recommended for production systems.)

[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic

[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s:%(lineno)s][%(threadName)s] %(message)s
68 changes: 68 additions & 0 deletions production.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
###
# app configuration
# http://docs.pylonsproject.org/projects/pyramid/en/1.7-branch/narr/environment.html
###

[app:pylistener]
use = egg:pylistener

pyramid.reload_templates = false
pyramid.debug_authorization = false
pyramid.debug_notfound = false
pyramid.debug_routematch = false
pyramid.default_locale_name = en

sqlalchemy.url = sqlite:///%(here)s/pylistener.sqlite

[filter:paste_prefix]
use = egg:PasteDeploy#prefix

[pipeline:main]
pipeline =
paste_prefix
pylistener

[server:main]
use = egg:waitress#main
host = 0.0.0.0
port = 6543

###
# logging configuration
# http://docs.pylonsproject.org/projects/pyramid/en/1.7-branch/narr/logging.html
###

[loggers]
keys = root, pylistener, sqlalchemy

[handlers]
keys = console

[formatters]
keys = generic

[logger_root]
level = WARN
handlers = console

[logger_pylistener]
level = WARN
handlers =
qualname = pylistener

[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine
# "level = INFO" logs SQL queries.
# "level = DEBUG" logs SQL queries and results.
# "level = WARN" logs neither. (Recommended for production systems.)

[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic

[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s:%(lineno)s][%(threadName)s] %(message)s
15 changes: 15 additions & 0 deletions pylistener/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from pyramid.config import Configurator
import os

def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
if "sqlalchemy.url" not in settings:
settings["sqlalchemy.url"] = os.environ["DATABASE_URL"]
config = Configurator(settings=settings)
config.include('pyramid_jinja2')
config.include('.models')
config.include('.routes')
config.include('.security')
config.scan()
return config.make_wsgi_app()
73 changes: 73 additions & 0 deletions pylistener/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
from sqlalchemy import engine_from_config
from sqlalchemy.orm import sessionmaker
from sqlalchemy.orm import configure_mappers
import zope.sqlalchemy

# import or define all models here to ensure they are attached to the
# Base.metadata prior to any initialization routines
from .mymodel import User, AddressBook, Attribute, Category, UserAttributeLink # noqa

# run configure_mappers after defining all of the models to ensure
# all relationships can be setup
configure_mappers()


def get_engine(settings, prefix='sqlalchemy.'):
return engine_from_config(settings, prefix)


def get_session_factory(engine):
factory = sessionmaker()
factory.configure(bind=engine)
return factory


def get_tm_session(session_factory, transaction_manager):
"""
Get a ``sqlalchemy.orm.Session`` instance backed by a transaction.

This function will hook the session to the transaction manager which
will take care of committing any changes.

- When using pyramid_tm it will automatically be committed or aborted
depending on whether an exception is raised.

- When using scripts you should wrap the session in a manager yourself.
For example::

import transaction

engine = get_engine(settings)
session_factory = get_session_factory(engine)
with transaction.manager:
dbsession = get_tm_session(session_factory, transaction.manager)

"""
dbsession = session_factory()
zope.sqlalchemy.register(
dbsession, transaction_manager=transaction_manager)
return dbsession


def includeme(config):
"""
Initialize the model for a Pyramid app.

Activate this setup using ``config.include('pylistener.models')``.

"""
settings = config.get_settings()

# use pyramid_tm to hook the transaction lifecycle to the request
config.include('pyramid_tm')

session_factory = get_session_factory(get_engine(settings))
config.registry['dbsession_factory'] = session_factory

# make request.dbsession available for use in Pyramid
config.add_request_method(
# r.tm is the transaction manager used by pyramid_tm
lambda r: get_tm_session(session_factory, r.tm),
'dbsession',
reify=True
)
16 changes: 16 additions & 0 deletions pylistener/models/meta.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.schema import MetaData

# Recommended naming convention used by Alembic, as various different database
# providers will autogenerate vastly different names making migrations more
# difficult. See: http://alembic.zzzcomputing.com/en/latest/naming.html
NAMING_CONVENTION = {
"ix": 'ix_%(column_0_label)s',
"uq": "uq_%(table_name)s_%(column_0_name)s",
"ck": "ck_%(table_name)s_%(constraint_name)s",
"fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
"pk": "pk_%(table_name)s"
}

metadata = MetaData(naming_convention=NAMING_CONVENTION)
Base = declarative_base(metadata=metadata)
Loading