Changeset 1173 in main


Ignore:
Timestamp:
06/06/12 07:20:16 (7 years ago)
Author:
zali
Message:

Sponsor template/view : language added to the form

Location:
trunk/openPLM/plmapp
Files:
2 edited

Legend:

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

    r1102 r1173  
    577577    warned = forms.BooleanField(initial=False, required=False, 
    578578                                widget=forms.HiddenInput()) 
     579    language = forms.TypedChoiceField(choices=settings.LANGUAGES) 
    579580 
    580581    class Meta: 
     
    584585    def __init__(self, *args, **kwargs): 
    585586        sponsor = kwargs.pop("sponsor", None) 
     587        language = kwargs.pop("language", None) 
    586588        super(SponsorForm, self).__init__(*args, **kwargs) 
    587589        if "sponsor" in self.data: 
     
    590592            qset = m.GroupInfo.objects.filter(owner__id=sponsor) 
    591593            self.fields["groups"].queryset = qset 
    592         self.fields["groups"].help_text = _("The new user will belong to the selected groups")  
     594        self.fields["groups"].help_text = _("The new user will belong to the selected groups") 
    593595        for key, field in self.fields.iteritems(): 
    594596            if key != "warned": 
  • trunk/openPLM/plmapp/views/main.py

    r1172 r1173  
    6767from django.template import RequestContext 
    6868from django.utils.encoding import iri_to_uri 
     69from django.utils import translation 
    6970from django.utils.translation import ugettext_lazy as _ 
    7071from django.utils.decorators import method_decorator 
     
    17441745    """ 
    17451746    obj, ctx = get_generic_data(request, "User", obj_ref) 
     1747 
    17461748    if request.method == "POST": 
    17471749        form = forms.SponsorForm(request.POST) 
    17481750        if form.is_valid(): 
    17491751            new_user = form.save() 
     1752            new_user.get_profile().language = form.cleaned_data["language"] 
    17501753            obj.sponsor(new_user) 
    17511754            return HttpResponseRedirect("..") 
    17521755    else: 
    1753         form = forms.SponsorForm(initial={"sponsor":obj.id}, sponsor=obj.id) 
     1756        form = forms.SponsorForm(initial={"sponsor":obj.id, "language":obj.language}, sponsor=obj.id) 
    17541757    ctx["sponsor_form"] = form 
    17551758    ctx['current_page'] = 'delegation'  
Note: See TracChangeset for help on using the changeset viewer.