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
2eb0fc81
Commit
2eb0fc81
authored
Jun 17, 2018
by
Hugo LEVY-FALK
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Paiement de cotisation en ligne possible pour les utilisateurs normaux (désactivable)
parent
6e416eac
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
82 additions
and
5 deletions
+82
-5
cotisations/forms.py
cotisations/forms.py
+5
-1
cotisations/migrations/0030_paiement_allow_self_subscription.py
...tions/migrations/0030_paiement_allow_self_subscription.py
+20
-0
cotisations/models.py
cotisations/models.py
+21
-0
cotisations/views.py
cotisations/views.py
+5
-1
preferences/migrations/0035_optionaluser_allow_self_subscription.py
...s/migrations/0035_optionaluser_allow_self_subscription.py
+20
-0
preferences/models.py
preferences/models.py
+7
-0
users/templates/users/profil.html
users/templates/users/profil.html
+4
-3
No files found.
cotisations/forms.py
View file @
2eb0fc81
...
...
@@ -55,9 +55,12 @@ class NewFactureForm(FormRevMixin, ModelForm):
"""
def
__init__
(
self
,
*
args
,
**
kwargs
):
prefix
=
kwargs
.
pop
(
'prefix'
,
self
.
Meta
.
model
.
__name__
)
allowed_payment
=
kwargs
.
pop
(
'allowed_payment'
,
None
)
super
(
NewFactureForm
,
self
).
__init__
(
*
args
,
prefix
=
prefix
,
**
kwargs
)
# TODO : remove the use of cheque and banque and paiement
# for something more generic or at least in English
if
allowed_payment
:
self
.
fields
[
'paiement'
].
queryset
=
allowed_payment
self
.
fields
[
'cheque'
].
required
=
False
self
.
fields
[
'banque'
].
required
=
False
self
.
fields
[
'cheque'
].
label
=
_
(
"Cheque number"
)
...
...
@@ -69,6 +72,7 @@ class NewFactureForm(FormRevMixin, ModelForm):
self
.
fields
[
'paiement'
].
widget
\
.
attrs
[
'data-cheque'
]
=
paiement_list
.
first
().
id
class
Meta
:
model
=
Facture
fields
=
[
'paiement'
,
'banque'
,
'cheque'
]
...
...
@@ -231,7 +235,7 @@ class PaiementForm(FormRevMixin, ModelForm):
class
Meta
:
model
=
Paiement
# TODO : change moyen to method and type_paiement to payment_type
fields
=
[
'moyen'
,
'type_paiement'
]
fields
=
[
'moyen'
,
'type_paiement'
,
'allow_self_subscription'
]
def
__init__
(
self
,
*
args
,
**
kwargs
):
prefix
=
kwargs
.
pop
(
'prefix'
,
self
.
Meta
.
model
.
__name__
)
...
...
cotisations/migrations/0030_paiement_allow_self_subscription.py
0 → 100644
View file @
2eb0fc81
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2018-06-17 14:59
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'cotisations'
,
'0029_auto_20180414_2056'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'paiement'
,
name
=
'allow_self_subscription'
,
field
=
models
.
BooleanField
(
default
=
False
,
verbose_name
=
'Is available for self subscription'
),
),
]
cotisations/models.py
View file @
2eb0fc81
...
...
@@ -46,6 +46,7 @@ from django.utils.translation import ugettext_lazy as _l
from
machines.models
import
regen
from
re2o.field_permissions
import
FieldPermissionModelMixin
from
re2o.mixins
import
AclMixin
,
RevMixin
from
preferences.models
import
OptionalUser
# TODO : change facture to invoice
...
...
@@ -213,6 +214,22 @@ class Facture(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
_
(
"You don't have the right to edit an invoice."
)
)
@
staticmethod
def
can_create
(
user_request
,
*
_args
,
**
_kwargs
):
"""Check if an user can create an invoice.
:param user_request: The user who wants to create an invoice.
:return: a message and a boolean which is True if the user can create
an invoice or if the `options.allow_self_subscription` is set.
"""
if
OptionalUser
.
get_cached_value
(
'allow_self_subscription'
):
return
True
,
None
return
(
user_request
.
has_perm
(
'cotisations.add_facture'
),
_
(
"You don't have the right to create an invoice."
)
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
Facture
,
self
).
__init__
(
*
args
,
**
kwargs
)
self
.
field_permissions
=
{
...
...
@@ -576,6 +593,10 @@ class Paiement(RevMixin, AclMixin, models.Model):
default
=
0
,
verbose_name
=
_l
(
"Payment type"
)
)
allow_self_subscription
=
models
.
BooleanField
(
default
=
False
,
verbose_name
=
_l
(
"Is available for self subscription"
)
)
class
Meta
:
permissions
=
(
...
...
cotisations/views.py
View file @
2eb0fc81
...
...
@@ -99,7 +99,11 @@ def new_facture(request, user, userid):
Q
(
type_user
=
'All'
)
|
Q
(
type_user
=
request
.
user
.
class_name
)
)
# Building the invocie form and the article formset
invoice_form
=
NewFactureForm
(
request
.
POST
or
None
,
instance
=
invoice
)
if
not
request
.
user
.
has_perm
(
'cotisations.add_facture'
)
and
OptionalUser
.
get_cached_value
(
'allow_self_subscription'
):
allowed_payment
=
Paiement
.
objects
.
filter
(
allow_self_subscription
=
True
)
invoice_form
=
NewFactureForm
(
request
.
POST
or
None
,
instance
=
invoice
,
allowed_payment
=
allowed_payment
)
else
:
invoice_form
=
NewFactureForm
(
request
.
POST
or
None
,
instance
=
invoice
)
if
request
.
user
.
is_class_club
:
article_formset
=
formset_factory
(
SelectClubArticleForm
)(
request
.
POST
or
None
...
...
preferences/migrations/0035_optionaluser_allow_self_subscription.py
0 → 100644
View file @
2eb0fc81
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2018-06-17 15:12
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'preferences'
,
'0034_auto_20180416_1120'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'optionaluser'
,
name
=
'allow_self_subscription'
,
field
=
models
.
BooleanField
(
default
=
False
,
help_text
=
"Autoriser les utilisateurs à cotiser par eux mêmes via les moyens de paiement permettant l'auto-cotisation."
),
),
]
preferences/models.py
View file @
2eb0fc81
...
...
@@ -96,6 +96,13 @@ class OptionalUser(AclMixin, PreferencesModel):
default
=
False
,
help_text
=
"Un nouvel utilisateur peut se créer son compte sur re2o"
)
allow_self_subscription
=
models
.
BooleanField
(
default
=
False
,
help_text
=
(
"Autoriser les utilisateurs à cotiser par eux mêmes via les"
" moyens de paiement permettant l'auto-cotisation."
)
)
shell_default
=
models
.
OneToOneField
(
'users.ListShell'
,
on_delete
=
models
.
PROTECT
,
...
...
users/templates/users/profil.html
View file @
2eb0fc81
...
...
@@ -166,7 +166,7 @@ non adhérent</span>{% endif %} et votre connexion est {% if users.has_access %}
<tr>
<th>
Solde
</th>
<td>
{{ users.solde }} €
{% if allow_online_payment %}
{% if
user_solde and
allow_online_payment %}
<a
class=
"btn btn-primary btn-sm"
style=
'float:right'
role=
"button"
href=
"{% url 'cotisations:recharge' %}"
>
<i
class=
"fa fa-euro-sign"
></i>
Recharger
...
...
@@ -287,8 +287,9 @@ non adhérent</span>{% endif %} et votre connexion est {% if users.has_access %}
{% if user_solde %}
<a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'cotisations:new_facture_solde' user.id %}"
>
<i
class=
"fa fa-euro-sign"
></i>
Ajouter une cotisation par solde
</a>
{% endif %}{% acl_end %}
</a>
Ajouter une cotisation par solde
</a>
{% endif %}
{% acl_end %}
</div>
<div
class=
"panel-body"
>
{% if facture_list %}
...
...
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