Skip to content

Commit

Permalink
pushbullet integration
Browse files Browse the repository at this point in the history
  • Loading branch information
FoxMaSk committed Jun 11, 2016
1 parent c6d1c50 commit bff1440
Show file tree
Hide file tree
Showing 20 changed files with 693 additions and 24 deletions.
61 changes: 41 additions & 20 deletions django_th/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,16 @@
"CLIENT_CLASS": "django_redis.client.DefaultClient",
}
},
# Pushbullet
'th_pushbullet':
{
'TIMEOUT': 3600,
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://127.0.0.1:6379/12",
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
}
},
'redis-cache':
{
'TIMEOUT': 3600,
Expand Down Expand Up @@ -337,23 +347,19 @@
TH_SERVICES = (
# uncomment the lines to enable the service you need
'th_rss.my_rss.ServiceRss',
'th_pocket.my_pocket.ServicePocket',
# 'th_pocket.my_pocket.ServicePocket',
# 'th_evernote.my_evernote.ServiceEvernote',
# 'th_readability.my_readability.ServiceReadability',
# 'th_twitter.my_twitter.ServiceTwitter',
# 'th_trello.my_trello.ServiceTrello',
# 'th_github.my_github.ServiceGithub',
# 'th_pelican.my_pelican.ServicePelican',
# 'th_wallabag.my_wallabag.ServiceWallabag',
# 'th_todoist.my_todoist.ServiceTodoist',
'th_pushbullet.my_pushbullet.ServicePushbullet',
'th_wallabag.my_wallabag.ServiceWallabag',
)


TH_POCKET = {
# get your credential by subscribing to http://getpocket.com/developer/
'consumer_key': '<your pocket key>',
}


TH_EVERNOTE = {
# get your credential by subscribing to http://dev.evernote.com/
# for testing purpose set sandbox to True
Expand All @@ -363,32 +369,47 @@
'consumer_secret': '<your evernote secret>',
}

# not python 3 compliant

TH_GITHUB = {
'username': 'username',
'password': 'password',
'consumer_key': 'my key',
'consumer_secret': 'my secret'
}


TH_POCKET = {
# get your credential by subscribing to http://getpocket.com/developer/
'consumer_key': '<your pocket key>',
}

TH_PUSHBULLET = {
'consumer_key': '<your pushbullet key>',
'consumer_secret': '<your pushbullet secret>',
}

TH_READABILITY = {
# get your credential by subscribing to
# https://www.readability.com/settings/account
'consumer_key': '<your readability key>',
'consumer_secret': '<your readability secret>',
}


TH_TWITTER = {
# get your credential by subscribing to
# https://dev.twitter.com/
'consumer_key': '<your twitter key>',
'consumer_secret': '<your twitter secret>',
TH_TODOIST = {
'client_id': '<your todoist key>',
'client_secret': '<your todoist secret>',
}

TH_TRELLO = {
'consumer_key': '<your twitter key>',
'consumer_secret': '<your twitter secret>',
}

TH_GITHUB = {
'username': 'username',
'password': 'password',
'consumer_key': 'my key',
'consumer_secret': 'my secret'
TH_TWITTER = {
# get your credential by subscribing to
# https://dev.twitter.com/
'consumer_key': '<your twitter key>',
'consumer_secret': '<your twitter secret>',
}

SECRET_KEY = 'to be defined :P'
Expand Down
6 changes: 5 additions & 1 deletion django_th/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@
{'service_name': 'ServiceTodoist', },
name="todoist_callback",
),

url(r"^th/callbackpushbullet/$",
"django_th.views_wizard.finalcallback",
{'service_name': 'ServicePushbullet', },
name="pushbullet_callback",
),
url(r'^th/myfeeds/', include('th_rss.urls')),
)

Expand Down
2 changes: 2 additions & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ add the module django_th, and its friends, to the INSTALLED_APPS
# 'th_search', # then follow instructions from http://django-haystack.readthedocs.org/
# 'th_pelican',
# 'th_wallabag',
# 'th_todoist',
# 'th_pushbullet',
)
Expand Down
8 changes: 6 additions & 2 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ for wallabag support

* `wallabag_api <https://pypi.python.org/pypi/wallabag_api>`_ == 1.1.0

fro todoist support
for todoist support

* `todoist-python <https://pypi.python.org/pypi/todoist-python>`_ == 7.0
* `todoist-python <https://pypi.python.org/pypi/todoist-python>`_ == 7.0

for pushbullet support

* `pushbullet.py <https://pypi.python.org/pypi/pushbullet.py>`_ == 0.10.0
94 changes: 94 additions & 0 deletions docs/pushbullet.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
Pushbullet
==========

Service Description:
--------------------

Your devices working better together

Nota : to be able to work, this service requires that your host uses HTTPS

modifications of settings.py
----------------------------

1) INSTALLED_APPS :

.. code-block:: python
INSTALLED_APPS = (
'th_pushbullet',
)
2) Cache :

After the default cache add :

.. code-block:: python
CACHES = {
'default':
{
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
'LOCATION': BASE_DIR + '/cache/',
'TIMEOUT': 600,
'OPTIONS': {
'MAX_ENTRIES': 1000
}
},
# Pushbullet Cache
'th_pushbullet':
{
'TIMEOUT': 500,
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://127.0.0.1:6379/12",
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
}
},
3) TH_SERVICES
add this line to the TH_SERVICES setting
.. code-block:: python
TH_SERVICES = (
'th_pushbullet.my_pushbullet.ServicePushbullet',
)
4) The service keys
I strongly recommend that your put the following in a local_settings.py, to avoid to accidentally push this to a public repository
.. code-block:: python
TH_PUSHBULLET = {
# get your credential by subscribing to
# https://www.pushbullet.com/#settings/clients
'client_id': '<your pushbulet id>',
'client_secret': '<your pushbulet secret>',
}
creation of the table of the services
-------------------------------------
enter the following command
.. code-block:: bash
python manage.py migrate
from the admin panel, activation of the service
-----------------------------------------------
from http://yourdomain.com/admin/django_th/servicesactivated/add/
* Select "Pushbullet",
* Set the Status to "Enabled"
* Check Auth Required: this will permit to redirect to the user (or you) to Twitter to ask to confirm the access to his/your Pushbullet account
* Fill a description
1 change: 1 addition & 0 deletions docs/services.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ For all the services, the installation is the same :
holidays
pelican
pocket
pushbullet
readability
rss
search
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ twython==3.4.0
wallabag_api==1.1.0
flake8==2.5.4
todoist-python==7.0
pushbullet.py==0.10.0
8 changes: 7 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,17 @@
extras_require_todoist = [
'todoist-python==7.0',
]
extras_require_pushbullet = [
'pushbullet.py==0.10.0'
]


extras_require_all = extras_require_github\
+ extras_require_pocket + extras_require_readability + extras_require_rss\
+ extras_require_search + extras_require_trello + extras_require_twitter\
+ extras_require_pelican + extras_require_wallabag\
+ extras_require_evernote + extras_require_todoist
+ extras_require_evernote + extras_require_todoist\
+ extras_require_pushbullet

setup(
name='django_th',
Expand Down Expand Up @@ -92,6 +97,7 @@
'pelican': extras_require_pelican,
'wallabag': extras_require_wallabag,
'todoist': extras_require_todoist,
'pushbullet': extras_require_pushbullet,
},
include_package_data=True,
)
Empty file added th_pushbullet/__init__.py
Empty file.
38 changes: 38 additions & 0 deletions th_pushbullet/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# coding: utf-8

from django import forms

from django.forms import TextInput
from th_pushbullet.models import Pushbullet

PUSH_TYPE = (('note', 'Note'), ('link', 'Link'), ('file', 'File'))


class PushbulletForm(forms.ModelForm):

"""
for to handle Todoist service
"""
type = forms.ChoiceField(widget=forms.Select(
attrs={'class': 'form-control'}))

class Meta:
model = Pushbullet
fields = ('type', 'device', 'email', 'channel_tag')
widgets = {
'device': TextInput(attrs={'class': 'form-control'}),
'email': TextInput(attrs={'class': 'form-control'}),
'channel_tag': TextInput(attrs={'class': 'form-control'}),
}

def __init__(self, *args, **kwargs):
super(PushbulletForm, self).__init__(*args, **kwargs)
self.fields['type'].choices = PUSH_TYPE


class PushbulletProviderForm(PushbulletForm):
pass


class PushbulletConsumerForm(PushbulletForm):
pass
35 changes: 35 additions & 0 deletions th_pushbullet/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


class Migration(migrations.Migration):

dependencies = [
('django_th', '__first__'),
]

operations = [
migrations.CreateModel(
name='Pushbullet',
fields=[
('id', models.AutoField(verbose_name='ID', auto_created=True, serialize=False, primary_key=True)),
('name', models.CharField(max_length=255)),
('type', models.CharField(max_length=4)),
('device', models.CharField(max_length=80, blank=True)),
('email', models.EmailField(max_length=255, blank=True)),
('channel_tag', models.CharField(max_length=80, blank=True)),
('status', models.BooleanField(default=False)),
('description', models.CharField(max_length=255)),
],
options={
'db_table': 'django_th_pushbullet',
},
),
migrations.AddField(
model_name='pushbullet',
name='trigger',
field=models.ForeignKey(to='django_th.TriggerService'),
),
]
Empty file.
25 changes: 25 additions & 0 deletions th_pushbullet/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# coding: utf-8
from django.db import models
from django_th.models.services import Services


class Pushbullet(Services):

"""
todoist model to be adapted for the new service
"""
type = models.CharField(max_length=4, default='note')
device = models.CharField(max_length=80, blank=True)
email = models.EmailField(max_length=255, blank=True)
channel_tag = models.CharField(max_length=80, blank=True)
trigger = models.ForeignKey('TriggerService')

class Meta:
app_label = 'django_th'
db_table = 'django_th_pushbullet'

def __str__(self):
return self.name

def show(self):
return "My Pushbullet %s" % self.name
Loading

0 comments on commit bff1440

Please sign in to comment.