1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2024-11-26 18:37:12 +00:00

Add permissions to (un)lock club notes

Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
This commit is contained in:
Yohann D'ANELLO 2021-12-13 18:31:36 +01:00
parent 2f28e34cec
commit b204805ce2
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
2 changed files with 44 additions and 8 deletions

View File

@ -183,14 +183,14 @@ class UserDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView):
modified_note._force_save = True modified_note._force_save = True
modified_note.save() modified_note.save()
context["can_force_lock"] = user.note.is_active and PermissionBackend\ context["can_force_lock"] = user.note.is_active and PermissionBackend\
.check_perm(self.request, "note.change_note_is_active", modified_note) .check_perm(self.request, "note.change_noteuser_is_active", modified_note)
old_note._force_save = True old_note._force_save = True
old_note._no_signal = True old_note._no_signal = True
old_note.save() old_note.save()
modified_note.refresh_from_db() modified_note.refresh_from_db()
modified_note.is_active = True modified_note.is_active = True
context["can_unlock_note"] = not user.note.is_active and PermissionBackend\ context["can_unlock_note"] = not user.note.is_active and PermissionBackend\
.check_perm(self.request, "note.change_note_is_active", modified_note) .check_perm(self.request, "note.change_noteuser_is_active", modified_note)
return context return context
@ -452,23 +452,23 @@ class ClubDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView):
modified_note = NoteClub.objects.get(pk=club.note.pk) modified_note = NoteClub.objects.get(pk=club.note.pk)
# Don't log these tests # Don't log these tests
modified_note._no_signal = True modified_note._no_signal = True
modified_note.is_active = True modified_note.is_active = False
modified_note.inactivity_reason = 'manual' modified_note.inactivity_reason = 'manual'
context["can_lock_note"] = club.note.is_active and PermissionBackend \ context["can_lock_note"] = club.note.is_active and PermissionBackend \
.check_perm(self.request, "note.change_noteuser_is_active", modified_note) .check_perm(self.request, "note.change_noteclub_is_active", modified_note)
old_note = NoteClub.objects.select_for_update().get(pk=club.note.pk) old_note = NoteClub.objects.select_for_update().get(pk=club.note.pk)
modified_note.inactivity_reason = 'forced' modified_note.inactivity_reason = 'forced'
modified_note._force_save = True modified_note._force_save = True
modified_note.save() modified_note.save()
context["can_force_lock"] = club.note.is_active and PermissionBackend \ context["can_force_lock"] = club.note.is_active and PermissionBackend \
.check_perm(self.request, "note.change_note_is_active", modified_note) .check_perm(self.request, "note.change_noteclub_is_active", modified_note)
old_note._force_save = True old_note._force_save = True
old_note._no_signal = True old_note._no_signal = True
old_note.save() old_note.save()
modified_note.refresh_from_db() modified_note.refresh_from_db()
modified_note.is_active = True modified_note.is_active = True
context["can_unlock_note"] = not club.note.is_active and PermissionBackend \ context["can_unlock_note"] = not club.note.is_active and PermissionBackend \
.check_perm(self.request, "note.change_note_is_active", modified_note) .check_perm(self.request, "note.change_noteclub_is_active", modified_note)
return context return context

View File

@ -2871,6 +2871,38 @@
"description": "Changer l'image de n'importe quelle note" "description": "Changer l'image de n'importe quelle note"
} }
}, },
{
"model": "permission.permission",
"pk": 184,
"fields": {
"model": [
"note",
"noteclub"
],
"query": "[\"AND\", {\"club\": [\"club\"]}, [\"OR\", {\"inactivity_reason\": \"manual\"}, {\"is_active\": true}]]",
"type": "change",
"mask": 3,
"field": "is_active",
"permanent": true,
"description": "(Dé)bloquer la note de son club manuellement"
}
},
{
"model": "permission.permission",
"pk": 185,
"fields": {
"model": [
"note",
"noteclub"
],
"query": "[\"AND\", {\"club\": [\"club\"]}, [\"OR\", {\"inactivity_reason\": \"manual\"}, {\"is_active\": true}]]",
"type": "change",
"mask": 3,
"field": "inactivity_reason",
"permanent": true,
"description": "(Dé)bloquer la note de son club et indiquer que cela a été fait manuellement"
}
},
{ {
"model": "permission.role", "model": "permission.role",
"pk": 1, "pk": 1,
@ -3010,7 +3042,9 @@
166, 166,
167, 167,
168, 168,
182 182,
184,
185
] ]
} }
}, },
@ -3278,7 +3312,9 @@
180, 180,
181, 181,
182, 182,
183 183,
184,
185
] ]
} }
}, },