コード例 #1
0
ファイル: views.py プロジェクト: ghostmod/pcp
def reg(request):
    if request.method == 'POST':
        form1 = formReg(request.POST)
        form2 = formReg2(request.POST)
        if form1.is_valid() and form2.is_valid():
            # machine
            m_web = get_object_or_404(Machine, name=config.default_web_machine)
            m_mail = get_object_or_404(Machine, name=config.default_mail_machine)
            m_mysql = get_object_or_404(Machine, name=config.default_mysql_machine)
            m_pgsql = get_object_or_404(Machine, name=config.default_pgsql_machine)

            address_id = 0
            if settings.JSONRPC_URL:
                proxy = ServiceProxy(settings.JSONRPC_URL)
                data = proxy.add_address(
                    settings.JSONRPC_USERNAME, settings.JSONRPC_PASSWORD,
                    form1.cleaned_data["company"],
                    form1.cleaned_data["first_name"],
                    form1.cleaned_data["last_name"],
                    form1.cleaned_data["street"],
                    form1.cleaned_data["city"],
                    form1.cleaned_data["city_num"],
                    form1.cleaned_data["phone"],
                    form1.cleaned_data["email"],
                    form1.cleaned_data["ic"],
                    form1.cleaned_data["dic"]
                )
                print data
                address_id = int(data["result"])

            # user
            u = user.objects.create_user(form2.cleaned_data["username"],
                                         form1.cleaned_data["email"],
                                         form2.cleaned_data["password1"])
            u.is_active = False
            u.save()

            # parms
            p = Parms()
            p.home = join("/home", form2.cleaned_data["username"])
            p.note = ""
            p.uid = 0
            p.gid = 0
            p.discount = 0
            p.web_machine = m_web
            p.mail_machine = m_mail
            p.mysql_machine = m_mysql
            p.pgsql_machine = m_pgsql
            p.user = u
            p.address_id = int(address_id)
            p.save()

            message = Message.objects.filter(purpose="reg")
            if message:
                message[0].send(form1.cleaned_data["email"])

            message = _("New user has been registered.")
            send_mail(_('New registration'),
                      message,
                      settings.EMAIL_FROM,
                [address for (name, address) in settings.ADMINS],
                      fail_silently=True)
            #fail_silently - nechci 500 kvuli neodeslanemu mailu

            return HttpResponseRedirect(
                reverse("wsgiadmin.useradmin.views.regok"))
    else:
        form1 = formReg()
        form2 = formReg2()

    form_helper = FormHelper()
    form_helper.form_tag = False

    return render_to_response('reg.html',
        {
            "form1": form1,
            "form2": form2,
            "form_helper": form_helper,
            "title": _("Registration"),
            "action": reverse("wsgiadmin.useradmin.views.reg"),
            "config": config,
            "menu_active": "registration",
        },
        context_instance=RequestContext(request)
    )
コード例 #2
0
ファイル: views.py プロジェクト: a740122/pcp
def reg(request):
    if request.method == 'POST':
        form = RegistrationForm(request.POST)
        if form.is_valid():
            # machine
            if settings.OLD:
                m_web = get_object_or_404(Machine, name=config.default_web_machine)
                m_mail = get_object_or_404(Machine, name=config.default_mail_machine)
                m_mysql = get_object_or_404(Machine, name=config.default_mysql_machine)
                m_pgsql = get_object_or_404(Machine, name=config.default_pgsql_machine)

            # user
            u = user.objects.create_user(form.cleaned_data["username"],
                                         form.cleaned_data["email"],
                                         form.cleaned_data["password1"])
            u.is_active = True
            u.save()

            # parms
            p = Parms()
            p.home = "/dev/null"
            p.note = ""
            p.uid = 0
            p.gid = 0
            p.discount = 0
            if settings.OLD:
                p.web_machine = m_web
                p.mail_machine = m_mail
                p.mysql_machine = m_mysql
                p.pgsql_machine = m_pgsql
            p.user = u
            p.save()

            if config.credit_registration:
                add_credit(u, float(config.credit_registration), free=True)

            message = Message.objects.filter(purpose="reg")
            if message:
                message[0].send(form.cleaned_data["email"])

            message = _("User %s has been registered." % u.username)
            send_mail(_('New registration'),
                      message,
                      settings.EMAIL_FROM,
                [address for (name, address) in settings.ADMINS],
                      fail_silently=True)
            #fail_silently - nechci 500 kvuli neodeslanemu mailu

            return HttpResponseRedirect(
                reverse("wsgiadmin.useradmin.views.regok"))
    else:
        form = RegistrationForm()

    return render_to_response('reg.html',
        {
            "form": form,
            "title": _("Registration"),
            "action": reverse("wsgiadmin.useradmin.views.reg"),
            "config": config,
            "menu_active": "registration",
        },
        context_instance=RequestContext(request)
    )
コード例 #3
0
ファイル: views.py プロジェクト: ghostmod/pcp
def reg(request):
    if request.method == 'POST':
        form1 = formReg(request.POST)
        form2 = formReg2(request.POST)
        if form1.is_valid() and form2.is_valid():
            # machine
            m_web = get_object_or_404(Machine, name=config.default_web_machine)
            m_mail = get_object_or_404(Machine,
                                       name=config.default_mail_machine)
            m_mysql = get_object_or_404(Machine,
                                        name=config.default_mysql_machine)
            m_pgsql = get_object_or_404(Machine,
                                        name=config.default_pgsql_machine)

            address_id = 0
            if settings.JSONRPC_URL:
                proxy = ServiceProxy(settings.JSONRPC_URL)
                data = proxy.add_address(
                    settings.JSONRPC_USERNAME, settings.JSONRPC_PASSWORD,
                    form1.cleaned_data["company"],
                    form1.cleaned_data["first_name"],
                    form1.cleaned_data["last_name"],
                    form1.cleaned_data["street"], form1.cleaned_data["city"],
                    form1.cleaned_data["city_num"],
                    form1.cleaned_data["phone"], form1.cleaned_data["email"],
                    form1.cleaned_data["ic"], form1.cleaned_data["dic"])
                print data
                address_id = int(data["result"])

            # user
            u = user.objects.create_user(form2.cleaned_data["username"],
                                         form1.cleaned_data["email"],
                                         form2.cleaned_data["password1"])
            u.is_active = False
            u.save()

            # parms
            p = Parms()
            p.home = join("/home", form2.cleaned_data["username"])
            p.note = ""
            p.uid = 0
            p.gid = 0
            p.discount = 0
            p.web_machine = m_web
            p.mail_machine = m_mail
            p.mysql_machine = m_mysql
            p.pgsql_machine = m_pgsql
            p.user = u
            p.address_id = int(address_id)
            p.save()

            message = Message.objects.filter(purpose="reg")
            if message:
                message[0].send(form1.cleaned_data["email"])

            message = _("New user has been registered.")
            send_mail(_('New registration'),
                      message,
                      settings.EMAIL_FROM,
                      [address for (name, address) in settings.ADMINS],
                      fail_silently=True)
            #fail_silently - nechci 500 kvuli neodeslanemu mailu

            return HttpResponseRedirect(
                reverse("wsgiadmin.useradmin.views.regok"))
    else:
        form1 = formReg()
        form2 = formReg2()

    form_helper = FormHelper()
    form_helper.form_tag = False

    return render_to_response(
        'reg.html', {
            "form1": form1,
            "form2": form2,
            "form_helper": form_helper,
            "title": _("Registration"),
            "action": reverse("wsgiadmin.useradmin.views.reg"),
            "config": config,
            "menu_active": "registration",
        },
        context_instance=RequestContext(request))
コード例 #4
0
ファイル: views.py プロジェクト: goldenboy/pcp
def reg(request):
    if request.method == 'POST':
        form1 = formReg(request.POST)
        form2 = formReg2(request.POST)
        form3 = PaymentRegForm(request.POST)
        if form1.is_valid() and form2.is_valid() and form3.is_valid():
            # user
            u = user.objects.create_user(form2.cleaned_data["username"],
                                         form1.cleaned_data["email"],
                                         form2.cleaned_data["password1"])
            u.is_active = False
            u.save()
            # adresa
            a = Address()
            a.company = form1.cleaned_data["company"]
            a.residency_name = form1.cleaned_data["name"]
            a.residency_street = form1.cleaned_data["street"]
            a.residency_city = form1.cleaned_data["city"]
            a.residency_city_num = form1.cleaned_data["city_num"]
            a.residency_ic = form1.cleaned_data["ic"]
            a.residency_dic = form1.cleaned_data["dic"]
            a.residency_email = form1.cleaned_data["email"]
            a.residency_phone = form1.cleaned_data["phone"]
            a.save()
            # machine
            m_web = get_object_or_404(Machine, name=config.default_web_machine)
            m_mail = get_object_or_404(Machine,
                                       name=config.default_mail_machine)
            m_mysql = get_object_or_404(Machine,
                                        name=config.default_mysql_machine)
            m_pgsql = get_object_or_404(Machine,
                                        name=config.default_pgsql_machine)
            # parms
            p = Parms()
            p.home = join("/home", form2.cleaned_data["username"])
            p.note = ""
            p.uid = 0
            p.gid = 0
            p.discount = 0
            p.address = a
            p.web_machine = m_web
            p.mail_machine = m_mail
            p.mysql_machine = m_mysql
            p.pgsql_machine = m_pgsql
            p.user = u
            p.save()

            if form3.cleaned_data["pay_method"] == "fee":
                p.fee = settings.PAYMENT_FEE[p.currency]
                p.save()

            message = Message.objects.filter(purpose="reg")
            if message:
                message[0].send(form1.cleaned_data["email"])

            message = _("New user has been registered.")
            send_mail(_('New registration'),
                      message,
                      settings.EMAIL_FROM,
                      [address for (name, address) in settings.ADMINS],
                      fail_silently=True)
            #fail_silently - nechci 500 kvuli neodeslanemu mailu

            return HttpResponseRedirect(
                reverse("wsgiadmin.useradmin.views.regok"))
    else:
        form1 = formReg()
        form2 = formReg2()
        form3 = PaymentRegForm()

    return render_to_response(
        'reg.html', {
            "form1": form1,
            "form2": form2,
            "form3": form3,
            "title": _("Registration"),
            "submit": _("Register"),
            "action": reverse("wsgiadmin.useradmin.views.reg"),
            "config": config,
        },
        context_instance=RequestContext(request))
コード例 #5
0
def reg(request):
    if request.method == 'POST':
        form = RegistrationForm(request.POST)
        if form.is_valid():
            # machine
            if settings.OLD:
                m_web = get_object_or_404(Machine,
                                          name=config.default_web_machine)
                m_mail = get_object_or_404(Machine,
                                           name=config.default_mail_machine)
                m_mysql = get_object_or_404(Machine,
                                            name=config.default_mysql_machine)
                m_pgsql = get_object_or_404(Machine,
                                            name=config.default_pgsql_machine)

            # user
            u = user.objects.create_user(form.cleaned_data["username"],
                                         form.cleaned_data["email"],
                                         form.cleaned_data["password1"])
            u.is_active = True
            u.save()

            # parms
            p = Parms()
            p.home = "/dev/null"
            p.note = ""
            p.uid = 0
            p.gid = 0
            p.discount = 0
            if settings.OLD:
                p.web_machine = m_web
                p.mail_machine = m_mail
                p.mysql_machine = m_mysql
                p.pgsql_machine = m_pgsql
            p.user = u
            p.save()

            if config.credit_registration:
                add_credit(u, float(config.credit_registration), free=True)

            message = Message.objects.filter(purpose="reg")
            if message:
                message[0].send(form.cleaned_data["email"])

            message = _("User %s has been registered." % u.username)
            send_mail(_('New registration'),
                      message,
                      settings.EMAIL_FROM,
                      [address for (name, address) in settings.ADMINS],
                      fail_silently=True)
            #fail_silently - nechci 500 kvuli neodeslanemu mailu

            return HttpResponseRedirect(
                reverse("wsgiadmin.useradmin.views.regok"))
    else:
        form = RegistrationForm()

    return render_to_response(
        'reg.html', {
            "form": form,
            "title": _("Registration"),
            "action": reverse("wsgiadmin.useradmin.views.reg"),
            "config": config,
            "menu_active": "registration",
        },
        context_instance=RequestContext(request))
コード例 #6
0
ファイル: views.py プロジェクト: MechanisM/pcp
def reg(request):
    if request.method == 'POST':
        form1 = formReg(request.POST)
        form2 = formReg2(request.POST)
        form3 = PaymentRegForm(request.POST)
        if form1.is_valid() and form2.is_valid() and form3.is_valid():
            # user
            u = user.objects.create_user(form2.cleaned_data["username"],
                                         form1.cleaned_data["email"],
                                         form2.cleaned_data["password1"])
            u.is_active = False
            u.save()
            # adresa
            a = Address()
            a.company = form1.cleaned_data["company"]
            a.residency_name = form1.cleaned_data["name"]
            a.residency_street = form1.cleaned_data["street"]
            a.residency_city = form1.cleaned_data["city"]
            a.residency_city_num = form1.cleaned_data["city_num"]
            a.residency_ic = form1.cleaned_data["ic"]
            a.residency_dic = form1.cleaned_data["dic"]
            a.residency_email = form1.cleaned_data["email"]
            a.residency_phone = form1.cleaned_data["phone"]
            a.save()
            # machine
            m_web = get_object_or_404(Machine, name=config.default_web_machine)
            m_mail = get_object_or_404(Machine, name=config.default_mail_machine)
            m_mysql = get_object_or_404(Machine, name=config.default_mysql_machine)
            m_pgsql = get_object_or_404(Machine, name=config.default_pgsql_machine)
            # parms
            p = Parms()
            p.home = join("/home", form2.cleaned_data["username"])
            p.note = ""
            p.uid = 0
            p.gid = 0
            p.discount = 0
            p.address = a
            p.web_machine = m_web
            p.mail_machine = m_mail
            p.mysql_machine = m_mysql
            p.pgsql_machine = m_pgsql
            p.user = u
            p.save()

            if form3.cleaned_data["pay_method"] == "fee":
                p.fee = settings.PAYMENT_FEE[p.currency]
                p.save()

            message = Message.objects.filter(purpose="reg")
            if message:
                message[0].send(form1.cleaned_data["email"])

            message = _("New user has been registered.")
            send_mail(_('New registration'),
                      message,
                      settings.EMAIL_FROM,
                [address for (name, address) in settings.ADMINS],
                      fail_silently=True)
            #fail_silently - nechci 500 kvuli neodeslanemu mailu

            return HttpResponseRedirect(
                reverse("wsgiadmin.useradmin.views.regok"))
    else:
        form1 = formReg()
        form2 = formReg2()
        form3 = PaymentRegForm()

    return render_to_response('reg.html',
            {
            "form1": form1,
            "form2": form2,
            "form3": form3,
            "title": _("Registration"),
            "submit": _("Register"),
            "action": reverse("wsgiadmin.useradmin.views.reg"),
            "config": config,
        },
        context_instance=RequestContext(request)
    )