diff --git a/accounts/edit_forms.py b/accounts/edit_forms.py index 1f00bb1e..a6dda1c9 100644 --- a/accounts/edit_forms.py +++ b/accounts/edit_forms.py @@ -60,10 +60,24 @@ class HomeForm(forms.ModelForm): class WorkForm(forms.ModelForm): position = forms.CharField(label=_(u'Укажите вашу должность'), required=False, widget=forms.TextInput()) + company = forms.CharField(label=_(u'Укажите вашу компанию'), required=False, + widget=forms.HiddenInput(attrs={'class': 'select2'})) + + def __init__(self, *args, **kwargs): + super(WorkForm, self).__init__(*args, **kwargs) + if self.instance.company: + self.fields['company'].widget = forms.HiddenInput(attrs={'class': 'select2', 'data-init-text': self.instance.company.name}) + class Meta: model = User - fields = ('position',) + fields = ('position', 'company') + + def clean_company(self): + try: + return Company.objects.get(id=self.cleaned_data['company']) + except Company.DoesNotExist: + return None class AboutCompanyForm(forms.ModelForm): diff --git a/accounts/views.py b/accounts/views.py index 7a6413ce..eb7fba7c 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -258,10 +258,10 @@ class WorkView(ProfileInvalidView): user = self.request.user form = self.form_class(self.request.POST, instance=user) user = form.save() - company = user.company - + #company = user.company - response = {'success': True, 'url':company.get_permanent_url()} + #response = {'success': True, 'url':company.get_permanent_url()} + response = {'success': True} return HttpResponse(json.dumps(response), content_type='application/json') diff --git a/templates/client/includes/accounts/current_user.html b/templates/client/includes/accounts/current_user.html index ae89d84e..4d8f6528 100644 --- a/templates/client/includes/accounts/current_user.html +++ b/templates/client/includes/accounts/current_user.html @@ -184,9 +184,9 @@
- +
- {{ work_form.work }} + {{ work_form.company }}