Commit ac3e5414 authored by Grizzly's avatar Grizzly Committed by graillot

Commit initial

## Re2o - DHCP
This service uses Re2o API to generate DHCP leases files
## Requirements
* python3
* requirements in
hostname =
username = passoir
password = plopplop
hostname =
username = my_api_username
password = my_api_password
#!/usr/bin/env python3
from configparser import ConfigParser
import socket
from re2oapi import Re2oAPIClient
from django.core.mail import send_mail
from django.template import loader, Context
from pprint import pprint
config = ConfigParser()'config.ini')
api_hostname = config.get('Re2o', 'hostname')
api_password = config.get('Re2o', 'password')
api_username = config.get('Re2o', 'username')
api_client = Re2oAPIClient(api_hostname,api_username,api_password)
client_hostname = socket.gethostname().split('.',1)[0]
def notif_end_adhesion(api_client):
asso_options = api_client.list("preferences/assooption")
from_mail = api_client.list("preferences/generaloption")["email_from"]
template = loader.get_template('email_fin_adhesion')
for result in api_client.list("reminder/get-users"):
for user in result["users_to_remind"]:
context = Context({
'nom': user["get_full_name"],
'temps': result["days"],
'asso_name': asso_options["name"],
'link': asso_options["site_url"]
print('mail envoyé à {}, reminder {} days'.format(user["get_full_name"],result["days"]))
send_mail("Avis de fin d'adhésion / End of subscription notice",
html_message = template.render(context)
## Re2o - API client
This project is providing an abstraction layer to easily use the API of Re2o.
## Requirements
* python3
* python3-iso8601
from .re2oapi import *
from .client import Re2oAPIClient
from . import exceptions
__all__ = ['Re2oAPIClient', 'exceptions']
This diff is collapsed.
class APIClientGenericError(ValueError):
template = "{}"
def __init__(self, *data): = data
self.message = self.template.format(*data)
super(APIClientGenericError, self).__init__(self.message)
class InvalidCredentials(APIClientGenericError):
template = "The credentials for {}@{} are not valid."
class PermissionDenied(APIClientGenericError):
template = "The {} request to '{}' was denied for {}."
class TokenFileNotFound(APIClientGenericError):
template = "Token file at {} not found."
class TokenFileNotReadable(APIClientGenericError):
template = "Token file at {} is not a JSON readable file."
class TokenNotInTokenFile(APIClientGenericError):
template = "Token for {}@{} not found in token file ({})."
<p>Bonjour {{nom}},</p>
<P>Ton adhésion arrive à son therme dans {{temps}} jours.</P>
{% if online %}
<p>Tu peux renouveller ton adhésion en ligne sur <a href"{{link}}">Mon Profil</a>.</p>
<p>Tu peux également contacter un membre de {{asso_name}} pour renouveller ton adhésion</p>
{% else %}
<p>Pour renouveller ton adhésion, contacte un membre de {{asso_name}}.</p>
{% endif %}
<p>A bientôt.</p>
<p>Hi {{nom}},</p>
<P>Your subscription comes to an end in {{temps}} days.</P>
{% if online %}
<p>You can renew it online on <a href"{{link}}">My Profil</a>.</p>
<p>You can also contat a member of {{asso_name}} to renew it.</p>
{% else %}
<p>To renew it, contact a member of {{asso_name}}</p>
{% endif %}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment