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
6a56fc08
Commit
6a56fc08
authored
Oct 08, 2015
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move author email generating to accounts module where it belongs
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
da38633b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
22 deletions
+21
-22
weblate/accounts/models.py
weblate/accounts/models.py
+15
-0
weblate/trans/models/subproject.py
weblate/trans/models/subproject.py
+2
-2
weblate/trans/models/translation.py
weblate/trans/models/translation.py
+4
-20
No files found.
weblate/accounts/models.py
View file @
6a56fc08
...
...
@@ -57,6 +57,21 @@ def send_mails(mails):
report_error
(
error
,
sys
.
exc_info
())
def
get_author_name
(
user
,
email
=
True
):
"""Returns formatted author name with email."""
# Get full name from database
full_name
=
user
.
first_name
# Use username if full name is empty
if
full_name
==
''
:
full_name
=
user
.
username
# Add email if we are asked for it
if
not
email
:
return
full_name
return
'%s <%s>'
%
(
full_name
,
user
.
email
)
def
notify_merge_failure
(
subproject
,
error
,
status
):
'''
Notification on merge failure.
...
...
weblate/trans/models/subproject.py
View file @
6a56fc08
...
...
@@ -59,7 +59,7 @@ from weblate.appsettings import (
HIDE_REPO_CREDENTIALS
,
DEFAULT_COMMITER_EMAIL
,
DEFAULT_COMMITER_NAME
,
)
from
weblate.accounts.models
import
notify_merge_failure
from
weblate.accounts.models
import
notify_merge_failure
,
get_author_name
from
weblate.trans.models.changes
import
Change
...
...
@@ -1523,7 +1523,7 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
)
translation
.
git_commit
(
request
,
translation
.
get_author_name
(
request
.
user
),
get_author_name
(
request
.
user
),
timezone
.
now
(),
force_commit
=
True
,
force_new
=
True
,
...
...
weblate/trans/models/translation.py
View file @
6a56fc08
...
...
@@ -44,7 +44,7 @@ from weblate.trans.util import translation_percent, split_plural
from
weblate.accounts.avatar
import
get_user_display
from
weblate.trans.mixins
import
URLMixin
,
PercentMixin
,
LoggerMixin
from
weblate.trans.boolean_sum
import
BooleanSum
from
weblate.accounts.models
import
notify_new_string
from
weblate.accounts.models
import
notify_new_string
,
get_author_name
from
weblate.trans.models.changes
import
Change
...
...
@@ -669,7 +669,7 @@ class Translation(models.Model, URLMixin, PercentMixin, LoggerMixin):
Returns last autor of change done in Weblate.
'''
try
:
return
self
.
get_author_name
(
return
get_author_name
(
self
.
change_set
.
content
()[
0
].
author
,
email
)
...
...
@@ -702,22 +702,6 @@ class Translation(models.Model, URLMixin, PercentMixin, LoggerMixin):
request
,
last
,
self
.
last_change
,
True
,
True
,
skip_push
)
def
get_author_name
(
self
,
user
,
email
=
True
):
'''
Returns formatted author name with email.
'''
# Get full name from database
full_name
=
user
.
first_name
# Use username if full name is empty
if
full_name
==
''
:
full_name
=
user
.
username
# Add email if we are asked for it
if
not
email
:
return
full_name
return
'%s <%s>'
%
(
full_name
,
user
.
email
)
def
get_commit_message
(
self
):
'''
Formats commit message based on project configuration.
...
...
@@ -871,7 +855,7 @@ class Translation(models.Model, URLMixin, PercentMixin, LoggerMixin):
self
.
store
.
add_unit
(
pounit
)
# We need to update backend now
author
=
self
.
get_author_name
(
user
)
author
=
get_author_name
(
user
)
# Update po file header
po_revision_date
=
(
...
...
@@ -1183,7 +1167,7 @@ class Translation(models.Model, URLMixin, PercentMixin, LoggerMixin):
# Optionally set authorship
if
author
is
None
:
author
=
self
.
get_author_name
(
request
.
user
)
author
=
get_author_name
(
request
.
user
)
# List translations we should process
# Filter out those who don't want automatic update, but keep ourselves
...
...
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