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
649d24c7
Commit
649d24c7
authored
Jun 07, 2012
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support for storing and validating link to repository (issue #48)
parent
ba43670a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
1 deletion
+35
-1
weblate/trans/models.py
weblate/trans/models.py
+35
-1
No files found.
weblate/trans/models.py
View file @
649d24c7
...
@@ -57,6 +57,27 @@ def validate_filemask(val):
...
@@ -57,6 +57,27 @@ def validate_filemask(val):
if
not
'*'
in
val
:
if
not
'*'
in
val
:
raise
ValidationError
(
_
(
'File mask does not contain * as a language placeholder!'
))
raise
ValidationError
(
_
(
'File mask does not contain * as a language placeholder!'
))
def
is_repo_link
(
val
):
'''
Checks whethere repository is just a link for other one.
'''
return
val
.
startswith
(
'weblate://'
)
def
get_linked_repo
(
val
):
'''
Returns subproject for linked repo.
'''
if
not
is_repo_link
(
val
):
return
None
project
,
subproject
=
self
.
repo
[
10
:].
split
(
'/'
,
1
)
return
SubProject
.
objects
.
get
(
slug
=
subproject
,
project__slug
=
project
)
def
validate_repo
(
val
):
try
:
get_linked_repo
(
val
)
except
:
raise
ValidationError
(
_
(
'Invalid link to repository!'
))
class
Project
(
models
.
Model
):
class
Project
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
100
)
name
=
models
.
CharField
(
max_length
=
100
)
slug
=
models
.
SlugField
(
db_index
=
True
)
slug
=
models
.
SlugField
(
db_index
=
True
)
...
@@ -172,7 +193,8 @@ class SubProject(models.Model):
...
@@ -172,7 +193,8 @@ class SubProject(models.Model):
project
=
models
.
ForeignKey
(
Project
)
project
=
models
.
ForeignKey
(
Project
)
repo
=
models
.
CharField
(
repo
=
models
.
CharField
(
max_length
=
200
,
max_length
=
200
,
help_text
=
_
(
'URL of Git repository'
)
help_text
=
_
(
'URL of Git repository'
),
validators
=
[
validate_repo
],
)
)
push
=
models
.
CharField
(
push
=
models
.
CharField
(
max_length
=
200
,
max_length
=
200
,
...
@@ -259,6 +281,18 @@ class SubProject(models.Model):
...
@@ -259,6 +281,18 @@ class SubProject(models.Model):
'''
'''
return
self
.
push
!=
''
and
self
.
push
is
not
None
return
self
.
push
!=
''
and
self
.
push
is
not
None
def
is_repo_link
(
self
):
'''
Checks whethere repository is just a link for other one.
'''
return
is_repo_link
(
self
.
repo
)
def
get_linked_repo
(
self
):
'''
Returns subproject for linked repo.
'''
return
get_linked_repo
(
self
.
repo
)
def
get_repo
(
self
):
def
get_repo
(
self
):
'''
'''
Gets Git repository object.
Gets Git repository object.
...
...
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