0005-django22-rename-permissions-49188.patch
passerelle/base/migrations/0001_initial.py | ||
---|---|---|
19 | 19 |
('resource_pk', models.PositiveIntegerField()), |
20 | 20 |
], |
21 | 21 |
options={ |
22 |
'permissions': (('view_accessright', 'Can view access right'),),
|
|
22 |
'permissions': (('see_accessright', 'Can see access right'),),
|
|
23 | 23 |
}, |
24 | 24 |
bases=(models.Model,), |
25 | 25 |
), |
passerelle/base/migrations/0005_resourcelog.py | ||
---|---|---|
25 | 25 |
('extra', django.contrib.postgres.fields.jsonb.JSONField(default={}, verbose_name=b'extras')), |
26 | 26 |
], |
27 | 27 |
options={ |
28 |
'permissions': (('view_resourcelog', 'Can view resource logs'),),
|
|
28 |
'permissions': (('see_resourcelog', 'Can see resource logs'),),
|
|
29 | 29 |
}, |
30 | 30 |
), |
31 | 31 |
] |
passerelle/base/migrations/0020_auto_20200515_1923.py | ||
---|---|---|
14 | 14 |
operations = [ |
15 | 15 |
migrations.AlterModelOptions( |
16 | 16 |
name='resourcelog', |
17 |
options={'ordering': ('id',), 'permissions': (('view_resourcelog', 'Can view resource logs'),)},
|
|
17 |
options={'ordering': ('id',), 'permissions': (('see_resourcelog', 'Can see resource logs'),)},
|
|
18 | 18 |
), |
19 | 19 |
] |
passerelle/base/migrations/0028_rename_permissions.py | ||
---|---|---|
1 |
# -*- coding: utf-8 -*- |
|
2 |
from __future__ import unicode_literals |
|
3 | ||
4 |
from django.db import migrations |
|
5 | ||
6 | ||
7 |
def rename_permissions(apps, schema_editor): |
|
8 |
Permission = apps.get_model('auth', 'Permission') |
|
9 |
ContentType = apps.get_model('contenttypes', 'ContentType') |
|
10 | ||
11 |
try: |
|
12 |
ct = ContentType.objects.get(app_label='base', model='accessright') |
|
13 |
except ContentType.DoesNotExist: |
|
14 |
# db from scratch: contenttypes are created on post_migrate signal |
|
15 |
return |
|
16 | ||
17 |
if not Permission.objects.filter(content_type=ct, codename='see_accessright').exists(): |
|
18 |
# old schema, rename view_accessright permission |
|
19 |
p = Permission.objects.get(content_type=ct, codename='view_accessright') |
|
20 |
p.codename = 'see_accessright' |
|
21 |
p.name = 'Can see access right' |
|
22 |
p.save() |
|
23 | ||
24 |
ct = ContentType.objects.get(app_label='base', model='resourcelog') |
|
25 |
if not Permission.objects.filter(content_type=ct, codename='see_resourcelog').exists(): |
|
26 |
# old schema, rename view_resourcelog permission |
|
27 |
p = Permission.objects.get(content_type=ct, codename='view_resourcelog') |
|
28 |
p.codename = 'see_resourcelog' |
|
29 |
p.name = 'Can see resource log' |
|
30 |
p.save() |
|
31 | ||
32 | ||
33 |
class Migration(migrations.Migration): |
|
34 | ||
35 |
dependencies = [ |
|
36 |
('base', '0027_transaction_id'), |
|
37 |
] |
|
38 | ||
39 |
operations = [ |
|
40 |
migrations.RunPython(rename_permissions, reverse_code=migrations.RunPython.noop), |
|
41 |
] |
passerelle/base/models.py | ||
---|---|---|
11 | 11 |
import itertools |
12 | 12 |
import uuid |
13 | 13 | |
14 |
from django import VERSION |
|
14 | 15 |
from django.apps import apps |
15 | 16 |
from django.conf import settings |
16 | 17 |
from django.contrib.postgres.fields import JSONField |
... | ... | |
642 | 643 | |
643 | 644 |
class Meta: |
644 | 645 |
permissions = ( |
645 |
('view_accessright', 'Can view access right'),
|
|
646 |
('see_accessright', 'Can see access right'),
|
|
646 | 647 |
) |
647 | 648 |
unique_together = ( |
648 | 649 |
('codename', 'resource_type', 'resource_pk', 'apiuser'), |
... | ... | |
810 | 811 |
class Meta: |
811 | 812 |
ordering = ('id',) |
812 | 813 |
permissions = ( |
813 |
('view_resourcelog', 'Can view resource logs'),
|
|
814 |
('see_resourcelog', 'Can see resource logs'),
|
|
814 | 815 |
) |
815 | 816 | |
816 | 817 |
@property |
passerelle/sms/templates/passerelle/manage/messages_service_view.html | ||
---|---|---|
3 | 3 | |
4 | 4 |
{% block endpoints %} |
5 | 5 |
{{ block.super }} |
6 |
{% if perms.base.view_accessright %}
|
|
6 |
{% if perms.base.see_accessright %}
|
|
7 | 7 |
<div> |
8 | 8 |
<a rel="popup" href="/manage{{ object.get_absolute_url }}test-send/"> |
9 | 9 |
{% trans 'Send a test message' %} |
passerelle/templates/passerelle/manage/service_view.html | ||
---|---|---|
106 | 106 |
{% endblock %} |
107 | 107 | |
108 | 108 |
<div id="security" class="section"> |
109 |
{% if perms.base.view_accessright %}
|
|
109 |
{% if perms.base.see_accessright %}
|
|
110 | 110 |
<h3>{% trans "Security" %}</h3> |
111 | 111 |
<div> |
112 | 112 |
{% block security %} |
... | ... | |
119 | 119 |
{% endif %} |
120 | 120 |
</div> |
121 | 121 | |
122 |
{% if perms.base.view_resourcelog %}
|
|
122 |
{% if perms.base.see_resourcelog %}
|
|
123 | 123 |
<div id="logs" class="section"> |
124 | 124 |
<h3>{% trans "Logs" %} |
125 | 125 |
<a class="button" href="{% url 'view-logs-connector' connector=object.get_connector_slug slug=object.slug %}">{% trans "Full page & filter" %}</a> |
126 |
- |