Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
26166e00
Commit
26166e00
authored
Oct 13, 2015
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow to specify end date for credits
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
289c474d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
10 deletions
+38
-10
weblate/trans/forms.py
weblate/trans/forms.py
+16
-3
weblate/trans/tests/test_reports.py
weblate/trans/tests/test_reports.py
+14
-4
weblate/trans/views/reports.py
weblate/trans/views/reports.py
+8
-3
No files found.
weblate/trans/forms.py
View file @
26166e00
...
...
@@ -821,9 +821,6 @@ class ReportDownloadForm(forms.Form):
(
'json'
,
_
(
'JSON'
))
),
)
class
CreditsForm
(
ReportDownloadForm
):
start_date
=
forms
.
DateField
(
label
=
_
(
'Starting date'
),
initial
=
date
(
2000
,
1
,
1
),
...
...
@@ -836,3 +833,19 @@ class CreditsForm(ReportDownloadForm):
format
=
'%Y-%m-%d'
)
)
end_date
=
forms
.
DateField
(
label
=
_
(
'Ending date'
),
initial
=
date
(
2100
,
1
,
1
),
widget
=
forms
.
DateInput
(
attrs
=
{
'type'
:
'date'
,
'data-provide'
:
'datepicker'
,
'data-date-format'
:
'yyyy-mm-dd'
,
},
format
=
'%Y-%m-%d'
)
)
class
CreditsForm
(
ReportDownloadForm
):
pass
weblate/trans/tests/test_reports.py
View file @
26166e00
...
...
@@ -42,7 +42,8 @@ class ReportsTest(ViewTestCase):
def
test_credits_empty
(
self
):
data
=
generate_credits
(
self
.
subproject
,
timezone
.
now
()
-
timedelta
(
days
=
1
)
timezone
.
now
()
-
timedelta
(
days
=
1
),
timezone
.
now
()
+
timedelta
(
days
=
1
)
)
self
.
assertEqual
(
data
,
[])
...
...
@@ -50,7 +51,8 @@ class ReportsTest(ViewTestCase):
self
.
add_change
()
data
=
generate_credits
(
self
.
subproject
,
timezone
.
now
()
-
timedelta
(
days
=
1
)
timezone
.
now
()
-
timedelta
(
days
=
1
),
timezone
.
now
()
+
timedelta
(
days
=
1
)
)
self
.
assertEqual
(
data
,
...
...
@@ -68,7 +70,11 @@ class ReportsTest(ViewTestCase):
self
.
add_change
()
response
=
self
.
client
.
post
(
reverse
(
'credits'
,
kwargs
=
self
.
kw_subproject
),
{
'style'
:
'json'
,
'start_date'
:
'2000-01-01'
},
{
'style'
:
'json'
,
'start_date'
:
'2000-01-01'
,
'end_date'
:
'2100-01-01'
},
)
data
=
json
.
loads
(
response
.
content
)
self
.
assertEqual
(
...
...
@@ -80,7 +86,11 @@ class ReportsTest(ViewTestCase):
self
.
add_change
()
response
=
self
.
client
.
post
(
reverse
(
'credits'
,
kwargs
=
self
.
kw_subproject
),
{
'style'
:
'rst'
,
'start_date'
:
'2000-01-01'
},
{
'style'
:
'rst'
,
'start_date'
:
'2000-01-01'
,
'end_date'
:
'2100-01-01'
},
)
self
.
assertEqual
(
response
.
content
,
...
...
weblate/trans/views/reports.py
View file @
26166e00
...
...
@@ -30,14 +30,15 @@ from django.core.exceptions import PermissionDenied
import
json
def
generate_credits
(
component
,
start_date
):
def
generate_credits
(
component
,
start_date
,
end_date
):
"""Generates credits data for given component."""
result
=
[]
for
translation
in
component
.
translation_set
.
all
():
authors
=
Change
.
objects
.
content
().
filter
(
translation
=
translation
translation
=
translation
,
timestamp__range
=
(
start_date
,
end_date
),
).
values_list
(
'author__email'
,
'author__first_name'
)
...
...
@@ -62,7 +63,11 @@ def get_credits(request, project, subproject):
if
not
form
.
is_valid
():
return
redirect
(
obj
)
data
=
generate_credits
(
obj
,
form
.
cleaned_data
[
'start_date'
])
data
=
generate_credits
(
obj
,
form
.
cleaned_data
[
'start_date'
],
form
.
cleaned_data
[
'end_date'
],
)
if
form
.
cleaned_data
[
'style'
]
==
'json'
:
return
HttpResponse
(
...
...
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