Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubes
expense
Commits
d517df6fc880
Commit
6bf44b04
authored
May 16, 2019
by
Philippe Pepiot
Browse files
[autopep8] E22 - Fix extraneous whitespace around keywords
parent
ec47c5346cf1
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
cubicweb_expense/pdfgen/flowgenerators.py
View file @
d517df6f
This diff is collapsed.
Click to expand it.
cubicweb_expense/pdfgen/styles.py
View file @
d517df6f
...
...
@@ -18,8 +18,8 @@ style_metadata.fontSize = STANDARD_FONT_SIZE
style_metadata
.
leading
=
STANDARD_FONT_SIZE
*
1.2
style_metadata
.
fontName
=
"Helvetica"
style_metadata
.
alignment
=
TA_LEFT
style_metadata
.
firstLineIndent
=
-
0.5
*
cm
style_metadata
.
leftIndent
=
0.5
*
cm
style_metadata
.
firstLineIndent
=
-
0.5
*
cm
style_metadata
.
leftIndent
=
0.5
*
cm
style_ids
=
ParagraphStyle
(
"ids"
)
style_ids
.
fontSize
=
STANDARD_FONT_SIZE
*
0.8
...
...
@@ -32,8 +32,8 @@ style_address.fontSize = STANDARD_FONT_SIZE * 1.2
style_address
.
leading
=
STANDARD_FONT_SIZE
*
1.2
*
1.2
style_address
.
fontName
=
"Helvetica"
style_address
.
alignment
=
TA_LEFT
style_address
.
firstLineIndent
=
-
0.5
*
cm
style_address
.
leftIndent
=
0.5
*
cm
style_address
.
firstLineIndent
=
-
0.5
*
cm
style_address
.
leftIndent
=
0.5
*
cm
style_table_header
=
ParagraphStyle
(
"table_header"
)
style_table_header
.
fontSize
=
STANDARD_FONT_SIZE
...
...
@@ -46,8 +46,8 @@ style_table_data.fontSize = STANDARD_FONT_SIZE
style_table_data
.
leading
=
STANDARD_FONT_SIZE
*
1.1
style_table_data
.
fontName
=
"Helvetica"
style_table_data
.
alignment
=
TA_LEFT
style_table_data
.
firstLineIndent
=
-
0.2
*
cm
style_table_data
.
leftIndent
=
0.2
*
cm
style_table_data
.
firstLineIndent
=
-
0.2
*
cm
style_table_data
.
leftIndent
=
0.2
*
cm
style_table_data_num
=
ParagraphStyle
(
"table_data_num"
)
style_table_data_num
.
fontSize
=
STANDARD_FONT_SIZE
...
...
cubicweb_expense/pdfgen/templates.py
View file @
d517df6f
...
...
@@ -40,9 +40,9 @@ class FreshPageTemplate(PageTemplate):
template_id: string. id of the page template.
"""
# Defines the main frame in which the expenses data will be displayed
main_f
=
Frame
(
1
*
cm
,
1
*
cm
,
19
*
cm
,
23.9
*
cm
,
leftPadding
=
0
*
cm
,
bottomPadding
=
0
*
cm
,
rightPadding
=
0
*
cm
,
topPadding
=
0
*
cm
)
main_f
=
Frame
(
1
*
cm
,
1
*
cm
,
19
*
cm
,
23.9
*
cm
,
leftPadding
=
0
*
cm
,
bottomPadding
=
0
*
cm
,
rightPadding
=
0
*
cm
,
topPadding
=
0
*
cm
)
self
.
company_data
=
company_data
self
.
doc_type
=
doc_type
...
...
@@ -83,14 +83,14 @@ class FreshPageTemplate(PageTemplate):
# with platypus, we can't draw an image (logo) that is left-aligned.
# rectangle around the header
canvas
.
setLineWidth
(
0.05
*
cm
)
canvas
.
rect
(
1
*
cm
,
28.7
*
cm
,
19
*
cm
,
-
3.3
*
cm
,
stroke
=
1
,
fill
=
0
)
canvas
.
setLineWidth
(
0.05
*
cm
)
canvas
.
rect
(
1
*
cm
,
28.7
*
cm
,
19
*
cm
,
-
3.3
*
cm
,
stroke
=
1
,
fill
=
0
)
# company logo
try
:
logo
=
ImageReader
(
self
.
company_data
[
"logo-filename"
])
if
reportlab_version
>=
"2.1"
and
reportlab_version
<=
"2.3"
:
canvas
.
drawImage
(
logo
,
1.2
*
cm
,
28.5
*
cm
,
5
*
cm
,
2.5
*
cm
,
canvas
.
drawImage
(
logo
,
1.2
*
cm
,
28.5
*
cm
,
5
*
cm
,
2.5
*
cm
,
preserveAspectRatio
=
True
,
anchor
=
"nw"
)
else
:
# Old version of reportlab. must compute the height and width
...
...
@@ -98,39 +98,39 @@ class FreshPageTemplate(PageTemplate):
# 2.4 Version has the same problem!
img_width
,
img_height
=
logo
.
getSize
()
ratio
=
img_width
/
img_height
if
ratio
>=
5
/
2.5
:
width
=
5
*
cm
height
=
5
*
cm
/
ratio
if
ratio
>=
5
/
2.5
:
width
=
5
*
cm
height
=
5
*
cm
/
ratio
else
:
width
=
ratio
*
2.5
*
cm
heigth
=
2.5
*
cm
canvas
.
drawImage
(
logo
,
1.2
*
cm
,
28.5
*
cm
-
height
,
width
,
height
)
width
=
ratio
*
2.5
*
cm
heigth
=
2.5
*
cm
canvas
.
drawImage
(
logo
,
1.2
*
cm
,
28.5
*
cm
-
height
,
width
,
height
)
except
IOError
:
# Unable to read logo filename
canvas
.
setFont
(
"Helvetica"
,
12
)
str_data
=
xml_escape
(
self
.
company_data
[
"company-name"
])
canvas
.
drawString
(
1.2
*
cm
,
28
*
cm
,
str_data
)
canvas
.
drawString
(
1.2
*
cm
,
28
*
cm
,
str_data
)
canvas
.
setFont
(
"Helvetica"
,
8
)
# page number
str_data
=
_
(
u
"Page"
)
+
_
(
u
": "
)
+
u
"%d"
%
document
.
page
canvas
.
drawRightString
(
19.8
*
cm
,
28.2
*
cm
,
str_data
)
str_data
=
_
(
u
"Page"
)
+
_
(
u
": "
)
+
u
"%d"
%
document
.
page
canvas
.
drawRightString
(
19.8
*
cm
,
28.2
*
cm
,
str_data
)
# company address
str_data
=
_
(
u
"Est."
)
+
_
(
u
": "
)
\
+
self
.
company_data
[
"company-address"
]
self
.
draw_string_in_width
(
canvas
,
str_data
,
1.2
*
cm
,
25.6
*
cm
,
9.5
*
cm
)
self
.
draw_string_in_width
(
canvas
,
str_data
,
1.2
*
cm
,
25.6
*
cm
,
9.5
*
cm
)
# company official ID number
str_data
=
_
(
u
"Official ID num"
)
+
_
(
u
": "
)
\
+
self
.
company_data
[
"company-offnum"
]
self
.
draw_string_in_width
(
canvas
,
str_data
,
11.2
*
cm
,
25.6
*
cm
,
5
*
cm
)
self
.
draw_string_in_width
(
canvas
,
str_data
,
11.2
*
cm
,
25.6
*
cm
,
5
*
cm
)
# company activity number
str_data
=
_
(
u
"Activity num"
)
+
_
(
u
": "
)
\
+
self
.
company_data
[
"company-actnum"
]
self
.
draw_string_in_width
(
canvas
,
str_data
,
16.7
*
cm
,
25.6
*
cm
,
3.5
*
cm
)
self
.
draw_string_in_width
(
canvas
,
str_data
,
16.7
*
cm
,
25.6
*
cm
,
3.5
*
cm
)
# title depending on document type
title
=
u
""
...
...
@@ -139,11 +139,11 @@ class FreshPageTemplate(PageTemplate):
elif
self
.
doc_type
==
"expense"
:
title
=
_
(
u
"Expense Document"
).
upper
()
canvas
.
setFont
(
"Helvetica-Bold"
,
14
)
canvas
.
drawCentredString
(
14.2
*
cm
,
27.2
*
cm
,
title
)
canvas
.
drawCentredString
(
14.2
*
cm
,
27.2
*
cm
,
title
)
# preamble remark
canvas
.
setFont
(
"Helvetica-Oblique"
,
9
)
canvas
.
drawCentredString
(
14.2
*
cm
,
26.7
*
cm
,
canvas
.
drawCentredString
(
14.2
*
cm
,
26.7
*
cm
,
_
(
u
"All the amounts are displayed in Euros, except if specified"
))
...
...
@@ -168,10 +168,10 @@ class FreshPageTemplate(PageTemplate):
str_width
=
canvas
.
stringWidth
(
string
,
canvas
.
_fontname
,
canvas
.
_fontsize
)
if
str_width
>
width
:
string
=
string
+
u
"..."
string
=
string
+
u
"..."
str_width
=
canvas
.
stringWidth
(
string
)
while
str_width
>
width
:
string
=
string
[:
-
4
]
+
u
"..."
string
=
string
[:
-
4
]
+
u
"..."
str_width
=
canvas
.
stringWidth
(
string
)
canvas
.
drawString
(
x
,
y
,
string
)
...
...
test/_helpers.py
View file @
d517df6f
...
...
@@ -30,7 +30,7 @@ class HelpersTC(CubicWebTC):
def
new_account
(
self
,
cnx
,
login
):
user
=
self
.
create_user
(
cnx
,
login
)
cnx
.
execute
(
'INSERT EmailAddress E: E address %(add)s, U use_email E, U primary_email E '
'WHERE U eid %(u)s'
,
{
'u'
:
user
.
eid
,
'add'
:
login
+
'@test.org'
})
'WHERE U eid %(u)s'
,
{
'u'
:
user
.
eid
,
'add'
:
login
+
'@test.org'
})
account
=
cnx
.
create_entity
(
'PaidByAccount'
,
label
=
u
'%s account'
%
login
)
self
.
add_relation
(
cnx
,
account
.
eid
,
'associated_to'
,
user
.
eid
)
return
user
,
account
...
...
test/unittest_hooks.py
View file @
d517df6f
...
...
@@ -48,7 +48,7 @@ class HooksTC(HelpersTC):
self
.
assertEqual
(
newcount
,
count
)
self
.
accept
(
cnx
,
expense
)
newcount
=
self
.
refund_lines_count
(
cnx
,
self
.
account1
)
self
.
assertEqual
(
newcount
,
count
+
1
)
self
.
assertEqual
(
newcount
,
count
+
1
)
def
test_expense_accepted_notification
(
self
):
...
...
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