Changeset 480 in main


Ignore:
Timestamp:
11/15/11 15:19:33 (8 years ago)
Author:
anonymous
Message:

fix #44

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/openPLM/plmapp/forms.py

    r463 r480  
    6363    return re.sub("\s+", " ", data.strip(" ")) 
    6464 
     65INVALID_GROUP = _("Bad group, check that the group exists and that you belong" 
     66        " to this group.") 
     67 
    6568def get_creation_form(user, cls=m.PLMObject, data=None, empty_allowed=False): 
    6669    u""" 
     
    9396    form = Form(data=data, empty_permitted=empty_allowed) if data else Form() 
    9497    if issubclass(cls, m.PLMObject): 
     98        # display only valid groups 
    9599        groups = user.groups.all().values_list("id", flat=True) 
    96         form.fields["group"].queryset = m.GroupInfo.objects.filter(id__in=groups) 
     100        field = form.fields["group"] 
     101        field.queryset = m.GroupInfo.objects.filter(id__in=groups) 
     102        field.error_messages["invalid_choice"] = INVALID_GROUP 
    97103    return form 
    98104get_creation_form.cache = {} 
Note: See TracChangeset for help on using the changeset viewer.