summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-11-22 22:39:27 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-11-28 11:40:17 +0100
commit008343e5b2944ae34fd4b7c721b50bb414446b1d (patch)
tree44aa25e6e96e365034ff011c3c8d3fa795fa7919
parent22fc81db0fb937e8b89af5f72892c9a3cc5cc1ba (diff)
downloadIshtar-008343e5b2944ae34fd4b7c721b50bb414446b1d.tar.bz2
Ishtar-008343e5b2944ae34fd4b7c721b50bb414446b1d.zip
Sheet: fix treatment file edit
-rw-r--r--archaeological_finds/ishtar_menu.py16
-rw-r--r--archaeological_finds/models_treatments.py16
-rw-r--r--fixtures/initial_data-auth-fr.json65
-rw-r--r--ishtar_common/migrations/0076_migrate_treatmentfile_permissions.py34
4 files changed, 63 insertions, 68 deletions
diff --git a/archaeological_finds/ishtar_menu.py b/archaeological_finds/ishtar_menu.py
index 2f37f4c4b..cf903e2f5 100644
--- a/archaeological_finds/ishtar_menu.py
+++ b/archaeological_finds/ishtar_menu.py
@@ -99,23 +99,23 @@ MENU_SECTIONS = [
MenuItem('treatmentfle_search',
_(u"Search"),
model=models.TreatmentFile,
- access_controls=['view_filetreatment',
- 'view_own_filetreatment']),
+ access_controls=['view_treatmentfile',
+ 'view_own_treatmentfile']),
MenuItem('treatmentfle_creation',
_(u"Creation"),
model=models.TreatmentFile,
- access_controls=['change_filetreatment',
- 'change_own_filetreatment']),
+ access_controls=['change_treatmentfile',
+ 'change_own_treatmentfile']),
MenuItem('treatmentfle_modification',
_(u"Modification"),
model=models.TreatmentFile,
- access_controls=['change_filetreatment',
- 'change_own_filetreatment']),
+ access_controls=['change_treatmentfile',
+ 'change_own_treatmentfile']),
MenuItem('treatmentfle_deletion',
_(u"Deletion"),
model=models.TreatmentFile,
- access_controls=['change_filetreatment',
- 'change_own_filetreatment']),
+ access_controls=['change_treatmentfile',
+ 'change_own_treatmentfile']),
SectionItem(
'admin_act_fletreatments', _(u"Administrative act"),
childs=[
diff --git a/archaeological_finds/models_treatments.py b/archaeological_finds/models_treatments.py
index bc5eace58..a902741a3 100644
--- a/archaeological_finds/models_treatments.py
+++ b/archaeological_finds/models_treatments.py
@@ -782,21 +782,15 @@ class TreatmentFile(DashboardFormItem, ClosedItem, BaseHistorizedItem,
verbose_name_plural = _(u"Treatment requests")
unique_together = ('year', 'index')
permissions = (
- ("view_filetreatment",
+ ("view_treatmentfile",
u"Can view all Treatment requests"),
- ("add_filetreatment",
- u"Can add Treatment request"),
- ("change_filetreatment",
- u"Can change Treatment request"),
- ("delete_filetreatment",
- u"Can delete Treatment request"),
- ("view_own_filetreatment",
+ ("view_own_treatmentfile",
u"Can view own Treatment request"),
- ("add_own_filetreatment",
+ ("add_own_treatmentfile",
u"Can add own Treatment request"),
- ("change_own_filetreatment",
+ ("change_own_treatmentfile",
u"Can change own Treatment request"),
- ("delete_own_filetreatment",
+ ("delete_own_treatmentfile",
u"Can delete own Treatment request"),
)
ordering = ('cached_label',)
diff --git a/fixtures/initial_data-auth-fr.json b/fixtures/initial_data-auth-fr.json
index feecf1e8a..64fbd8051 100644
--- a/fixtures/initial_data-auth-fr.json
+++ b/fixtures/initial_data-auth-fr.json
@@ -3852,39 +3852,6 @@
{
"model": "auth.permission",
"fields": {
- "name": "Can add Treatment file",
- "content_type": [
- "archaeological_finds",
- "treatmentfile"
- ],
- "codename": "add_treatmentfile"
- }
-},
-{
- "model": "auth.permission",
- "fields": {
- "name": "Can change Treatment file",
- "content_type": [
- "archaeological_finds",
- "treatmentfile"
- ],
- "codename": "change_treatmentfile"
- }
-},
-{
- "model": "auth.permission",
- "fields": {
- "name": "Can delete Treatment file",
- "content_type": [
- "archaeological_finds",
- "treatmentfile"
- ],
- "codename": "delete_treatmentfile"
- }
-},
-{
- "model": "auth.permission",
- "fields": {
"name": "Can add Warehouse division",
"content_type": [
"archaeological_warehouse",
@@ -4121,7 +4088,7 @@
"archaeological_finds",
"treatmentfile"
],
- "codename": "view_filetreatment"
+ "codename": "view_treatmentfile"
}
},
{
@@ -4132,7 +4099,7 @@
"archaeological_finds",
"treatmentfile"
],
- "codename": "view_own_filetreatment"
+ "codename": "view_own_treatmentfile"
}
},
{
@@ -4143,7 +4110,7 @@
"archaeological_finds",
"treatmentfile"
],
- "codename": "add_own_filetreatment"
+ "codename": "add_own_treatmentfile"
}
},
{
@@ -4154,7 +4121,7 @@
"archaeological_finds",
"treatmentfile"
],
- "codename": "change_own_filetreatment"
+ "codename": "change_own_treatmentfile"
}
},
{
@@ -4165,7 +4132,7 @@
"archaeological_finds",
"treatmentfile"
],
- "codename": "delete_own_filetreatment"
+ "codename": "delete_own_treatmentfile"
}
},
{
@@ -4308,7 +4275,7 @@
"archaeological_finds",
"treatmentfile"
],
- "codename": "add_filetreatment"
+ "codename": "add_treatmentfile"
}
},
{
@@ -4319,7 +4286,7 @@
"archaeological_finds",
"treatmentfile"
],
- "codename": "change_filetreatment"
+ "codename": "change_treatmentfile"
}
},
{
@@ -4330,7 +4297,7 @@
"archaeological_finds",
"treatmentfile"
],
- "codename": "delete_filetreatment"
+ "codename": "delete_treatmentfile"
}
},
{
@@ -5935,7 +5902,7 @@
"name": "Demandes de traitement : ajout",
"permissions": [
[
- "add_filetreatment",
+ "add_treatmentfile",
"archaeological_finds",
"treatmentfile"
]
@@ -5948,12 +5915,12 @@
"name": "Demandes de traitement : modification/suppression",
"permissions": [
[
- "change_filetreatment",
+ "change_treatmentfile",
"archaeological_finds",
"treatmentfile"
],
[
- "delete_filetreatment",
+ "delete_treatmentfile",
"archaeological_finds",
"treatmentfile"
]
@@ -5966,7 +5933,7 @@
"name": "Demandes de traitement : lecture",
"permissions": [
[
- "view_filetreatment",
+ "view_treatmentfile",
"archaeological_finds",
"treatmentfile"
]
@@ -5979,7 +5946,7 @@
"name": "Demandes de traitement rattach\u00e9es : ajout",
"permissions": [
[
- "add_own_filetreatment",
+ "add_own_treatmentfile",
"archaeological_finds",
"treatmentfile"
]
@@ -5992,7 +5959,7 @@
"name": "Demandes de traitement rattach\u00e9es : lecture",
"permissions": [
[
- "view_own_filetreatment",
+ "view_own_treatmentfile",
"archaeological_finds",
"treatmentfile"
]
@@ -6005,12 +5972,12 @@
"name": "Demandes de traitement rattach\u00e9es : modification/suppression",
"permissions": [
[
- "change_own_filetreatment",
+ "change_own_treatmentfile",
"archaeological_finds",
"treatmentfile"
],
[
- "delete_own_filetreatment",
+ "delete_own_treatmentfile",
"archaeological_finds",
"treatmentfile"
]
diff --git a/ishtar_common/migrations/0076_migrate_treatmentfile_permissions.py b/ishtar_common/migrations/0076_migrate_treatmentfile_permissions.py
new file mode 100644
index 000000000..0defa4efe
--- /dev/null
+++ b/ishtar_common/migrations/0076_migrate_treatmentfile_permissions.py
@@ -0,0 +1,34 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.10 on 2018-11-22 22:17
+from __future__ import unicode_literals
+
+from django.db import migrations
+
+
+def migrate_perm(apps, schema_editor):
+ Permission = apps.get_model('auth', 'Permission')
+ Group = apps.get_model('auth', 'Group')
+ for perm in Permission.objects.filter(
+ codename__icontains='filetreatment').exclude(
+ codename__icontains='source').all():
+ new_codename = perm.codename.replace('filetreatment', 'treatmentfile')
+ q = Permission.objects.filter(
+ codename=new_codename).exclude(pk=perm.pk)
+ if q.count():
+ for gp in Group.objects.filter(permissions=q.all()[0]):
+ gp.permissions.add(perm)
+ q.all()[0].delete()
+ print(new_codename)
+ perm.codename = new_codename
+ perm.save()
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('ishtar_common', '0075_auto_20181108_1908'),
+ ]
+
+ operations = [
+ migrations.RunPython(migrate_perm)
+ ]