Moved project list to model

This commit is contained in:
Tris Forster
2023-02-23 18:37:21 +11:00
parent 6ec5808275
commit f49ff0fd0e
3 changed files with 22 additions and 12 deletions
+6 -2
View File
@@ -248,7 +248,7 @@ class WorkUpdateView(CollectionMixin, UpdateView):
class WorkAddToProject(ProjectMixin, FormView):
class WorkAddToProject(CollectionMixin, FormView):
admin_required = True
form_class = forms.ProjectSelectForm
template_name = "interface/default_form.html"
@@ -261,8 +261,12 @@ class WorkAddToProject(ProjectMixin, FormView):
f = super(WorkAddToProject, self).get_form()
qs = f.fields['project'].queryset
# Limit to projects for ensembles where we are an admin and they haven't occured yet
qs = qs.filter(ensemble__admins=self.request.user, event_date__gt=now())
# dont show projects already added to
work = self.get_object()
qs = qs.filter(ensemble_id=self.request.ensemble_id).exclude(pk__in=work.projects.all())
qs = qs.exclude(pk__in=work.projects.all())
f.fields['project'].queryset = qs
return f