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
ce97523e
Commit
ce97523e
authored
Jan 16, 2013
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Exclude ACL protected projects from sitemaps
parent
198c51e4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
6 deletions
+33
-6
weblate/trans/managers.py
weblate/trans/managers.py
+26
-1
weblate/trans/models.py
weblate/trans/models.py
+3
-1
weblate/urls.py
weblate/urls.py
+4
-4
No files found.
weblate/trans/managers.py
View file @
ce97523e
...
@@ -102,10 +102,24 @@ class ProjectManager(models.Manager):
...
@@ -102,10 +102,24 @@ class ProjectManager(models.Manager):
project_ids
=
[
project_ids
=
[
project
.
id
for
project
in
projects
if
project
.
has_acl
(
user
)
project
.
id
for
project
in
projects
if
project
.
has_acl
(
user
)
]
]
if
projects
.
count
==
len
(
project_ids
):
if
projects
.
count
()
==
len
(
project_ids
):
return
projects
return
projects
return
self
.
filter
(
id__in
=
project_ids
)
return
self
.
filter
(
id__in
=
project_ids
)
class
SubProjectManager
(
models
.
Manager
):
def
all_acl
(
self
,
user
):
'''
Returns list of projects user is allowed to access.
'''
from
weblate.trans.models
import
Project
all_projects
=
Project
.
objects
.
all
()
projects
=
Project
.
objects
.
all_acl
(
user
)
if
projects
.
count
()
==
all_projects
.
count
():
return
self
.
all
()
return
self
.
filter
(
project__in
=
projects
)
class
TranslationManager
(
models
.
Manager
):
class
TranslationManager
(
models
.
Manager
):
def
update_from_blob
(
self
,
subproject
,
code
,
path
,
force
=
False
,
request
=
None
):
def
update_from_blob
(
self
,
subproject
,
code
,
path
,
force
=
False
,
request
=
None
):
'''
'''
...
@@ -127,6 +141,17 @@ class TranslationManager(models.Manager):
...
@@ -127,6 +141,17 @@ class TranslationManager(models.Manager):
def
enabled
(
self
):
def
enabled
(
self
):
return
self
.
filter
(
enabled
=
True
)
return
self
.
filter
(
enabled
=
True
)
def
all_acl
(
self
,
user
):
'''
Returns list of projects user is allowed to access.
'''
from
weblate.trans.models
import
Project
all_projects
=
Project
.
objects
.
all
()
projects
=
Project
.
objects
.
all_acl
(
user
)
if
projects
.
count
()
==
all_projects
.
count
():
return
self
.
all
()
return
self
.
filter
(
subproject__project__in
=
projects
)
class
UnitManager
(
models
.
Manager
):
class
UnitManager
(
models
.
Manager
):
def
update_from_unit
(
self
,
translation
,
unit
,
pos
,
template
=
None
):
def
update_from_unit
(
self
,
translation
,
unit
,
pos
,
template
=
None
):
...
...
weblate/trans/models.py
View file @
ce97523e
...
@@ -54,7 +54,7 @@ from weblate.lang.models import Language
...
@@ -54,7 +54,7 @@ from weblate.lang.models import Language
from
weblate.trans.checks
import
CHECKS
from
weblate.trans.checks
import
CHECKS
from
weblate.trans.managers
import
(
from
weblate.trans.managers
import
(
TranslationManager
,
UnitManager
,
DictionaryManager
,
ChangeManager
,
TranslationManager
,
UnitManager
,
DictionaryManager
,
ChangeManager
,
ProjectManager
,
ProjectManager
,
SubProjectManager
,
)
)
from
weblate.trans.filelock
import
FileLock
,
FileLockException
from
weblate.trans.filelock
import
FileLock
,
FileLockException
from
util
import
(
from
util
import
(
...
@@ -615,6 +615,8 @@ class SubProject(models.Model):
...
@@ -615,6 +615,8 @@ class SubProject(models.Model):
help_text
=
ugettext_lazy
(
'Whether translation updates in other subproject will cause automatic translation in this project'
)
help_text
=
ugettext_lazy
(
'Whether translation updates in other subproject will cause automatic translation in this project'
)
)
)
objects
=
SubProjectManager
()
class
Meta
:
class
Meta
:
ordering
=
[
'project__name'
,
'name'
]
ordering
=
[
'project__name'
,
'name'
]
permissions
=
(
permissions
=
(
...
...
weblate/urls.py
View file @
ce97523e
...
@@ -42,17 +42,17 @@ js_info_dict = {
...
@@ -42,17 +42,17 @@ js_info_dict = {
}
}
project_dict
=
{
project_dict
=
{
'queryset'
:
Project
.
objects
.
all
(
),
'queryset'
:
Project
.
objects
.
all
_acl
(
None
),
'date_field'
:
'get_last_change'
,
'date_field'
:
'get_last_change'
,
}
}
subproject_dict
=
{
subproject_dict
=
{
'queryset'
:
SubProject
.
objects
.
all
(
),
'queryset'
:
SubProject
.
objects
.
all
_acl
(
None
),
'date_field'
:
'get_last_change'
,
'date_field'
:
'get_last_change'
,
}
}
translation_dict
=
{
translation_dict
=
{
'queryset'
:
Translation
.
objects
.
all
(
),
'queryset'
:
Translation
.
objects
.
all
_acl
(
None
),
'date_field'
:
'get_last_change'
,
'date_field'
:
'get_last_change'
,
}
}
...
@@ -96,7 +96,7 @@ class EngageLangSitemap(Sitemap):
...
@@ -96,7 +96,7 @@ class EngageLangSitemap(Sitemap):
Return list of existing project, langauge tuples.
Return list of existing project, langauge tuples.
'''
'''
ret
=
[]
ret
=
[]
for
project
in
Project
.
objects
.
all
(
):
for
project
in
Project
.
objects
.
all
_acl
(
None
):
for
lang
in
project
.
get_languages
():
for
lang
in
project
.
get_languages
():
ret
.
append
((
project
,
lang
))
ret
.
append
((
project
,
lang
))
return
ret
return
ret
...
...
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