You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.4 KiB
67 lines
1.4 KiB
import json
|
|
from django.http import HttpResponseRedirect, HttpResponse, Http404
|
|
from django.utils.translation import get_language
|
|
from edit_forms import *
|
|
from accounts.views import ProfileInvalidView
|
|
|
|
class BaseView(ProfileInvalidView):
|
|
def form_valid(self, form):
|
|
company = self.request.user.company
|
|
if self.form_class.translation:
|
|
lang = get_language()
|
|
comp_transl = company.translations.get(language_code=lang)
|
|
form = self.form_class(self.request.POST, instance=comp_transl)
|
|
|
|
else:
|
|
form = self.form_class(self.request.POST, instance=company)
|
|
|
|
form.save()
|
|
response = {'success': True}
|
|
return HttpResponse(json.dumps(response), content_type='application/json')
|
|
|
|
|
|
class NameView(BaseView):
|
|
form_class = NameForm
|
|
|
|
|
|
class HomeView(BaseView):
|
|
form_class = HomeForm
|
|
|
|
class SpecializationView(BaseView):
|
|
form_class = SpecializationForm
|
|
|
|
|
|
class PhoneView(BaseView):
|
|
form_class = PhoneForm
|
|
|
|
|
|
class EmailView(BaseView):
|
|
form_class = EmailForm
|
|
|
|
|
|
class WebPageView(BaseView):
|
|
form_class = WebPageForm
|
|
|
|
|
|
class SocialView(BaseView):
|
|
form_class = SocialForm
|
|
|
|
|
|
class TagView(BaseView):
|
|
form_class = TagForm
|
|
|
|
|
|
class FoundationView(BaseView):
|
|
form_class = FoundationForm
|
|
|
|
|
|
class StaffView(BaseView):
|
|
form_class = StaffForm
|
|
|
|
|
|
class DescriptionView(BaseView):
|
|
form_class = DescriptionForm
|
|
|
|
|
|
class AddressView(BaseView):
|
|
form_class = AddressForm |