def post(self, request, *args, **kwargs): from elect.forms import ElectForm self.form_post = ElectForm(request.POST, request.FILES) if request.is_ajax() and self.form_post.is_valid( ) and request.user.is_elect_new_manager(): post = self.form_post.save(commit=False) new_post = post.create_elect(creator=request.user, name=post.name, description=post.description, image=post.image, list=request.POST.getlist("list"), region=request.POST.getlist("region"), area=request.POST.getlist("area"), birthday=post.birthday, fraction=post.fraction, post_2=post.post_2, vk=post.vk, tg=post.tg, tw=post.tw, ig=post.ig, fb=post.fb, mail=post.mail, phone=post.phone, i_address=post.i_address, address=post.address, site=post.site, type="PUB") return HttpResponse() else: from django.http import HttpResponseBadRequest return HttpResponseBadRequest()
class EditManagerElect(TemplateView): template_name = "managers/manage_create/elect_new/edit_elect.html" def get(self, request, *args, **kwargs): from elect.models import Elect self.elect = Elect.objects.get(pk=self.kwargs["pk"]) return super(EditManagerElect, self).get(request, *args, **kwargs) def get_context_data(self, **kwargs): from elect.forms import ElectForm from lists.models import AuthorityList context = super(EditManagerElect, self).get_context_data(**kwargs) context["form"] = ElectForm(instance=self.elect) context["elect"] = self.elect context["lists"] = AuthorityList.objects.filter(is_active=True) return context def post(self, request, *args, **kwargs): from elect.forms import ElectForm from elect.models import Elect self.elect = Elect.objects.get(pk=self.kwargs["pk"]) self.form_post = ElectForm(request.POST, request.FILES, instance=self.elect) if request.is_ajax() and self.form_post.is_valid( ) and request.user.is_elect_new_manager(): post = self.form_post.save(commit=False) new_post = post.edit_elect(name=post.name, description=post.description, image=post.image, list=request.POST.getlist("list"), region=request.POST.getlist("region"), area=request.POST.getlist("area"), birthday=post.birthday, fraction=post.fraction, manager_id=request.user.pk, post_2=post.post_2, vk=post.vk, tg=post.tg, tw=post.tw, ig=post.ig, fb=post.fb, mail=post.mail, phone=post.phone, i_address=post.i_address, address=post.address, site=post.site) return HttpResponse() else: from django.http import HttpResponseBadRequest return HttpResponseBadRequest()
def get_context_data(self, **kwargs): from elect.forms import ElectForm from lists.models import AuthorityList context = super(CreateManagerElect, self).get_context_data(**kwargs) context["form"] = ElectForm() context["lists"] = AuthorityList.objects.filter(is_active=True) return context
class CreateSuggestElect(TemplateView): template_name = "elect/suggest_elect.html" def get_context_data(self, **kwargs): from elect.forms import ElectForm from lists.models import AuthorityList context = super(CreateSuggestElect, self).get_context_data(**kwargs) context["form"] = ElectForm() context["lists"] = AuthorityList.objects.filter(is_active=True) return context def post(self, request, *args, **kwargs): from elect.forms import ElectForm self.form_post = ElectForm(request.POST, request.FILES) if request.is_ajax() and self.form_post.is_valid( ) and request.user.is_authenticated: post = self.form_post.save(commit=False) new_post = post.create_elect(creator=request.user, name=post.name, description=post.description, image=post.image, list=request.POST.getlist("list"), region=request.POST.getlist("region"), area=request.POST.getlist("area"), birthday=post.birthday, fraction=post.fraction, post_2=post.post_2, vk=post.vk, tg=post.tg, tw=post.tw, ig=post.ig, fb=post.fb, mail=post.mail, phone=post.phone, i_address=post.i_address, address=post.address, site=post.site, type="SUG") return HttpResponse() else: from django.http import HttpResponseBadRequest return HttpResponseBadRequest()
def post(self, request, *args, **kwargs): from elect.forms import ElectForm from elect.models import Elect self.elect = Elect.objects.get(pk=self.kwargs["pk"]) self.form_post = ElectForm(request.POST, request.FILES, instance=self.elect) if request.is_ajax() and self.form_post.is_valid( ) and request.user.is_elect_new_manager(): post = self.form_post.save(commit=False) new_post = post.edit_elect(name=post.name, description=post.description, image=post.image, list=request.POST.getlist("list"), region=request.POST.getlist("region"), area=request.POST.getlist("area"), birthday=post.birthday, fraction=post.fraction, manager_id=request.user.pk, post_2=post.post_2, vk=post.vk, tg=post.tg, tw=post.tw, ig=post.ig, fb=post.fb, mail=post.mail, phone=post.phone, i_address=post.i_address, address=post.address, site=post.site) return HttpResponse() else: from django.http import HttpResponseBadRequest return HttpResponseBadRequest()