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
55706363
Commit
55706363
authored
Sep 16, 2015
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add permission for changes CSV download
Fixes #817 Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
6824014b
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
51 additions
and
0 deletions
+51
-0
docs/admin/access.rst
docs/admin/access.rst
+2
-0
weblate/accounts/models.py
weblate/accounts/models.py
+1
-0
weblate/html/trans/change_list.html
weblate/html/trans/change_list.html
+7
-0
weblate/trans/migrations/0045_auto_20150916_1007.py
weblate/trans/migrations/0045_auto_20150916_1007.py
+18
-0
weblate/trans/models/changes.py
weblate/trans/models/changes.py
+3
-0
weblate/trans/permissions.py
weblate/trans/permissions.py
+8
-0
weblate/trans/templatetags/permissions.py
weblate/trans/templatetags/permissions.py
+5
-0
weblate/trans/views/changes.py
weblate/trans/views/changes.py
+7
-0
No files found.
docs/admin/access.rst
View file @
55706363
...
@@ -85,6 +85,8 @@ Can edit priority [Managers, Owners]
...
@@ -85,6 +85,8 @@ Can edit priority [Managers, Owners]
Can adjust source string priority
Can adjust source string priority
Can edit check flags [Managers, Owners]
Can edit check flags [Managers, Owners]
Can adjust source string check flags
Can adjust source string check flags
Can download changes [Managers, Owners]
Can download changes in a CSV format.
.. _acl:
.. _acl:
...
...
weblate/accounts/models.py
View file @
55706363
...
@@ -779,6 +779,7 @@ def create_groups(update):
...
@@ -779,6 +779,7 @@ def create_groups(update):
Permission
.
objects
.
get
(
codename
=
'edit_priority'
),
Permission
.
objects
.
get
(
codename
=
'edit_priority'
),
Permission
.
objects
.
get
(
codename
=
'edit_flags'
),
Permission
.
objects
.
get
(
codename
=
'edit_flags'
),
Permission
.
objects
.
get
(
codename
=
'manage_acl'
),
Permission
.
objects
.
get
(
codename
=
'manage_acl'
),
Permission
.
objects
.
get
(
codename
=
'download_changes'
),
)
)
group
,
created
=
Group
.
objects
.
get_or_create
(
name
=
'Managers'
)
group
,
created
=
Group
.
objects
.
get_or_create
(
name
=
'Managers'
)
...
...
weblate/html/trans/change_list.html
View file @
55706363
{% extends "base.html" %}
{% extends "base.html" %}
{% load i18n %}
{% load i18n %}
{% load translations %}
{% load translations %}
{% load permissions %}
{% block breadcrumbs %}
{% block breadcrumbs %}
<li><a
href=
"{% url 'changes' %}"
>
{% trans "Changes" %}
</a></li>
<li><a
href=
"{% url 'changes' %}"
>
{% trans "Changes" %}
</a></li>
...
@@ -8,16 +9,22 @@
...
@@ -8,16 +9,22 @@
{% block content %}
{% block content %}
{% can_download_changes user project as user_can_download_changes %}
{% if user_can_download_changes or changes_rss %}
<ul
class=
"pagination pull-right flip"
>
<ul
class=
"pagination pull-right flip"
>
{% if user_can_download_changes %}
<li>
<li>
<a
href=
"{% url 'changes-csv' %}?{{ query_string }}"
title=
"{% trans "
Download
all
changes
as
CSV
"
%}"
><i
class=
"fa fa-download"
></i></a>
<a
href=
"{% url 'changes-csv' %}?{{ query_string }}"
title=
"{% trans "
Download
all
changes
as
CSV
"
%}"
><i
class=
"fa fa-download"
></i></a>
</li>
</li>
{% endif %}
{% if changes_rss %}
{% if changes_rss %}
<li>
<li>
<a
href=
"{{ changes_rss }}"
title=
"{% trans "
Follow
using
RSS
"
%}"
><i
class=
"fa fa-rss"
></i></a>
<a
href=
"{{ changes_rss }}"
title=
"{% trans "
Follow
using
RSS
"
%}"
><i
class=
"fa fa-rss"
></i></a>
</li>
</li>
{% endif %}
{% endif %}
</ul>
</ul>
{% endif %}
{% include "paginator.html" %}
{% include "paginator.html" %}
...
...
weblate/trans/migrations/0045_auto_20150916_1007.py
0 → 100644
View file @
55706363
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
models
,
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'trans'
,
'0044_auto_20150916_0952'
),
]
operations
=
[
migrations
.
AlterModelOptions
(
name
=
'change'
,
options
=
{
'ordering'
:
[
'-timestamp'
],
'permissions'
:
((
'download_changes'
,
'Can download changes'
),)},
),
]
weblate/trans/models/changes.py
View file @
55706363
...
@@ -239,6 +239,9 @@ class Change(models.Model):
...
@@ -239,6 +239,9 @@ class Change(models.Model):
class
Meta
(
object
):
class
Meta
(
object
):
ordering
=
[
'-timestamp'
]
ordering
=
[
'-timestamp'
]
app_label
=
'trans'
app_label
=
'trans'
permissions
=
(
(
'download_changes'
,
"Can download changes"
),
)
def
__unicode__
(
self
):
def
__unicode__
(
self
):
return
_
(
'%(action)s at %(time)s on %(translation)s by %(user)s'
)
%
{
return
_
(
'%(action)s at %(time)s on %(translation)s by %(user)s'
)
%
{
...
...
weblate/trans/permissions.py
View file @
55706363
...
@@ -253,3 +253,11 @@ def can_manage_acl(user, project):
...
@@ -253,3 +253,11 @@ def can_manage_acl(user, project):
Checks whether user can manage ACL on given project.
Checks whether user can manage ACL on given project.
"""
"""
return
check_permission
(
user
,
project
,
'trans.manage_acl'
)
return
check_permission
(
user
,
project
,
'trans.manage_acl'
)
@
cache_permission
def
can_download_changes
(
user
,
project
):
"""
Checks whether user can download CSV for changes on given project.
"""
return
check_permission
(
user
,
project
,
'trans.download_changes'
)
weblate/trans/templatetags/permissions.py
View file @
55706363
...
@@ -116,3 +116,8 @@ def can_delete_comment(user, project):
...
@@ -116,3 +116,8 @@ def can_delete_comment(user, project):
@
register
.
assignment_tag
@
register
.
assignment_tag
def
can_manage_acl
(
user
,
project
):
def
can_manage_acl
(
user
,
project
):
return
weblate
.
trans
.
permissions
.
can_manage_acl
(
user
,
project
)
return
weblate
.
trans
.
permissions
.
can_manage_acl
(
user
,
project
)
@
register
.
assignment_tag
def
can_download_changes
(
user
,
project
):
return
weblate
.
trans
.
permissions
.
can_download_changes
(
user
,
project
)
weblate/trans/views/changes.py
View file @
55706363
...
@@ -25,9 +25,12 @@ from django.contrib.auth.models import User
...
@@ -25,9 +25,12 @@ from django.contrib.auth.models import User
from
django.utils.translation
import
ugettext
as
_
,
activate
from
django.utils.translation
import
ugettext
as
_
,
activate
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
from
django.db.models
import
Q
from
django.db.models
import
Q
from
django.core.exceptions
import
PermissionDenied
from
weblate.trans.models.changes
import
Change
from
weblate.trans.models.changes
import
Change
from
weblate.trans.views.helper
import
get_project_translation
from
weblate.trans.views.helper
import
get_project_translation
from
weblate.lang.models
import
Language
from
weblate.lang.models
import
Language
from
weblate.trans.permissions
import
can_download_changes
from
urllib
import
urlencode
from
urllib
import
urlencode
import
csv
import
csv
...
@@ -55,6 +58,7 @@ class ChangesView(ListView):
...
@@ -55,6 +58,7 @@ class ChangesView(ListView):
**
kwargs
**
kwargs
)
)
context
[
'title'
]
=
_
(
'Changes'
)
context
[
'title'
]
=
_
(
'Changes'
)
context
[
'project'
]
=
self
.
project
url
=
{}
url
=
{}
...
@@ -205,6 +209,9 @@ class ChangesCSVView(ChangesView):
...
@@ -205,6 +209,9 @@ class ChangesCSVView(ChangesView):
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
object_list
=
self
.
get_queryset
()
object_list
=
self
.
get_queryset
()
if
not
can_download_changes
(
request
.
user
,
self
.
project
):
raise
PermissionDenied
()
# Always output in english
# Always output in english
activate
(
'en'
)
activate
(
'en'
)
...
...
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