def submitandregister(request): d = {"clientip": request.META["REMOTE_ADDR"], "user": request.user} data = prepare_template_data(request) userops = UserProfileOPS() # TODO:site ve pages'e bi care bulmak lazim site = Site.objects.get(is_active=True) pages = Menu.objects.filter(site=site.pk).order_by("order") note = "Kurs onerisi olustur:" try: curuserprof = UserProfile.objects.get(user=request.user) except: log.info("%s kullanici profili bulunamadi" % (request.user), extra=d) curinstprofform = InstProfileForm(prefix="cur") forms = {} for x in xrange(4): forms[x] = [CreateInstForm(prefix=str(x) + "inst"), InstProfileForm(prefix=str(x) + "instprof")] form = CreateCourseForm() if "submit" in request.POST: allf = [] forms = {} for x in xrange(4): if str(x) + "inst-email" in request.POST: forms[x] = [ CreateInstForm(request.POST, prefix=str(x) + "inst"), InstProfileForm(request.POST, prefix=str(x) + "instprof"), ] allf.append(forms[x][0].is_valid()) allf.append(forms[x][1].is_valid()) else: pass curinstprofform = InstProfileForm(request.POST, prefix="cur") form = CreateCourseForm(request.POST) if all([curinstprofform.is_valid(), form.is_valid()]) and all(allf): curinst = curinstprofform.save(commit=False) curinst.user = request.user curinst.save() course = form.save(commit=False) if "fulltext" in request.FILES: course.fulltext = request.FILES["fulltext"] course.save() for key, f in forms.items(): instx = f[0].save(commit=False) passwd = userops.generatenewpass(8) instx.set_password(passwd) instx.save() instxprof = f[1].save(commit=False) instxprof.user = instx instxprof.save() course.trainer.add(instxprof) course.trainer.add(curinst) course.save() note = "Egitim oneriniz basari ile alindi." else: note = "Olusturulamadi" return render_to_response( "training/submitandregister.html", {"site": site, "pages": pages, "note": note, "form": form, "curinstprofform": curinstprofform, "forms": forms}, context_instance=RequestContext(request), )
def submitandregister(request): """ Bu view'ı kullanmıyoruz. Egitmen ve egitim başvurularını sistemden aldığımızda kullanılabilir. :param request: :return: """ userops = UserProfileOPS() data = {'note': "Kurs onerisi olustur:"} curinstprofform = InstProfileForm(prefix="cur") forms = {} for x in xrange(4): forms[x] = [ CreateInstForm(prefix=str(x) + "inst"), InstProfileForm(prefix=str(x) + "instprof") ] form = CreateCourseForm() if "submit" in request.POST: allf = [] forms = {} for x in xrange(4): if str(x) + "inst-email" in request.POST: forms[x] = [ CreateInstForm(request.POST, prefix=str(x) + "inst"), InstProfileForm(request.POST, prefix=str(x) + "instprof") ] allf.append(forms[x][0].is_valid()) allf.append(forms[x][1].is_valid()) else: pass curinstprofform = InstProfileForm(request.POST, prefix="cur") form = CreateCourseForm(request.POST) if all([curinstprofform.is_valid(), form.is_valid()]) and all(allf): curinst = curinstprofform.save(commit=False) curinst.user = request.user curinst.save() course = form.save(commit=False) if 'fulltext' in request.FILES: course.fulltext = request.FILES['fulltext'] course.save() for key, f in forms.items(): instx = f[0].save(commit=False) passwd = userops.generatenewpass(8) instx.set_password(passwd) instx.save() instxprof = f[1].save(commit=False) instxprof.user = instx instxprof.save() course.trainer.add(instxprof) course.trainer.add(curinst) course.save() data['note'] = "Egitim oneriniz basari ile alindi." else: data['note'] = "Olusturulamadi" data['note'] = note data['form'] = form data['curinstprofform'] = curinstprofform data['forms'] = forms return render(request, "training/submitandregister.html", data)
def submitandregister(request): """ Bu view'ı kullanmıyoruz. Egitmen ve egitim başvurularını sistemden aldığımızda kullanılabilir. :param request: :return: """ d = {'clientip': request.META['REMOTE_ADDR'], 'user': request.user} userops = UserProfileOPS() data = getsiteandmenus(request) note = "Kurs onerisi olustur:" curinstprofform = InstProfileForm(prefix="cur") forms = {} for x in xrange(4): forms[x] = [CreateInstForm(prefix=str(x) + "inst"), InstProfileForm(prefix=str(x) + "instprof")] form = CreateCourseForm() if "submit" in request.POST: allf = [] forms = {} for x in xrange(4): if str(x) + "inst-email" in request.POST: forms[x] = [CreateInstForm(request.POST, prefix=str(x) + "inst"), InstProfileForm(request.POST, prefix=str(x) + "instprof")] allf.append(forms[x][0].is_valid()) allf.append(forms[x][1].is_valid()) else: pass curinstprofform = InstProfileForm(request.POST, prefix="cur") form = CreateCourseForm(request.POST) if all([curinstprofform.is_valid(), form.is_valid()]) and all(allf): curinst = curinstprofform.save(commit=False) curinst.user = request.user curinst.save() course = form.save(commit=False) if 'fulltext' in request.FILES: course.fulltext = request.FILES['fulltext'] course.save() for key, f in forms.items(): instx = f[0].save(commit=False) passwd = userops.generatenewpass(8) instx.set_password(passwd) instx.save() instxprof = f[1].save(commit=False) instxprof.user = instx instxprof.save() course.trainer.add(instxprof) course.trainer.add(curinst) course.save() note = "Egitim oneriniz basari ile alindi." else: note = "Olusturulamadi" data['note'] = note data['form'] = form data['curinstprofform'] = curinstprofform data['forms'] = forms return render_to_response("training/submitandregister.html", data, context_instance=RequestContext(request))
def submitandregister(request): d = {'clientip': request.META['REMOTE_ADDR'], 'user': request.user} data = prepare_template_data(request) userops = UserProfileOPS() # TODO:site ve pages'e bi care bulmak lazim site = Site.objects.get(is_active=True) pages = Menu.objects.filter(site=site.pk).order_by('order') note = "Kurs onerisi olustur:" try: curuserprof = UserProfile.objects.get(user=request.user) except: log.info("%s kullanici profili bulunamadi" % (request.user), extra=d) curinstprofform = InstProfileForm(prefix="cur") forms = {} for x in xrange(4): forms[x] = [ CreateInstForm(prefix=str(x) + "inst"), InstProfileForm(prefix=str(x) + "instprof") ] form = CreateCourseForm() if "submit" in request.POST: allf = [] forms = {} for x in xrange(4): if str(x) + "inst-email" in request.POST: forms[x] = [ CreateInstForm(request.POST, prefix=str(x) + "inst"), InstProfileForm(request.POST, prefix=str(x) + "instprof") ] allf.append(forms[x][0].is_valid()) allf.append(forms[x][1].is_valid()) else: pass curinstprofform = InstProfileForm(request.POST, prefix="cur") form = CreateCourseForm(request.POST) if all([curinstprofform.is_valid(), form.is_valid()]) and all(allf): curinst = curinstprofform.save(commit=False) curinst.user = request.user curinst.save() course = form.save(commit=False) if 'fulltext' in request.FILES: course.fulltext = request.FILES['fulltext'] course.save() for key, f in forms.items(): instx = f[0].save(commit=False) passwd = userops.generatenewpass(8) instx.set_password(passwd) instx.save() instxprof = f[1].save(commit=False) instxprof.user = instx instxprof.save() course.trainer.add(instxprof) course.trainer.add(curinst) course.save() note = "Egitim oneriniz basari ile alindi." else: note = "Olusturulamadi" return render_to_response("training/submitandregister.html", { 'site': site, 'pages': pages, 'note': note, 'form': form, 'curinstprofform': curinstprofform, 'forms': forms }, context_instance=RequestContext(request))