mirror of https://gitlab.federez.net/re2o/re2o
12 changed files with 79 additions and 580 deletions
@ -1,158 +0,0 @@ |
|||
{% extends "cotisations/sidebar.html" %} |
|||
{% comment %} |
|||
Re2o est un logiciel d'administration développé initiallement au rezometz. Il |
|||
se veut agnostique au réseau considéré, de manière à être installable en |
|||
quelques clics. |
|||
|
|||
Copyright © 2017 Gabriel Détraz |
|||
Copyright © 2017 Goulven Kermarec |
|||
Copyright © 2017 Augustin Lemesle |
|||
|
|||
This program is free software; you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation; either version 2 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License along |
|||
with this program; if not, write to the Free Software Foundation, Inc., |
|||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|||
{% endcomment %} |
|||
|
|||
{% load bootstrap3 %} |
|||
{% load staticfiles%} |
|||
{% load i18n %} |
|||
|
|||
{% block title %}{% trans "Invoices creation and edition" %}{% endblock %} |
|||
|
|||
{% block content %} |
|||
{% bootstrap_form_errors venteform.management_form %} |
|||
|
|||
<form class="form" method="post"> |
|||
{% csrf_token %} |
|||
<h3>{% trans "New invoice" %}</h3> |
|||
{{ venteform.management_form }} |
|||
<!-- TODO: FIXME to include data-type="check" for right option in id_cheque select --> |
|||
<h3>{% trans "Invoice's articles" %}</h3> |
|||
<div id="form_set" class="form-group"> |
|||
{% for form in venteform.forms %} |
|||
<div class='product_to_sell form-inline'> |
|||
{% trans "Article" %} : |
|||
{% bootstrap_form form label_class='sr-only' %} |
|||
|
|||
<button class="btn btn-danger btn-sm" id="id_form-0-article-remove" type="button"> |
|||
<span class="fa fa-times"></span> |
|||
</button> |
|||
</div> |
|||
{% endfor %} |
|||
</div> |
|||
<input class="btn btn-primary btn-sm" role="button" value="{% trans "Add an article"%}" id="add_one"> |
|||
<p> |
|||
{% blocktrans %} |
|||
Total price : <span id="total_price">0,00</span> € |
|||
{% endblocktrans %} |
|||
</p> |
|||
{% trans "Confirm" as tr_confirm %} |
|||
{% bootstrap_button tr_confirm button_type='submit' icon='star' %} |
|||
</form> |
|||
|
|||
<script type="text/javascript"> |
|||
|
|||
var prices = {}; |
|||
{% for article in articlelist %} |
|||
prices[{{ article.id|escapejs }}] = {{ article.prix }}; |
|||
{% endfor %} |
|||
|
|||
var template = `Article : |
|||
{% bootstrap_form venteform.empty_form label_class='sr-only' %} |
|||
|
|||
<button class="btn btn-danger btn-sm" id="id_form-__prefix__-article-remove" type="button"> |
|||
<span class="fa fa-times"></span> |
|||
</button>` |
|||
|
|||
function add_article(){ |
|||
// Index start at 0 => new_index = number of items |
|||
var new_index = |
|||
document.getElementsByClassName('product_to_sell').length; |
|||
document.getElementById('id_form-TOTAL_FORMS').value ++; |
|||
var new_article = document.createElement('div'); |
|||
new_article.className = 'product_to_sell form-inline'; |
|||
new_article.innerHTML = template.replace(/__prefix__/g, new_index); |
|||
document.getElementById('form_set').appendChild(new_article); |
|||
add_listenner_for_id(new_index); |
|||
} |
|||
|
|||
function update_price(){ |
|||
var price = 0; |
|||
var product_count = |
|||
document.getElementsByClassName('product_to_sell').length; |
|||
var article, article_price, quantity; |
|||
for (i = 0; i < product_count; ++i){ |
|||
article = document.getElementById( |
|||
'id_form-' + i.toString() + '-article').value; |
|||
if (article == '') { |
|||
continue; |
|||
} |
|||
article_price = prices[article]; |
|||
quantity = document.getElementById( |
|||
'id_form-' + i.toString() + '-quantity').value; |
|||
price += article_price * quantity; |
|||
} |
|||
document.getElementById('total_price').innerHTML = |
|||
price.toFixed(2).toString().replace('.', ','); |
|||
} |
|||
|
|||
function add_listenner_for_id(i){ |
|||
document.getElementById('id_form-' + i.toString() + '-article') |
|||
.addEventListener("change", update_price, true); |
|||
document.getElementById('id_form-' + i.toString() + '-article') |
|||
.addEventListener("onkeypress", update_price, true); |
|||
document.getElementById('id_form-' + i.toString() + '-quantity') |
|||
.addEventListener("change", update_price, true); |
|||
document.getElementById('id_form-' + i.toString() + '-article-remove') |
|||
.addEventListener("click", function(event) { |
|||
var article = event.target.parentNode; |
|||
article.parentNode.removeChild(article); |
|||
document.getElementById('id_form-TOTAL_FORMS').value --; |
|||
update_price(); |
|||
} |
|||
) |
|||
} |
|||
|
|||
function set_cheque_info_visibility() { |
|||
var paiement = document.getElementById("id_Facture-paiement"); |
|||
var visible = paiement.value == paiement.getAttribute('data-cheque'); |
|||
p = document.getElementById("id_Facture-paiement"); |
|||
var display = 'none'; |
|||
if (visible) { |
|||
display = 'block'; |
|||
} |
|||
document.getElementById("id_Facture-cheque") |
|||
.parentNode.style.display = display; |
|||
document.getElementById("id_Facture-banque") |
|||
.parentNode.style.display = display; |
|||
} |
|||
|
|||
// Add events manager when DOM is fully loaded |
|||
document.addEventListener("DOMContentLoaded", function() { |
|||
document.getElementById("add_one") |
|||
.addEventListener("click", add_article, true); |
|||
var product_count = |
|||
document.getElementsByClassName('product_to_sell').length; |
|||
for (i = 0; i < product_count; ++i){ |
|||
add_listenner_for_id(i); |
|||
} |
|||
document.getElementById("id_Facture-paiement") |
|||
.addEventListener("change", set_cheque_info_visibility, true); |
|||
set_cheque_info_visibility(); |
|||
update_price(); |
|||
}); |
|||
|
|||
</script> |
|||
|
|||
{% endblock %} |
|||
|
|||
@ -1,45 +0,0 @@ |
|||
{% extends "cotisations/sidebar.html" %} |
|||
{% comment %} |
|||
Re2o est un logiciel d'administration développé initiallement au rezometz. Il |
|||
se veut agnostique au réseau considéré, de manière à être installable en |
|||
quelques clics. |
|||
|
|||
Copyright © 2017 Gabriel Détraz |
|||
Copyright © 2017 Goulven Kermarec |
|||
Copyright © 2017 Augustin Lemesle |
|||
|
|||
This program is free software; you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation; either version 2 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License along |
|||
with this program; if not, write to the Free Software Foundation, Inc., |
|||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|||
{% endcomment %} |
|||
|
|||
{% load bootstrap3 %} |
|||
{% load staticfiles%} |
|||
{% load i18n %} |
|||
|
|||
{% block title %}{% trans "Balance refill" %}{% endblock %} |
|||
|
|||
{% block content %} |
|||
<h2>{% trans "Balance refill" %}</h2> |
|||
<h3> |
|||
{% blocktrans %} |
|||
Balance : <span class="label label-default">{{ solde }} €</span> |
|||
{% endblocktrans %} |
|||
</h3> |
|||
<form class="form" method="post"> |
|||
{% csrf_token %} |
|||
{% bootstrap_form rechargeform %} |
|||
{% trans "Confirm" as tr_confirm %} |
|||
{% bootstrap_button tr_confirm button_type='submit' icon='piggy-bank' %} |
|||
</form> |
|||
{% endblock %} |
|||
@ -1,94 +0,0 @@ |
|||
# coding:utf-8 |
|||
# Re2o est un logiciel d'administration développé initiallement au rezometz. Il |
|||
# se veut agnostique au réseau considéré, de manière à être installable en |
|||
# quelques clics. |
|||
# |
|||
# Copyright © 2017 Gabriel Détraz |
|||
# Copyright © 2017 Goulven Kermarec |
|||
# Copyright © 2017 Augustin Lemesle |
|||
# Copyright © 2018 Maël Kervella |
|||
# |
|||
# This program is free software; you can redistribute it and/or modify |
|||
# it under the terms of the GNU General Public License as published by |
|||
# the Free Software Foundation; either version 2 of the License, or |
|||
# (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU General Public License along |
|||
# with this program; if not, write to the Free Software Foundation, Inc., |
|||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|||
|
|||
# App de gestion des machines pour re2o |
|||
# Gabriel Détraz, Augustin Lemesle |
|||
# Gplv2 |
|||
"""preferences.aes_field |
|||
Module defining a AESEncryptedField object that can be used in forms |
|||
to handle the use of properly encrypting and decrypting AES keys |
|||
""" |
|||
|
|||
import string |
|||
import binascii |
|||
from random import choice |
|||
from Crypto.Cipher import AES |
|||
|
|||
from django.db import models |
|||
from django.conf import settings |
|||
|
|||
EOD = '`%EofD%`' # This should be something that will not occur in strings |
|||
|
|||
|
|||
def genstring(length=16, chars=string.printable): |
|||
""" Generate a random string of length `length` and composed of |
|||
the characters in `chars` """ |
|||
return ''.join([choice(chars) for i in range(length)]) |
|||
|
|||
|
|||
def encrypt(key, s): |
|||
""" AES Encrypt a secret `s` with the key `key` """ |
|||
obj = AES.new(key) |
|||
datalength = len(s) + len(EOD) |
|||
if datalength < 16: |
|||
saltlength = 16 - datalength |
|||
else: |
|||
saltlength = 16 - datalength % 16 |
|||
ss = ''.join([s, EOD, genstring(saltlength)]) |
|||
return obj.encrypt(ss) |
|||
|
|||
|
|||
def decrypt(key, s): |
|||
""" AES Decrypt a secret `s` with the key `key` """ |
|||
obj = AES.new(key) |
|||
ss = obj.decrypt(s) |
|||
return ss.split(bytes(EOD, 'utf-8'))[0] |
|||
|
|||
|
|||
class AESEncryptedField(models.CharField): |
|||
""" A Field that can be used in forms for adding the support |
|||
of AES ecnrypted fields """ |
|||
def save_form_data(self, instance, data): |
|||
setattr(instance, self.name, |
|||
binascii.b2a_base64(encrypt(settings.AES_KEY, data))) |
|||
|
|||
def to_python(self, value): |
|||
if value is None: |
|||
return None |
|||
return decrypt(settings.AES_KEY, |
|||
binascii.a2b_base64(value)).decode('utf-8') |
|||
|
|||
def from_db_value(self, value, *args, **kwargs): |
|||
if value is None: |
|||
return value |
|||
return decrypt(settings.AES_KEY, |
|||
binascii.a2b_base64(value)).decode('utf-8') |
|||
|
|||
def get_prep_value(self, value): |
|||
if value is None: |
|||
return value |
|||
return binascii.b2a_base64(encrypt( |
|||
settings.AES_KEY, |
|||
value |
|||
)) |
|||
@ -0,0 +1,47 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Generated by Django 1.10.7 on 2018-07-05 13:40 |
|||
from __future__ import unicode_literals |
|||
|
|||
from django.db import migrations |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('preferences', '0035_optionaluser_allow_self_subscription'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.RemoveField( |
|||
model_name='assooption', |
|||
name='payment', |
|||
), |
|||
migrations.RemoveField( |
|||
model_name='assooption', |
|||
name='payment_id', |
|||
), |
|||
migrations.RemoveField( |
|||
model_name='assooption', |
|||
name='payment_pass', |
|||
), |
|||
migrations.RemoveField( |
|||
model_name='optionaluser', |
|||
name='allow_self_subscription', |
|||
), |
|||
migrations.RemoveField( |
|||
model_name='optionaluser', |
|||
name='max_solde', |
|||
), |
|||
migrations.RemoveField( |
|||
model_name='optionaluser', |
|||
name='min_online_payment', |
|||
), |
|||
migrations.RemoveField( |
|||
model_name='optionaluser', |
|||
name='solde_negatif', |
|||
), |
|||
migrations.RemoveField( |
|||
model_name='optionaluser', |
|||
name='user_solde', |
|||
), |
|||
] |
|||
Loading…
Reference in new issue