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
6ce12151
Commit
6ce12151
authored
Mar 11, 2013
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Share logic for loading template with class validation
parent
d738075b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
6 deletions
+14
-6
trans/models/subproject.py
trans/models/subproject.py
+14
-6
No files found.
trans/models/subproject.py
View file @
6ce12151
...
@@ -792,10 +792,9 @@ class SubProject(models.Model):
...
@@ -792,10 +792,9 @@ class SubProject(models.Model):
))
))
# Validate template
# Validate template
if
self
.
template
!=
''
:
if
self
.
has_template
():
template
=
self
.
get_template_filename
()
try
:
try
:
self
.
file_format_cls
.
load
(
template
)
self
.
load_template_store
(
)
except
ValueError
:
except
ValueError
:
raise
ValidationError
(
_
(
'Format of translation template could not be recognized.'
))
raise
ValidationError
(
_
(
'Format of translation template could not be recognized.'
))
except
Exception
as
e
:
except
Exception
as
e
:
...
@@ -807,6 +806,9 @@ class SubProject(models.Model):
...
@@ -807,6 +806,9 @@ class SubProject(models.Model):
pass
pass
def
get_template_filename
(
self
):
def
get_template_filename
(
self
):
'''
Creates absolute filename for template.
'''
return
os
.
path
.
join
(
self
.
get_path
(),
self
.
template
)
return
os
.
path
.
join
(
self
.
get_path
(),
self
.
template
)
def
save
(
self
,
*
args
,
**
kwargs
):
def
save
(
self
,
*
args
,
**
kwargs
):
...
@@ -911,6 +913,14 @@ class SubProject(models.Model):
...
@@ -911,6 +913,14 @@ class SubProject(models.Model):
'''
'''
return
self
.
file_format_cls
.
mark_fuzzy
return
self
.
file_format_cls
.
mark_fuzzy
def
load_template_store
(
self
):
'''
Loads translate-toolkit store for template.
'''
return
self
.
file_format_cls
.
load
(
self
.
get_template_filename
(),
)
def
get_template_store
(
self
):
def
get_template_store
(
self
):
'''
'''
Gets translate-toolkit store for template.
Gets translate-toolkit store for template.
...
@@ -920,9 +930,7 @@ class SubProject(models.Model):
...
@@ -920,9 +930,7 @@ class SubProject(models.Model):
return
None
return
None
if
self
.
_template_store
is
None
:
if
self
.
_template_store
is
None
:
self
.
_template_store
=
self
.
file_format_cls
.
load
(
self
.
_template_store
=
self
.
load_template_store
()
self
.
get_template_filename
(),
)
return
self
.
_template_store
return
self
.
_template_store
...
...
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