mirror of
https://gitlab.crans.org/bde/nk20
synced 2024-11-26 18:37:12 +00:00
🎨 Update activity interface
This commit is contained in:
parent
0a2c9d9c87
commit
5ea8d8f870
@ -182,8 +182,11 @@ class ActivityEntryView(LoginRequiredMixin, TemplateView):
|
|||||||
context["noteuser_ctype"] = ContentType.objects.get_for_model(NoteUser).pk
|
context["noteuser_ctype"] = ContentType.objects.get_for_model(NoteUser).pk
|
||||||
context["notespecial_ctype"] = ContentType.objects.get_for_model(NoteSpecial).pk
|
context["notespecial_ctype"] = ContentType.objects.get_for_model(NoteSpecial).pk
|
||||||
|
|
||||||
context["activities_open"] = Activity.objects.filter(open=True).filter(
|
activities_open = Activity.objects.filter(open=True).filter(
|
||||||
PermissionBackend.filter_queryset(self.request.user, Activity, "view")).filter(
|
PermissionBackend.filter_queryset(self.request.user, Activity, "view")).distinct().all()
|
||||||
PermissionBackend.filter_queryset(self.request.user, Activity, "change")).all()
|
context["activities_open"] = [a for a in activities_open
|
||||||
|
if PermissionBackend.check_perm(self.request.user,
|
||||||
|
"activity.add_entry",
|
||||||
|
Entry(activity=a, note=self.request.user.note,))]
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
@ -18,7 +18,7 @@ class ReadProtectedModelViewSet(viewsets.ModelViewSet):
|
|||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
user = get_current_authenticated_user()
|
user = get_current_authenticated_user()
|
||||||
return self.model.objects.filter(PermissionBackend.filter_queryset(user, self.model, "view"))
|
return self.model.objects.filter(PermissionBackend.filter_queryset(user, self.model, "view")).distinct()
|
||||||
|
|
||||||
|
|
||||||
class ReadOnlyProtectedModelViewSet(viewsets.ReadOnlyModelViewSet):
|
class ReadOnlyProtectedModelViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
@ -32,4 +32,4 @@ class ReadOnlyProtectedModelViewSet(viewsets.ReadOnlyModelViewSet):
|
|||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
user = get_current_authenticated_user()
|
user = get_current_authenticated_user()
|
||||||
return self.model.objects.filter(PermissionBackend.filter_queryset(user, self.model, "view"))
|
return self.model.objects.filter(PermissionBackend.filter_queryset(user, self.model, "view")).distinct()
|
||||||
|
@ -9,6 +9,8 @@ from rest_framework import viewsets
|
|||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework import status
|
from rest_framework import status
|
||||||
from api.viewsets import ReadProtectedModelViewSet, ReadOnlyProtectedModelViewSet
|
from api.viewsets import ReadProtectedModelViewSet, ReadOnlyProtectedModelViewSet
|
||||||
|
from note_kfet.middlewares import get_current_authenticated_user
|
||||||
|
from permission.backends import PermissionBackend
|
||||||
|
|
||||||
from .serializers import NotePolymorphicSerializer, AliasSerializer, ConsumerSerializer,\
|
from .serializers import NotePolymorphicSerializer, AliasSerializer, ConsumerSerializer,\
|
||||||
TemplateCategorySerializer, TransactionTemplateSerializer, TransactionPolymorphicSerializer
|
TemplateCategorySerializer, TransactionTemplateSerializer, TransactionPolymorphicSerializer
|
||||||
@ -150,3 +152,7 @@ class TransactionViewSet(ReadProtectedModelViewSet):
|
|||||||
serializer_class = TransactionPolymorphicSerializer
|
serializer_class = TransactionPolymorphicSerializer
|
||||||
filter_backends = [SearchFilter]
|
filter_backends = [SearchFilter]
|
||||||
search_fields = ['$reason', ]
|
search_fields = ['$reason', ]
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
user = get_current_authenticated_user()
|
||||||
|
return self.model.objects.filter(PermissionBackend.filter_queryset(user, self.model, "view"))
|
||||||
|
@ -10,6 +10,8 @@ from django.utils.translation import gettext_lazy as _
|
|||||||
from django.views.generic import CreateView, UpdateView
|
from django.views.generic import CreateView, UpdateView
|
||||||
from django_tables2 import SingleTableView
|
from django_tables2 import SingleTableView
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
|
|
||||||
|
from activity.models import Entry
|
||||||
from note_kfet.inputs import AmountInput
|
from note_kfet.inputs import AmountInput
|
||||||
from permission.backends import PermissionBackend
|
from permission.backends import PermissionBackend
|
||||||
from permission.views import ProtectQuerysetMixin
|
from permission.views import ProtectQuerysetMixin
|
||||||
@ -52,9 +54,13 @@ class TransactionCreateView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTabl
|
|||||||
# Add a shortcut for entry page for open activities
|
# Add a shortcut for entry page for open activities
|
||||||
if "activity" in settings.INSTALLED_APPS:
|
if "activity" in settings.INSTALLED_APPS:
|
||||||
from activity.models import Activity
|
from activity.models import Activity
|
||||||
context["activities_open"] = Activity.objects.filter(open=True).filter(
|
activities_open = Activity.objects.filter(open=True).filter(
|
||||||
PermissionBackend.filter_queryset(self.request.user, Activity, "view")).filter(
|
PermissionBackend.filter_queryset(self.request.user, Activity, "view")).distinct().all()
|
||||||
PermissionBackend.filter_queryset(self.request.user, Activity, "change")).all()
|
context["activities_open"] = [a for a in activities_open
|
||||||
|
if PermissionBackend.check_perm(self.request.user,
|
||||||
|
"activity.add_entry",
|
||||||
|
Entry(activity=a,
|
||||||
|
note=self.request.user.note, ))]
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
@ -2311,6 +2311,38 @@
|
|||||||
"description": "Ajouter un membre à n'importe quel club"
|
"description": "Ajouter un membre à n'importe quel club"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"model": "permission.permission",
|
||||||
|
"pk": 148,
|
||||||
|
"fields": {
|
||||||
|
"model": [
|
||||||
|
"activity",
|
||||||
|
"activity"
|
||||||
|
],
|
||||||
|
"query": "{\"valid\": false}",
|
||||||
|
"type": "change",
|
||||||
|
"mask": 2,
|
||||||
|
"field": "",
|
||||||
|
"permanent": false,
|
||||||
|
"description": "Modifier une activité non validée"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "permission.permission",
|
||||||
|
"pk": 149,
|
||||||
|
"fields": {
|
||||||
|
"model": [
|
||||||
|
"activity",
|
||||||
|
"activity"
|
||||||
|
],
|
||||||
|
"query": "{\"valid\": false}",
|
||||||
|
"type": "delete",
|
||||||
|
"mask": 2,
|
||||||
|
"field": "",
|
||||||
|
"permanent": false,
|
||||||
|
"description": "Supprimer une activité non validée"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"model": "permission.role",
|
"model": "permission.role",
|
||||||
"pk": 1,
|
"pk": 1,
|
||||||
@ -2643,7 +2675,9 @@
|
|||||||
144,
|
144,
|
||||||
145,
|
145,
|
||||||
146,
|
146,
|
||||||
147
|
147,
|
||||||
|
148,
|
||||||
|
149
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -2690,7 +2724,9 @@
|
|||||||
43,
|
43,
|
||||||
44,
|
44,
|
||||||
45,
|
45,
|
||||||
46
|
46,
|
||||||
|
148,
|
||||||
|
149
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user