Moved project list to model
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user