Skip to content
GitLab
Explore
Sign in
Commits on Source (3)
Add __str__ to models, remove null=True in CharField and TextField
· bac22dcb
ynerant
authored
Sep 07, 2020
bac22dcb
Plain text mode in reports
· 4506dd4d
ynerant
authored
Sep 07, 2020
4506dd4d
Linebreaks are rendered as <<BR>> in the wiki
· e5b76b7c
ynerant
authored
Sep 07, 2020
e5b76b7c
Hide whitespace changes
Inline
Side-by-side
management/commands/import_transaction.py
View file @
e5b76b7c
...
...
@@ -214,7 +214,7 @@ class Command(ImportCommand):
"
amount
"
:
row
[
"
montant
"
],
"
created_at
"
:
date
,
"
destination_alias
"
:
""
,
"
invalidity_reason
"
:
None
,
"
invalidity_reason
"
:
""
,
"
quantity
"
:
row
[
"
quantite
"
],
"
reason
"
:
row
[
"
description
"
],
"
source_alias
"
:
""
,
...
...
management/commands/refresh_activities.py
View file @
e5b76b7c
...
...
@@ -100,7 +100,7 @@ class Command(BaseCommand):
title
=
act
.
name
,
start
=
timezone
.
localtime
(
act
.
date_start
).
strftime
(
"
%Y-%m-%d %H:%M
"
),
end
=
timezone
.
localtime
(
act
.
date_end
).
strftime
(
"
%Y-%m-%d %H:%M
"
),
description
=
act
.
description
,
description
=
act
.
description
.
replace
(
"
\r
"
,
""
).
replace
(
"
\n
"
,
"
<<BR>>
"
)
,
club
=
act
.
organizer
.
name
,
location
=
act
.
location
,
)
...
...
@@ -108,7 +108,7 @@ class Command(BaseCommand):
return
"
|| {start} || {title} || {description} || {club} || {location} ||
"
.
format
(
title
=
act
.
name
,
start
=
timezone
.
localtime
(
act
.
date_start
).
strftime
(
"
%d/%m/%Y
"
),
description
=
act
.
description
,
description
=
act
.
description
.
replace
(
"
\r
"
,
""
).
replace
(
"
\n
"
,
"
<<BR>>
"
)
,
club
=
act
.
organizer
.
name
,
location
=
act
.
location
,
)
...
...
management/commands/send_reports.py
View file @
e5b76b7c
...
...
@@ -14,12 +14,19 @@ from note.tables import HistoryTable
class
Command
(
BaseCommand
):
def
add_arguments
(
self
,
parser
):
parser
.
add_argument
(
'
--notes
'
,
'
-n
'
,
type
=
int
,
nargs
=
'
+
'
,
help
=
'
Select note ids
'
)
parser
.
add_argument
(
'
--debug
'
,
'
-d
'
,
action
=
'
store_true
'
,
help
=
'
Debug mode, print mails in stdout
'
)
def
handle
(
self
,
*
args
,
**
options
):
activate
(
'
fr
'
)
notes
=
NoteUser
.
objects
.
filter
(
user__memberships__date_end__gte
=
timezone
.
now
(),
user__profile__report_frequency__gt
=
0
,
).
distinct
().
all
()
if
"
notes
"
in
options
:
notes
=
NoteUser
.
objects
.
filter
(
pk__in
=
options
[
"
notes
"
]).
all
()
else
:
notes
=
NoteUser
.
objects
.
filter
(
user__memberships__date_end__gte
=
timezone
.
now
(),
user__profile__report_frequency__gt
=
0
,
).
distinct
().
all
()
for
note
in
notes
:
now
=
timezone
.
now
()
last_report
=
note
.
user
.
profile
.
last_report
...
...
@@ -41,11 +48,16 @@ class Command(BaseCommand):
context
=
dict
(
user
=
note
.
user
,
table
=
table
,
last_transactions
=
last_transactions
,
incoming
=
incoming
,
outcoming
=
outcoming
,
diff
=
incoming
-
outcoming
,
now
=
now
,
last_report
=
last_report
,
)
plain
=
render_to_string
(
"
note/mails/weekly_report.txt
"
,
context
)
html
=
render_to_string
(
"
note/mails/weekly_report.html
"
,
context
)
note
.
user
.
email_user
(
"
[Note Kfet] Rapport de la Note Kfet
"
,
html
,
html_message
=
html
)
if
options
[
"
debug
"
]:
self
.
stdout
.
write
(
plain
)
else
:
note
.
user
.
email_user
(
"
[Note Kfet] Rapport de la Note Kfet
"
,
plain
,
html_message
=
html
)