Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade dependencies to match quality checklist #61

Merged
merged 5 commits into from
May 13, 2020
Merged
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
3 changes: 2 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Coverage configuration file

[run]
source = .
source =
airtng_flask

omit =
*/migrations/*
Expand Down
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
TWILIO_ACCOUNT_SID=Your-Account-SID
TWILIO_AUTH_TOKEN=Your-Twilio-Auth-Token
TWILIO_NUMBER=Your-Twilio-Phone-Number
34 changes: 34 additions & 0 deletions .github/workflows/flask.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Flask

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.6, 3.7, 3.8]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install coveralls
- name: Set up project
run: |
python manage.py db upgrade
- name: Run Tests
run: |
coverage run manage.py test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ __pycache__/
*.so

# Distribution / packaging
venv
.Python
env/
ivr-env/
Expand Down Expand Up @@ -63,3 +64,5 @@ target/

.idea
dev.sqlite

.vscode
13 changes: 13 additions & 0 deletions .mergify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
pull_request_rules:
- name: automatic merge for Dependabot pull requests
conditions:
- author=dependabot-preview[bot]
- status-success=build (macos-latest, 10)
- status-success=build (macos-latest, 12)
- status-success=build (windows-latest, 10)
- status-success=build (windows-latest, 12)
- status-success=build (ubuntu-latest, 10)
- status-success=build (ubuntu-latest, 12)
actions:
merge:
method: squash
10 changes: 0 additions & 10 deletions .travis.yml

This file was deleted.

73 changes: 73 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

- The use of sexualized language or imagery and unwelcome sexual attention or
advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at open-source@twilio.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Contributing to Twilio

All third party contributors acknowledge that any contributions they provide will be made under the same open source license that the open source project is provided under.
37 changes: 18 additions & 19 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
Copyright (c) 2012 Twilio, Inc.
MIT License

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
Copyright (c) 2020 Twilio Inc.

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
38 changes: 22 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Airtng App: Part 1 - Workflow Automation with Python | Flask
> We are currently in the process of updating this sample template. If you are encountering any issues with the sample, please open an issue at [github.com/twilio-labs/code-exchange/issues](https://github.com/twilio-labs/code-exchange/issues) and we'll try to help you.

[![Build Status](https://travis-ci.org/TwilioDevEd/airtng-flask.svg?branch=master)](https://travis-ci.org/TwilioDevEd/airtng-flask)
![](https://github.com/TwilioDevEd/airtng-flask/workflows/Flask/badge.svg)


Learn how to automate your workflow using Twilio's REST API and Twilio SMS. This example app is a vacation rental site, where the host can confirm a reservation via SMS.
Expand All @@ -17,6 +17,13 @@ Learn how to automate your workflow using Twilio's REST API and Twilio SMS. This

Remember that the number where you change the _SMS webhook_ must be the same one you set on the `TwilioPhoneNumber` setting.

![Configure Messaging](webhook.png)

You need to expose your application to the wider internet using [ngrok](https://ngrok.com/download).
This step is important because the application won't work as expected if you run it through localhost.

> [Learn 6 awesome reasons why to use ngrok](https://www.twilio.com/blog/2015/09/6-awesome-reasons-to-use-ngrok-when-testing-webhooks.html).

To start using `ngrok` in our project you'll have execute to the following line in the _command prompt_.
po5i marked this conversation as resolved.
Show resolved Hide resolved

```
Expand All @@ -29,13 +36,13 @@ Learn how to automate your workflow using Twilio's REST API and Twilio SMS. This
http://<your-ngrok-subdomain>.ngrok.io/confirm
```

1. Clone this repository and `cd` into it.
2. Clone this repository and `cd` into it.

```
git clone git@github.com:TwilioDevEd/airtng-flask.git
```

1. Create a new virtual environment.
3. Create a new virtual environment.

- If using vanilla [virtualenv](https://virtualenv.pypa.io/en/latest/):

Expand All @@ -50,35 +57,35 @@ Learn how to automate your workflow using Twilio's REST API and Twilio SMS. This
mkvirtualenv airtng-flask
```

1. Install the requirements.
4. Install the requirements.

```
pip install -r requirements.txt
```

1. Edit the following keys/values for the `config.py` file inside the `airtng_flask/` directory. Be sure to replace the place holders and connection string with real information. Replace the connection string preferably under development config.
5. Copy the sample configuration `.env.example` to `.env`, and then edit `.env` to match your configuration.

```
TWILIO_ACCOUNT_SID = 'your_twilio_account_sid'
TWILIO_AUTH_TOKEN = 'your_twilio_auth_token'
TWILIO_NUMBER = 'your_twilio_phone_number'
```bash
cp .env.example .env
```

SQLALCHEMY_DATABASE_URI = 'sqlite://'
```
You can find your `TWILIO_ACCOUNT_SID` and `TWILIO_AUTH_TOKEN` in your
[Twilio Account Settings](https://www.twilio.com/console).
You will also need a `TWILIO_PHONE_NUMBER`, which you may find [here](https://www.twilio.com/console/phone-numbers/incoming).
po5i marked this conversation as resolved.
Show resolved Hide resolved

1. Run the migrations.
6. Run the migrations.

```
python manage.py db upgrade
```

1. Start the development server.
7. Start the development server.

```
python manage.py runserver
```

1. Check it out at [http://localhost:5000](http://localhost:5000)
8. Check it out at [http://localhost:5000](http://localhost:5000)


That's it!
Expand All @@ -87,8 +94,6 @@ That's it!

You can run the tests locally through [coverage](http://coverage.readthedocs.org/):

1. Run the tests.

```
$ coverage run manage.py test
```
Expand All @@ -98,5 +103,6 @@ You can then view the results with `coverage report` or build an HTML report wit
## Meta

* No warranty expressed or implied. Software is as is. Diggity.
* The CodeExchange repository can be found [here](https://github.com/twilio-labs/code-exchange/).
* [MIT License](http://www.opensource.org/licenses/mit-license.html)
* Lovingly crafted by Twilio Developer Education.
5 changes: 3 additions & 2 deletions airtng_flask/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from airtng_flask.config import config_env_files
from flask import Flask

from flask.ext.bcrypt import Bcrypt
from flask.ext.sqlalchemy import SQLAlchemy
from flask_bcrypt import Bcrypt
from flask_sqlalchemy import SQLAlchemy
from flask_login import LoginManager

db = SQLAlchemy()
Expand All @@ -14,6 +14,7 @@
def create_app(config_name='development', p_db=db, p_bcrypt=bcrypt, p_login_manager=login_manager):
new_app = Flask(__name__)
config_app(config_name, new_app)
new_app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

p_db.init_app(new_app)
p_bcrypt.init_app(new_app)
Expand Down
8 changes: 5 additions & 3 deletions airtng_flask/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

basedir = os.path.abspath(os.path.dirname(__file__))

from dotenv import load_dotenv
load_dotenv()

class DefaultConfig(object):
SECRET_KEY = 'secret-key'
DEBUG = False
SQLALCHEMY_DATABASE_URI = 'sqlite://'
TWILIO_ACCOUNT_SID = 'your_twilio_account_sid'
TWILIO_AUTH_TOKEN = 'your_twilio_auth_token'
TWILIO_NUMBER = 'your_twilio_number'
TWILIO_ACCOUNT_SID = os.getenv('TWILIO_ACCOUNT_SID')
TWILIO_AUTH_TOKEN = os.getenv('TWILIO_AUTH_TOKEN')
TWILIO_NUMBER = os.getenv('TWILIO_NUMBER')


class DevelopmentConfig(DefaultConfig):
Expand Down
5 changes: 2 additions & 3 deletions airtng_flask/forms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from flask_wtf import Form
from flask_wtf import FlaskForm as Form
from wtforms import TextField, PasswordField, IntegerField, HiddenField
from wtforms.validators import DataRequired, Length, Email, URL

Expand All @@ -19,8 +19,7 @@ class RegisterForm(Form):
)
country_code = TextField(
'Country Code:',
validators=[DataRequired("Country code is required"),
Length(min=1, max=4, message="Country code must be between 1 and 4 numbers")]
validators=[Length(min=1, max=4, message="Country code must be between 1 and 4 numbers")]
)

phone_number = IntegerField(
Expand Down
2 changes: 1 addition & 1 deletion airtng_flask/templates/property_new.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h1>New Vacation Property</h1>
<hr/>

{{ render_field(form.description, placeholder="Captain's Palace") }}
{{ render_field(form.image_url }}
{{ render_field(form.image_url) }}

<div class="actions">
<button type="submit" class="btn btn-lg btn-primary">Create Property</button>
Expand Down
2 changes: 1 addition & 1 deletion airtng_flask/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from airtng_flask import db, bcrypt, app, login_manager
from flask import session, g, request, flash, Blueprint
from flask.ext.login import login_user, logout_user, current_user, login_required
from flask_login import login_user, logout_user, current_user, login_required
from twilio.twiml.voice_response import VoiceResponse

from airtng_flask.forms import RegisterForm, LoginForm, VacationPropertyForm, ReservationForm, \
Expand Down
4 changes: 2 additions & 2 deletions manage.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from flask.ext.script import Manager
from flask.ext.migrate import Migrate, MigrateCommand
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand

from airtng_flask import app, db

Expand Down
Loading