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
0a8335c3
Commit
0a8335c3
authored
Jan 03, 2019
by
Hugo LEVY-FALK
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable template selection for invoices.
parent
6fdf8a04
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
52 additions
and
1 deletion
+52
-1
cotisations/tex.py
cotisations/tex.py
+4
-1
preferences/forms.py
preferences/forms.py
+8
-0
preferences/models.py
preferences/models.py
+12
-0
preferences/templates/preferences/display_preferences.html
preferences/templates/preferences/display_preferences.html
+19
-0
preferences/urls.py
preferences/urls.py
+5
-0
preferences/views.py
preferences/views.py
+3
-0
re2o/settings.py
re2o/settings.py
+1
-0
No files found.
cotisations/tex.py
View file @
0a8335c3
...
...
@@ -40,6 +40,7 @@ from django.utils.text import slugify
from
django.utils.translation
import
ugettext_lazy
as
_
from
re2o.mixins
import
AclMixin
,
RevMixin
from
preferences.models
import
CotisationsOption
TEMP_PREFIX
=
getattr
(
settings
,
'TEX_TEMP_PREFIX'
,
'render_tex-'
)
...
...
@@ -73,6 +74,7 @@ def render_invoice(_request, ctx={}):
Render an invoice using some available information such as the current
date, the user, the articles, the prices, ...
"""
options
,
_
=
CotisationsOption
.
objects
.
get_or_create
()
is_estimate
=
ctx
.
get
(
'is_estimate'
,
False
)
filename
=
'_'
.
join
([
'cost_estimate'
if
is_estimate
else
'invoice'
,
...
...
@@ -82,7 +84,8 @@ def render_invoice(_request, ctx={}):
str
(
ctx
.
get
(
'DATE'
,
datetime
.
now
()).
month
),
str
(
ctx
.
get
(
'DATE'
,
datetime
.
now
()).
day
),
])
r
=
render_tex
(
_request
,
'cotisations/factures.tex'
,
ctx
)
templatename
=
options
.
invoice_template
.
template
.
name
.
split
(
'/'
)[
-
1
]
r
=
render_tex
(
_request
,
templatename
,
ctx
)
r
[
'Content-Disposition'
]
=
'attachment; filename="{name}.pdf"'
.
format
(
name
=
filename
)
...
...
preferences/forms.py
View file @
0a8335c3
...
...
@@ -43,6 +43,7 @@ from .models import (
RadiusKey
,
SwitchManagementCred
,
RadiusOption
,
CotisationsOption
)
from
topologie.models
import
Switch
...
...
@@ -253,6 +254,13 @@ class EditRadiusOptionForm(ModelForm):
return
cleaned_data
class
EditCotisationsOptionForm
(
ModelForm
):
"""Edition forms for Cotisations options"""
class
Meta
:
model
=
CotisationsOption
fields
=
'__all__'
class
ServiceForm
(
ModelForm
):
"""Edition, ajout de services sur la page d'accueil"""
class
Meta
:
...
...
preferences/models.py
View file @
0a8335c3
...
...
@@ -687,3 +687,15 @@ class RadiusOption(AclMixin, PreferencesModel):
null
=
True
)
class
CotisationsOption
(
AclMixin
,
PreferencesModel
):
class
Meta
:
verbose_name
=
_
(
"cotisations options"
)
invoice_template
=
models
.
OneToOneField
(
'cotisations.DocumentTemplate'
,
verbose_name
=
_
(
"Template for invoices"
),
related_name
=
"invoice_template"
,
on_delete
=
models
.
PROTECT
,
)
preferences/templates/preferences/display_preferences.html
View file @
0a8335c3
...
...
@@ -346,6 +346,25 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</table>
</div>
</div>
<div
class=
"panel panel-default"
id=
"cotisation"
>
<div
class=
"panel-heading"
data-toggle=
"collapse"
href=
"#collapse_cotisation"
>
<h4
class=
"panel-title"
>
<a><i
class=
"fa fa-eur"
></i>
{% trans "Cotisation's options" %}
</a>
</h4>
</div>
<div
id=
"collapse_cotisation"
class=
"panel-collapse panel-body collapse"
>
<a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'preferences:edit-options' 'CotisationsOption' %}"
>
<i
class=
"fa fa-edit"
></i>
</a>
<table
class=
"table table-striped"
>
<tr>
<th>
{% trans "Invoices' template" %}
</th>
<td>
{{ cotisationsoptions.invoice_template }}
</td>
</tr>
</table>
</div>
</div>
<div
class=
"panel panel-default"
id=
"mail"
>
<div
class=
"panel-heading"
data-toggle=
"collapse"
href=
"#collapse_mail"
>
...
...
preferences/urls.py
View file @
0a8335c3
...
...
@@ -71,6 +71,11 @@ urlpatterns = [
views
.
edit_options
,
name
=
'edit-options'
),
url
(
r
'^edit_options/(?P<section>CotisationsOption)$'
,
views
.
edit_options
,
name
=
'edit-options'
),
url
(
r
'^add_service/$'
,
views
.
add_service
,
name
=
'add-service'
),
url
(
r
'^edit_service/(?P<serviceid>[0-9]+)$'
,
...
...
preferences/views.py
View file @
0a8335c3
...
...
@@ -64,6 +64,7 @@ from .models import (
RadiusKey
,
SwitchManagementCred
,
RadiusOption
,
CotisationsOption
,
)
from
.
import
models
from
.
import
forms
...
...
@@ -88,6 +89,7 @@ def display_options(request):
radiuskey_list
=
RadiusKey
.
objects
.
all
()
switchmanagementcred_list
=
SwitchManagementCred
.
objects
.
all
()
radiusoptions
,
_
=
RadiusOption
.
objects
.
get_or_create
()
cotisationsoptions
,
_created
=
CotisationsOption
.
objects
.
get_or_create
()
return
form
({
'useroptions'
:
useroptions
,
'machineoptions'
:
machineoptions
,
...
...
@@ -102,6 +104,7 @@ def display_options(request):
'radiuskey_list'
:
radiuskey_list
,
'switchmanagementcred_list'
:
switchmanagementcred_list
,
'radiusoptions'
:
radiusoptions
,
'cotisationsoptions'
:
cotisationsoptions
,
},
'preferences/display_preferences.html'
,
request
)
...
...
re2o/settings.py
View file @
0a8335c3
...
...
@@ -120,6 +120,7 @@ TEMPLATES = [
'DIRS'
:
[
# Use only absolute paths with '/' delimiters even on Windows
os
.
path
.
join
(
BASE_DIR
,
'templates'
).
replace
(
'
\\
'
,
'/'
),
os
.
path
.
join
(
BASE_DIR
,
'media'
,
'templates'
).
replace
(
'
\\
'
,
'/'
),
],
'APP_DIRS'
:
True
,
'OPTIONS'
:
{
...
...
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