diff --git a/castellum/execution/feeds.py b/castellum/execution/feeds.py index fbf34e07b4fb9148a952012c3a53031e6c491941..6d6af931eff013e72d88fefe3e9d9c8223f48b11 100644 --- a/castellum/execution/feeds.py +++ b/castellum/execution/feeds.py @@ -19,6 +19,7 @@ # License along with Castellum. If not, see # . +from django.shortcuts import get_object_or_404 from django.urls import reverse from django.utils.translation import gettext_lazy as _ @@ -26,6 +27,7 @@ from castellum.appointments.mixins import BaseAppointmentFeed from castellum.castellum_auth.mixins import ParamAuthMixin from castellum.castellum_auth.mixins import PermissionRequiredMixin from castellum.studies.mixins import StudyMixin +from castellum.studies.models import Resource from castellum.studies.models import Study @@ -65,3 +67,13 @@ class AppointmentFeedForUser(ParamAuthMixin, BaseExecutionAppointmentFeed): for item in items: if self.request.user.has_perms(perms, obj=item.session.study): yield item + + +class ResourceFeed(ParamAuthMixin, BaseExecutionAppointmentFeed): + def items(self): + resource = get_object_or_404(Resource, pk=self.kwargs['pk']) + return ( + super().items() + .filter(session__resource=resource) + .exclude(session__study__status=Study.FINISHED) + ) diff --git a/castellum/execution/urls.py b/castellum/execution/urls.py index af1e31c6df7475006a136cceba98bed0304610c6..b243d9455a8aedb40a4851ff4916d2f3ac2613bf 100644 --- a/castellum/execution/urls.py +++ b/castellum/execution/urls.py @@ -29,6 +29,7 @@ from .api import APIResolveView from .api import APIValidateView from .feeds import AppointmentFeedForStudy from .feeds import AppointmentFeedForUser +from .feeds import ResourceFeed from .views import AdditionalInfoUpdateView from .views import AttributesUpdateView from .views import CalendarView @@ -53,6 +54,7 @@ from .views import TagView app_name = 'execution' urlpatterns = [ path('calendar/feed/', AppointmentFeedForUser.as_view(), name='calendar-user-feed'), + path('resources//', ResourceFeed.as_view(), name='resource-feed'), path('/', StudyDetailView.as_view(), name='study-detail'), path('/resolve/', ResolveView.as_view(), name='resolve'), path('/news/', NewsMailView.as_view(), name='news-mail'), diff --git a/castellum/templates/feeds.html b/castellum/templates/feeds.html index 881789c16e945e47312f2f3eb0bb24025c337727..baa3840be7ffd82c8ea724cb6cf4eda5e850c693 100644 --- a/castellum/templates/feeds.html +++ b/castellum/templates/feeds.html @@ -40,6 +40,7 @@

{% translate 'Per Resource' %}