Ronnie has proposed merging lp:~ronnie.vd.c/loco-directory/627492 into 
lp:loco-directory.

Requested reviews:
  loco-directory-dev (loco-directory-dev)
Related bugs:
  #627492 Limit selection of users to team members
  https://bugs.launchpad.net/bugs/627492


owner, admin and contact profiles in team_edit are now grouped (optgroups) in 
"Team members" (the members in the team that is edited) and "Other members"

This makes it easier to assign the right people
-- 
https://code.launchpad.net/~ronnie.vd.c/loco-directory/627492/+merge/43988
Your team loco-directory-dev is requested to review the proposed merge of 
lp:~ronnie.vd.c/loco-directory/627492 into lp:loco-directory.
=== modified file 'loco_directory/teams/forms.py'
--- loco_directory/teams/forms.py	2010-11-20 17:40:31 +0000
+++ loco_directory/teams/forms.py	2010-12-16 22:51:10 +0000
@@ -4,6 +4,7 @@
 from django.utils.translation import ugettext_lazy as _
 
 from models import Team
+from userprofiles.models import UserProfile
 from common.forms import RenderableMixin
 
 class UpdateTeamForm(forms.ModelForm, RenderableMixin):
@@ -18,18 +19,28 @@
         js = (
               '/media/js/colortip-1.0-jquery.js',
               )
-
-class LoCoCouncilForm(forms.ModelForm, RenderableMixin):
-    class Meta:
+              
+    def __init__(self, *args, **kwargs):
+        super(UpdateTeamForm, self).__init__(*args, **kwargs)
+        user_list = self.grouped_user_list()
+        self.fields['owner_profile'].choices = user_list
+        self.fields['admin_profiles'].choices = user_list
+        self.fields['contact_profiles'].choices = user_list
+        
+    def grouped_user_list(self):
+        other_members, team_members = [], []
+        for profile in UserProfile.objects.filter(user__groups__name__exact=self.instance.lp_name):
+            team_members.append((profile.id, str(profile)))
+        for profile in UserProfile.objects.all().exclude(user__groups__name__exact=self.instance.lp_name):
+            other_members.append((profile.id, str(profile)))
+
+        return [(_('Team members'), team_members),
+                (_('Other members'), other_members)]
+
+
+class LoCoCouncilForm(UpdateTeamForm, RenderableMixin):
+    class Meta(UpdateTeamForm.Meta):
         model = Team
         exclude = ('approved', 'expires_date', 'name', 'lp_name', 'admins', 'owner', 'active')
 
-    class Media:
-        css = {'all': (
-                       '/media/css/colortip-1.0-jquery.css', 
-                       )}
-        js = (
-              '/media/js/colortip-1.0-jquery.js',
-              )
-
 

_______________________________________________
Mailing list: https://launchpad.net/~loco-directory-dev
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~loco-directory-dev
More help   : https://help.launchpad.net/ListHelp

Reply via email to