This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from my_app.models import * | |
my_books = Book.objects.all() #Search in Book only. | |
my_collection = Collection.objects.all() #Search in all collection. | |
for elem in my_collection: | |
if elem.categorie == 'book': | |
print(elem.book.author, elem.book.title) | |
else: | |
print(elem.music.artist, elem.music.album) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## For Debian (jessie) | |
## Maintener: Anton Millescamps <[email protected]> | |
## Create source.list file. | |
echo -e "\n# Tor" >> /etc/apt/sources.list | |
echo "deb https://deb.torproject.org/torproject.org jessie main" >> /etc/apt/sources.list | |
echo "deb-src https://deb.torproject.org/torproject.org jessie main" >> /etc/apt/sources.list | |
## Import gpg key. | |
gpg --keyserver keys.gnupg.net --recv 886DDD89 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from apize.decorators import apize_raw | |
api_url = 'http://mafreebox.freebox.fr/api/v3' | |
@apize_raw(api_url + '/lan/browser/pub/') | |
def get_lan_host(session_token): | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import time | |
from apize.apize import Apize | |
app = Apize('http://mafreebox.freebox.fr/api/v3') | |
@app.call('/phone/fxs_ring_start/', method='POST') | |
def call_start(session_token): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import hmac | |
from apize.apize import Apize | |
app = Apize('http://mafreebox.freebox.fr/api/v3') | |
@app.call('/login/session/', method='POST') | |
def connect_app(app_token, app_id, challenge): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from apize.decorators import apize_raw | |
api_url = 'http://mafreebox.freebox.fr/api/v3' | |
@apize_raw(api_url + '/login/authorize/', method='POST') | |
def get_authorization(): | |
data = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
A noter qu'il s'agit d'un exemple. Par exemple si vous ne souhaitez modifier que | |
l'en-tête X-FRAME-OPTIONS, django à prévu le coup: | |
https://github.com/django/django/blob/master/django/views/decorators/clickjacking.py | |
''' | |
def complete_headers(view_func): | |
def wrapped_view(*args, **kwargs): | |
#Objet HTTPResponse retourné par render. | |
response = view_func(*args, **kwargs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
from django.contrib.auth.models import AbstractBaseUser | |
from django.contrib.auth.models import BaseUserManager | |
from django.contrib.auth.models import PermissionsMixin | |
''' | |
In this example, create usermodel who use email and password for login. | |
Don't forget to add in settings.py: | |
AUTH_USER_MODEL='your_app.UserModel' |