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
beff1bbd
Commit
beff1bbd
authored
Jun 17, 2018
by
Hugo LEVY-FALK
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ne montre pas tous les articles en vente aux utilisateurs lambdas
parent
27f646c2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
2 deletions
+56
-2
cotisations/forms.py
cotisations/forms.py
+16
-0
cotisations/migrations/0031_article_allow_self_subscription.py
...ations/migrations/0031_article_allow_self_subscription.py
+20
-0
cotisations/models.py
cotisations/models.py
+4
-0
cotisations/views.py
cotisations/views.py
+16
-2
No files found.
cotisations/forms.py
View file @
beff1bbd
...
...
@@ -131,6 +131,14 @@ class SelectUserArticleForm(
required
=
True
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
self_subscription
=
kwargs
.
pop
(
'is_self_subscription'
,
False
)
super
(
SelectUserArticleForm
,
self
).
__init__
(
*
args
,
**
kwargs
)
if
self_subscription
:
self
.
fields
[
'article'
].
queryset
=
Article
.
objects
.
filter
(
Q
(
type_user
=
'All'
)
|
Q
(
type_user
=
'Adherent'
)
).
filter
(
allow_self_subscription
=
True
)
class
SelectClubArticleForm
(
Form
):
"""
...
...
@@ -150,6 +158,14 @@ class SelectClubArticleForm(Form):
required
=
True
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
self_subscription
=
kwargs
.
pop
(
'is_self_subscription'
,
False
)
super
(
SelectClubArticleForm
,
self
).
__init__
(
*
args
,
**
kwargs
)
if
self_subscription
:
self
.
fields
[
'article'
].
queryset
=
Article
.
objects
.
filter
(
Q
(
type_user
=
'All'
)
|
Q
(
type_user
=
'Club'
)
).
filter
(
allow_self_subscription
=
True
)
# TODO : change Facture to Invoice
class
NewFactureFormPdf
(
Form
):
...
...
cotisations/migrations/0031_article_allow_self_subscription.py
0 → 100644
View file @
beff1bbd
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2018-06-17 17:13
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'cotisations'
,
'0030_paiement_allow_self_subscription'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'article'
,
name
=
'allow_self_subscription'
,
field
=
models
.
BooleanField
(
default
=
False
,
verbose_name
=
'Is available for self subscription'
),
),
]
cotisations/models.py
View file @
beff1bbd
...
...
@@ -518,6 +518,10 @@ class Article(RevMixin, AclMixin, models.Model):
max_length
=
255
,
verbose_name
=
_l
(
"Type of cotisation"
)
)
allow_self_subscription
=
models
.
BooleanField
(
default
=
False
,
verbose_name
=
_l
(
"Is available for self subscription"
)
)
unique_together
=
(
'name'
,
'type_user'
)
...
...
cotisations/views.py
View file @
beff1bbd
...
...
@@ -99,18 +99,32 @@ 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
is_self_subscription
=
False
if
not
request
.
user
.
has_perm
(
'cotisations.add_facture'
)
and
OptionalUser
.
get_cached_value
(
'allow_self_subscription'
):
is_self_subscription
=
True
article_list
=
article_list
.
filter
(
allow_self_subscription
=
True
)
allowed_payment
=
Paiement
.
objects
.
filter
(
allow_self_subscription
=
True
)
invoice_form
=
NewFactureForm
(
request
.
POST
or
None
,
instance
=
invoice
,
allowed_payment
=
allowed_payment
)
elif
not
OptionalUser
.
get_cached_value
(
'allow_self_subscription'
):
messages
.
error
(
request
,
_
(
"You cannot subscribe. Please ask to the staff."
)
)
return
redirect
(
reverse
(
'users:profil'
,
kwargs
=
{
'userid'
:
userid
}
))
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
request
.
POST
or
None
,
form_kwargs
=
{
'is_self_subscription'
:
is_self_subscription
}
)
else
:
article_formset
=
formset_factory
(
SelectUserArticleForm
)(
request
.
POST
or
None
request
.
POST
or
None
,
form_kwargs
=
{
'is_self_subscription'
:
is_self_subscription
}
)
if
invoice_form
.
is_valid
()
and
article_formset
.
is_valid
():
...
...
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