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
ff489030
Commit
ff489030
authored
Mar 12, 2013
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split up subproject validation
parent
d05c6c16
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
54 deletions
+67
-54
trans/models/subproject.py
trans/models/subproject.py
+67
-54
No files found.
trans/models/subproject.py
View file @
ff489030
...
@@ -735,6 +735,32 @@ class SubProject(models.Model):
...
@@ -735,6 +735,32 @@ class SubProject(models.Model):
self
.
update_remote_branch
()
self
.
update_remote_branch
()
self
.
update_branch
()
self
.
update_branch
()
def
clean_repo_link
(
self
):
'''
Validates repository link.
'''
if
self
.
push
!=
''
:
raise
ValidationError
(
_
(
'Push URL is not used when repository is linked!'
)
)
validate_repo
(
self
.
repo
)
def
clean_template
(
self
):
'''
Validates whether template can be loaded.
'''
try
:
self
.
load_template_store
()
except
ValueError
:
raise
ValidationError
(
_
(
'Format of translation template could not be recognized.'
)
)
except
Exception
as
e
:
raise
ValidationError
(
_
(
'Failed to parse translation template.'
)
)
def
clean
(
self
):
def
clean
(
self
):
'''
'''
Validator fetches repository and tries to find translation files.
Validator fetches repository and tries to find translation files.
...
@@ -748,16 +774,13 @@ class SubProject(models.Model):
...
@@ -748,16 +774,13 @@ class SubProject(models.Model):
self
.
sync_git_repo
(
True
)
self
.
sync_git_repo
(
True
)
# Push repo is not used with link
# Push repo is not used with link
if
self
.
is_repo_link
()
and
self
.
push
!=
''
:
if
self
.
is_repo_link
():
raise
ValidationError
(
self
.
clean_repo_link
()
_
(
'Push URL is not used when repository is linked!'
)
)
try
:
matches
=
self
.
get_mask_matches
()
matches
=
self
.
get_mask_matches
()
if
len
(
matches
)
==
0
:
if
len
(
matches
)
==
0
:
raise
ValidationError
(
_
(
'The mask did not match any files!'
))
raise
ValidationError
(
_
(
'The mask did not match any files!'
))
langs
=
{}
langs
=
set
()
for
match
in
matches
:
for
match
in
matches
:
code
=
self
.
get_lang_code
(
match
)
code
=
self
.
get_lang_code
(
match
)
if
code
in
langs
:
if
code
in
langs
:
...
@@ -766,7 +789,7 @@ class SubProject(models.Model):
...
@@ -766,7 +789,7 @@ class SubProject(models.Model):
'adjust the mask and use subprojects for translating '
'adjust the mask and use subprojects for translating '
'different resources.'
'different resources.'
))
))
langs
[
code
]
=
match
langs
.
add
(
code
)
# Try parsing files
# Try parsing files
notrecognized
=
[]
notrecognized
=
[]
...
@@ -793,17 +816,7 @@ class SubProject(models.Model):
...
@@ -793,17 +816,7 @@ class SubProject(models.Model):
# Validate template
# Validate template
if
self
.
has_template
():
if
self
.
has_template
():
try
:
self
.
clean_template
()
self
.
load_template_store
()
except
ValueError
:
raise
ValidationError
(
_
(
'Format of translation template could not be recognized.'
))
except
Exception
as
e
:
raise
ValidationError
(
_
(
'Failed to parse translation template.'
)
)
except
SubProject
.
DoesNotExist
:
# Happens with invalid link
pass
def
get_template_filename
(
self
):
def
get_template_filename
(
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