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

3.0 #6

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
b386a66
upgraded for 2.0
josephmancuso Dec 4, 2019
d3fb5b2
removed travis
josephmancuso Dec 4, 2019
80710dd
added makefile
josephmancuso Dec 4, 2019
ad164e3
fixed package directory
josephmancuso Dec 4, 2019
faa22e0
linted
josephmancuso Dec 4, 2019
fc6ddef
added inits back
josephmancuso Dec 4, 2019
5c49050
bumped requirement
josephmancuso Dec 4, 2019
b82fdf6
added pytest
josephmancuso Dec 4, 2019
f38a802
trigger
josephmancuso Dec 4, 2019
02cd473
trigger
josephmancuso Dec 4, 2019
3b55506
fixed pythonapp
josephmancuso Dec 4, 2019
12490c5
fixed env
josephmancuso Dec 4, 2019
bbd03dd
bumped
josephmancuso Dec 4, 2019
a98b9c6
edit init in Makefile and add all Github Actions
Aug 12, 2020
f483f36
add black for formatting
Aug 12, 2020
064bbd3
add basic pytest config
Aug 12, 2020
73f7d19
add .env template file
Aug 12, 2020
b35d50e
add README with badges
Aug 13, 2020
9eaee34
add more tests and ability to switch driver and channel on the fly
girardinsamuel Oct 14, 2020
533a899
start testing new refactoring of notifications package
girardinsamuel Oct 14, 2020
3e85345
Complete refactoring phase 1
girardinsamuel Oct 15, 2020
270f14d
refactor broadcast_driver
girardinsamuel Oct 15, 2020
63a6f1a
add database driver
girardinsamuel Oct 15, 2020
751af29
add better tests
girardinsamuel Oct 15, 2020
11792a8
ignore coverage files
girardinsamuel Oct 24, 2020
70ec8f8
refactor
girardinsamuel Oct 24, 2020
759a384
start refactoring last official driver: slack
girardinsamuel Oct 24, 2020
a819896
add basic slack notifications with tests and add fail_siilently
girardinsamuel Oct 24, 2020
cd789ed
start adding nexmo driver
girardinsamuel Oct 24, 2020
632a5eb
start adding vonage driver
girardinsamuel Oct 24, 2020
2e076c2
add correct routing for vonage driver
girardinsamuel Oct 24, 2020
3d8d86f
update nexmo driver and start adding tests
girardinsamuel Oct 24, 2020
d29077c
update vonage driver and tests
girardinsamuel Oct 25, 2020
460f987
update tests for vonage
girardinsamuel Oct 25, 2020
c5e0e32
fix database notications tests
girardinsamuel Oct 25, 2020
bcdbd01
fix last database notications tests
girardinsamuel Oct 25, 2020
df4e948
all tests ok
girardinsamuel Oct 25, 2020
d89580f
fix linting
girardinsamuel Oct 25, 2020
dfac185
remove bare exceptions and add package exceptions
girardinsamuel Oct 25, 2020
6185d86
reformat tests
girardinsamuel Oct 25, 2020
31e017f
add missing tests for sending on-demand notifications
girardinsamuel Oct 25, 2020
16486b1
add way to use custom notification class
girardinsamuel Oct 25, 2020
1a60654
start adding test for custom driver and fix channels overrides
girardinsamuel Oct 25, 2020
6f50bda
complete tests for custom driver registering
girardinsamuel Oct 25, 2020
f6c32fe
revert mock on drivers after tests end
girardinsamuel Oct 25, 2020
7a098af
set mail driver to terminal in ci
girardinsamuel Oct 25, 2020
1a17dcd
drop python 3.5 support
girardinsamuel Oct 25, 2020
603bc48
fix workflow file
girardinsamuel Oct 25, 2020
868efe8
fix workflow file
girardinsamuel Oct 25, 2020
d007123
update setup and makefile
girardinsamuel Oct 25, 2020
4e69bbf
fix workflow again
girardinsamuel Oct 25, 2020
5c7f0e4
update gitignore
girardinsamuel Oct 25, 2020
1ba6e62
add pre masonite 3.0
girardinsamuel Oct 25, 2020
b0d552a
add missing license and update readme to new version
girardinsamuel Oct 25, 2020
55f12aa
add contributing guide
girardinsamuel Oct 25, 2020
cfa2882
update masonite dep
girardinsamuel Oct 25, 2020
e0e6e87
update req
girardinsamuel Oct 25, 2020
7c62638
update to masonite 3
girardinsamuel Jan 17, 2021
0dc1c14
ignore pyenv local file
girardinsamuel Jan 17, 2021
9b46fd9
start fixing morph relations
girardinsamuel Jan 17, 2021
efac930
fixes some tests
girardinsamuel Jan 17, 2021
d34cf58
fix tests
girardinsamuel Jan 23, 2021
5fd6c65
clean code
girardinsamuel Jan 23, 2021
18b92f5
re-add queueing mail notifications
girardinsamuel Jan 23, 2021
a4bb480
fix queueing notifications
girardinsamuel Jan 23, 2021
91f4965
fix queueing notifications
girardinsamuel Jan 23, 2021
08a3da0
remove debug statements
girardinsamuel Jan 23, 2021
c3dd156
fix tests
girardinsamuel Jan 24, 2021
20abed5
format tests
girardinsamuel Jan 24, 2021
a29ff0c
add all queue method for each drivers
girardinsamuel Jan 24, 2021
eeb0c36
complete slack notifications
girardinsamuel Jan 24, 2021
424d141
clean
girardinsamuel Jan 24, 2021
465fa41
fix coveralls upload
girardinsamuel Jan 24, 2021
b6f389a
add fixes
girardinsamuel Jan 24, 2021
643671a
add last fixes
girardinsamuel Jan 24, 2021
4a8e30e
rename Notify service to Notification
girardinsamuel Jan 24, 2021
3f4747b
add possibility to override driver
girardinsamuel Jan 24, 2021
fc065b3
clean
girardinsamuel Jan 25, 2021
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
7 changes: 7 additions & 0 deletions .env-example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
DB_DATABASE=test.db
DB_DRIVER=sqlite
DB_CONNECTION=sqlite

VONAGE_KEY=
VONAGE_SECRET=
SLACK_TOKEN=
40 changes: 40 additions & 0 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Test Application

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9"]
name: Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
make init
- name: Test with pytest and Build coverage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MAIL_DRIVER: terminal
run: |
make coverage
lint:
runs-on: ubuntu-latest
name: Lint
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.6
uses: actions/setup-python@v1
with:
python-version: 3.6
- name: Install Flake8
run: |
pip install flake8
- name: Lint
run: make lint
28 changes: 28 additions & 0 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Upload Python Package

on:
release:
types: [created]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
make init
make test
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
22 changes: 16 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
*.pyc
*__pycache__
venv
.DS_Store
.pytest_cache
masonite_notifications.*
dist/
venv2
.vscode
.idea/
build/
.pypirc
.coverage
coverage.xml
.pytest_*
.python-version
**/*__pycache__*
**/*.DS_Store*
**.pyc
dist
.env*
*.db
masonite_notifications.egg-info
*.sqlite3
9 changes: 0 additions & 9 deletions .travis.yml

This file was deleted.

130 changes: 130 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Contributing Guide

## Introduction

When contributing to this repository, **please first discuss the change you wish to make via issue, email, or any other method with the owners or contributors of this repository** before making a change 😃 . Thank you !

## Getting Started

### Get the code

First you should configure your local environment to be able to make changes in this package.

1. Fork the repo.
2. Clone that repo into your computer: `git clone http://github.com/MasoniteFramework/notifications.git`.
3. Checkout the current release branch `3.0`.
4. Run `git pull origin 3.0` to get the current release version.

### Install the environment

1. You should create a Python virtual environment with `Python >= 3.6`.
2. Then install the dependencies and setup the project, in root directory with:

```
make init
```

**Note:**

- The package will be locally installed in your venv (with `pip install .`). Meaning that you will be
able to import it from the project contained in the package as if you installed it from PyPi.
- When making changes to your packages you will need to uninstall the package and reinstall it with
`pip uninstall package && pip install .`

### Contribute

- From there simply create:
- a feature branch `feat/my-new-feature`
- a fix branch `fix/my-new-fix`
- Push to your origin repository:
- `git push origin feat/my-new-feature`
- Open a pull request (PR) and follow the PR process below

1. You should open an issue before making any pull requests. Not all features will be added to the package and some may be better off as another third party package. It wouldn't be good if you worked on a feature for several days and the pull request gets rejected for reasons that could have been discussed in an issue for several minutes.
2. Ensure any changes are well commented and any configuration files that are added have a flagpole comment on the variables it's setting.
3. Update the README.md if installation/configuration or usage has changed.
4. It's better to add unit tests for the changes you made.
5. The PR must pass Github CI checks. The PR can be merged in once you have a successful review from a maintainer.
6. The version will be bumped by the maintainer when merging, so don't edit package version in the PR.

### Testing

- To add unit tests add tests under `tests/` directory, please read about [Masonite
testing](https://docs.masoniteproject.com/useful-features/testing) in the official
documentation

- To test your package locally in a project, a default Masonite project is available
at root. Just run `python craft serve` and navigate to `localhost:8000/` and
you will see `Hello Package World` in your browser.

## Dev Guidelines

### Package development

You should read guidelines on package creation in the [Official Documentation](https://docs.masoniteproject.com/advanced/creating-packages)

### Comments

Comments are a vital part of any repository and should be used where needed. It is important not to overcomment something. If you find you need to constantly add comments, you're code may be too complex. Code should be self documenting \(with clearly defined variable and method names\)

#### Types of comments to use

There are 3 main type of comments you should use when developing for Masonite:

**Module Docstrings**

All modules should have a docstring at the top of every module file and should look something like:

```python
""" This is a module to add support for Billing users """
from masonite.request import Request
...
```

**Method and Function Docstrings**

All methods and functions should also contain a docstring with a brief description of what the module does

For example:

```python
def some_function(self):
"""
This is a function that does x action.
Then give an exmaple of when to use it
"""
... code ...
```

**Code Comments**

If you're code MUST be complex enough that future developers will not understand it, add a `#` comment above it

For normal code this will look something like:

```python
# This code performs a complex task that may not be understood later on
# You can add a second line like this
complex_code = 'value'

perform_some_complex_task()
```

**Flagpole Comments**

Flag pole comments are a fantastic way to give developers an inside to what is really happening and for now should only be reserved for configuration files. A flag pole comment gets its name from how the comment looks

```text
"""
|--------------------------------------------------------------------------
| A Heading of The Setting Being Set
|--------------------------------------------------------------------------
|
| A quick description
|
"""

SETTING = "some value"
```

It's important to note that there should have exactly 75 `-` above and below the header and have a trailing `|` at the bottom of the comment.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Joseph Mancuso

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 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.
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
include notifications/snippets/mail/*
graft src/masonite/notifications/snippets/
graft src/masonite/notifications/migrations/
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Masonite Notifications Package

<p align="center">
<img src="https://i.imgur.com/rEXcoMn.png" width="130px">
</p>

<p align="center">
<a href="https://docs.masoniteproject.com">
<img alt="Masonite Package" src="https://img.shields.io/static/v1?label=Masonite&message=package&labelColor=gr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l245/W9OnVrSY+O2eqPkyz4sVvHoKp9gOihf5KoAVv3hkQgbj/ihG9fI3RixKcUVx7lJVaEc0vnyf2FFll+ny80ZHZiGhIKowWJBCEAKr+FSuNDLt+lxybSF51lo74arqs113dOZqwsptxNs5bwi7Q3q8npSC2AWmvjTncZf1l61e5DEizNn5mtufpsqk5+CZTuq00sP1wkNPv8jeEikVVlJso+GEwRtNs3QeBt2YP2V2ZI3Tx0e+7T89zK5tNASOLEytJAryGtkLc2PcBM5byyUWYkMQpMioYcDcchC6xN220Iv36Ot8pV0454RHLEwmmD7UWfIdX0zq3GjMPG5NKBtv5qiPEPekK2U51j1451BZoc3i+1ohSQ/UzzG5uYFFn2mwVUnO4O3JblXA91T51l3pB3QweDl7sNXMyEjbguSjrPcQNmwDkNc8CbCvDd0+xCC7RFi9wFulD3mJeXqxQevB4prrqgc0TmQ85NG/K43e2UwnMVAJIEBNfWRYR3HfnvivrIzMyo4Hgy+hfscvLo53jItAAAAABJRU5ErkJggg==">
</a>
<img alt="GitHub Workflow Status (branch)" src="https://img.shields.io/github/workflow/status/MasoniteFramework/notifications/Test%20Application/master">
<img alt="Coveralls github branch" src="https://img.shields.io/coveralls/github/MasoniteFramework/notifications/master">
<img alt="PyPI" src="https://img.shields.io/pypi/v/notifications">
<img src="https://img.shields.io/badge/python-3.6+-blue.svg" alt="Python Version">
<img alt="GitHub release (latest by date)" src="https://img.shields.io/github/v/release/MasoniteFramework/notifications">
<img alt="License" src="https://img.shields.io/github/license/MasoniteFramework/notifications">
<a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
</p>

## Introduction

This is the official notifications package for Masonite allowing to quickly add notifications feature in
your application. Notifications can be sent accross `mail`, `slack`, `broadcast`, `database` and `vonage` (SMS)
channels by default.

## Official Documentation

Read the official documentation [here](https://docs.masoniteproject.com/official-packages/masonite-notifications).

Also be sure to join the [Slack channel](http://slack.masoniteproject.com/)!

## Contributing

Please read the [Contributing Documentation](CONTRIBUTING.md) here.

## License

Masonite Notifications Package is open-sourced software licensed under the [MIT License](LICENSE).
11 changes: 11 additions & 0 deletions app/User.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""User Model."""

from masoniteorm.models import Model


class User(Model):
"""User Model."""

__fillable__ = ['name', 'email', 'password']

__auth__ = 'email'
11 changes: 11 additions & 0 deletions app/http/controllers/PackageController.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
""" Welcome The User To Masonite """

from masonite.view import View
from masonite.request import Request


class PackageController:
"""Controller For Welcoming The User"""

def show(self, view: View, request: Request):
return "Hello World"
30 changes: 30 additions & 0 deletions app/http/middleware/AuthenticationMiddleware.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
""" Authentication Middleware """

from masonite.request import Request


class AuthenticationMiddleware:
"""Middleware To Check If The User Is Logged In
"""

def __init__(self, request: Request):
"""Inject Any Dependencies From The Service Container

Arguments:
Request {masonite.request.Request} -- The Masonite request object
"""

self.request = request

def before(self):
"""Run This Middleware Before The Route Executes
"""

if not self.request.user():
self.request.redirect_to('login')

def after(self):
"""Run This Middleware After The Route Executes
"""

pass
15 changes: 15 additions & 0 deletions app/http/middleware/CsrfMiddleware.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
""" CSRF Middleware """

from masonite.middleware import CsrfMiddleware as Middleware


class CsrfMiddleware(Middleware):
""" Verify CSRF Token Middleware """

exempt = [
'/api/user',
'/token',
'/jwt',
'/jwt/refresh',
'/authorize'
]
Loading