From 82a5adc36d31aff3c77c5108709fed4f130164e1 Mon Sep 17 00:00:00 2001
From: Jorran de Wit <jorrandewit@outlook.com>
Date: Fri, 21 Dec 2018 14:16:54 +0100
Subject: [PATCH] Improvements to production app

---
 production/forms.py                                      | 9 +++++++++
 .../management/commands/add_groups_and_permissions.py    | 7 ++++---
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/production/forms.py b/production/forms.py
index 07b9b20af..350e1bc62 100644
--- a/production/forms.py
+++ b/production/forms.py
@@ -5,6 +5,7 @@ __license__ = "AGPL v3"
 import datetime
 
 from django import forms
+from django.contrib.auth import get_user_model
 
 from . import constants
 from .models import ProductionUser, ProductionStream, ProductionEvent, Proofs,\
@@ -126,7 +127,15 @@ class StreamStatusForm(forms.ModelForm):
         return stream
 
 
+class UserModelChoiceField(forms.ModelChoiceField):
+    def label_from_instance(self, obj):
+         return '{}, {} ({})'.format(obj.last_name, obj.first_name, obj.email)
+
+
 class UserToOfficerForm(forms.ModelForm):
+    user = UserModelChoiceField(queryset=get_user_model().objects.filter(
+        production_user__isnull=True).order_by('last_name'))
+
     class Meta:
         model = ProductionUser
         fields = (
diff --git a/scipost/management/commands/add_groups_and_permissions.py b/scipost/management/commands/add_groups_and_permissions.py
index c8f3fdf54..975560f7a 100644
--- a/scipost/management/commands/add_groups_and_permissions.py
+++ b/scipost/management/commands/add_groups_and_permissions.py
@@ -345,11 +345,11 @@ class Command(BaseCommand):
             can_fix_College_decision,
             can_promote_user_to_production_officer,
             can_view_production,
+            can_view_all_production_streams,
+            can_promote_to_production_team,
             can_attend_VGMs,
             can_view_timesheets,
             can_manage_mailchimp,
-            can_view_all_production_streams,
-            can_promote_to_production_team,
             can_manage_affiliations,
             can_view_statistics,
             can_create_profiles,
@@ -380,7 +380,6 @@ class Command(BaseCommand):
             can_prepare_recommendations_for_voting,
             can_manage_college_composition,
             can_fix_College_decision,
-            can_view_production,
             can_view_timesheets,
             can_publish_accepted_submission,
             can_draft_publication,
@@ -390,6 +389,8 @@ class Command(BaseCommand):
             can_manage_reports,
             can_assign_production_supervisor,
             can_view_all_production_streams,
+            can_view_production,
+            can_promote_user_to_production_officer,
             can_take_decisions_related_to_proofs,
             can_upload_proofs,
             can_run_proofs_by_authors,
-- 
GitLab