Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
re2o
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nounous
re2o
Commits
a71e01e1
Commit
a71e01e1
authored
Jan 14, 2018
by
Gabriel Detraz
Committed by
root
Jan 28, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Montant minimal de rechargement + refactor de la fonction payment + self adhesion
parent
5319ed26
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
80 additions
and
7 deletions
+80
-7
cotisations/forms.py
cotisations/forms.py
+15
-0
cotisations/payment.py
cotisations/payment.py
+2
-1
cotisations/views.py
cotisations/views.py
+2
-2
preferences/forms.py
preferences/forms.py
+2
-0
preferences/migrations/0031_optionaluser_self_adhesion.py
preferences/migrations/0031_optionaluser_self_adhesion.py
+20
-0
preferences/migrations/0032_optionaluser_min_online_payment.py
...rences/migrations/0032_optionaluser_min_online_payment.py
+20
-0
preferences/models.py
preferences/models.py
+9
-0
preferences/templates/preferences/display_preferences.html
preferences/templates/preferences/display_preferences.html
+10
-4
No files found.
cotisations/forms.py
View file @
a71e01e1
...
...
@@ -41,6 +41,8 @@ from django.db.models import Q
from
django.forms
import
ModelForm
,
Form
from
django.core.validators
import
MinValueValidator
,
MaxValueValidator
from
.models
import
Article
,
Paiement
,
Facture
,
Banque
from
preferences.models
import
OptionalUser
from
users.models
import
User
from
re2o.field_permissions
import
FieldPermissionFormMixin
...
...
@@ -287,3 +289,16 @@ class RechargeForm(Form):
min_value
=
0.01
,
validators
=
[]
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
user
=
kwargs
.
pop
(
'user'
)
super
(
RechargeForm
,
self
).
__init__
(
*
args
,
**
kwargs
)
def
clean_value
(
self
):
value
=
self
.
cleaned_data
[
'value'
]
options
,
_created
=
OptionalUser
.
objects
.
get_or_create
()
if
value
<
options
.
min_online_payment
:
raise
forms
.
ValidationError
(
"Montant inférieur au montant minimal de paiement en ligne (%s) €"
%
options
.
min_online_payment
)
if
value
+
self
.
user
.
solde
>
options
.
max_solde
:
raise
forms
.
ValidationError
(
"Le solde ne peux excéder %s "
%
options
.
max_solde
)
return
value
cotisations/payment.py
View file @
a71e01e1
...
...
@@ -76,7 +76,8 @@ def ipn(request):
return
HttpResponse
(
"HTTP/1.0 200 OK"
)
def
comnpay
(
facture
,
host
):
def
comnpay
(
facture
,
request
):
host
=
request
.
get_host
()
p
=
ComnpayPayment
(
"DEMO"
,
"DEMO"
,
...
...
cotisations/views.py
View file @
a71e01e1
...
...
@@ -687,7 +687,7 @@ def new_facture_solde(request, userid):
@
login_required
def
recharge
(
request
):
f
=
RechargeForm
(
request
.
POST
or
None
)
f
=
RechargeForm
(
request
.
POST
or
None
,
user
=
request
.
user
)
if
f
.
is_valid
():
facture
=
Facture
(
user
=
request
.
user
)
paiement
,
_created
=
Paiement
.
objects
.
get_or_create
(
moyen
=
'Rechargement en ligne'
)
...
...
@@ -702,6 +702,6 @@ def recharge(request):
)
v
.
save
()
options
,
_created
=
AssoOption
.
objects
.
get_or_create
()
content
=
payment
.
PAYMENT_SYSTEM
[
options
.
payment
](
facture
,
request
.
get_host
()
)
content
=
payment
.
PAYMENT_SYSTEM
[
options
.
payment
](
facture
,
request
)
return
render
(
request
,
'cotisations/payment.html'
,
content
)
return
form
({
'rechargeform'
:
f
},
'cotisations/recharge.html'
,
request
)
preferences/forms.py
View file @
a71e01e1
...
...
@@ -49,6 +49,8 @@ class EditOptionalUserForm(ModelForm):
self
.
fields
[
'user_solde'
].
label
=
'Activation du solde pour
\
les utilisateurs'
self
.
fields
[
'max_solde'
].
label
=
'Solde maximum'
self
.
fields
[
'min_online_payment'
].
label
=
'Montant de rechargement minimum en ligne'
self
.
fields
[
'self_adhesion'
].
label
=
'Auto inscription'
class
EditOptionalMachineForm
(
ModelForm
):
...
...
preferences/migrations/0031_optionaluser_self_adhesion.py
0 → 100644
View file @
a71e01e1
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2018-01-12 11:34
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'preferences'
,
'0030_auto_20180111_2346'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'optionaluser'
,
name
=
'self_adhesion'
,
field
=
models
.
BooleanField
(
default
=
False
,
help_text
=
'Un nouvel utilisateur peut se créer son compte sur re2o'
),
),
]
preferences/migrations/0032_optionaluser_min_online_payment.py
0 → 100644
View file @
a71e01e1
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2018-01-13 16:43
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'preferences'
,
'0031_optionaluser_self_adhesion'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'optionaluser'
,
name
=
'min_online_payment'
,
field
=
models
.
DecimalField
(
decimal_places
=
2
,
default
=
10
,
max_digits
=
5
),
),
]
preferences/models.py
View file @
a71e01e1
...
...
@@ -46,11 +46,20 @@ class OptionalUser(models.Model):
decimal_places
=
2
,
default
=
50
)
min_online_payment
=
models
.
DecimalField
(
max_digits
=
5
,
decimal_places
=
2
,
default
=
10
)
gpg_fingerprint
=
models
.
BooleanField
(
default
=
True
)
all_can_create
=
models
.
BooleanField
(
default
=
False
,
help_text
=
"Tous les users peuvent en créer d'autres"
,
)
self_adhesion
=
models
.
BooleanField
(
default
=
False
,
help_text
=
"Un nouvel utilisateur peut se créer son compte sur re2o"
)
class
Meta
:
permissions
=
(
...
...
preferences/templates/preferences/display_preferences.html
View file @
a71e01e1
...
...
@@ -54,11 +54,17 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<tr>
<th>
Creations d'users par tous
</th>
<td>
{{ useroptions.all_can_create }}
</td>
{% if useroptions.user_solde %}
<th>
Solde maximum
</th>
<td>
{{ useroptions.max_solde }}
</td>
{% endif %}
<th>
Auto inscription
</th>
<td>
{{ useroptions.self_adhesion }}
</td>
</tr>
{% if useroptions.user_solde %}
<tr>
<th>
Solde maximum
</th>
<td>
{{ useroptions.max_solde }}
</td>
<th>
Montant minimal de rechargement en ligne
</th>
<td>
{{ useroptions.min_online_payment }}
</td>
</tr>
{% endif %}
</table>
<h4>
Préférences machines
</h4>
<a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'preferences:edit-options' 'OptionalMachine' %}"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment