Exemplo n.º 1
0
Arquivo: tests.py Projeto: a740122/pcp
	def setUp(self):
		u = User.objects.create_user("testuser", "info@localhost", "******")
		u.is_active = False
		#u.save()
		# machine
		m = Machine()
		m.ipv6 = "::1"
		m.ipv4 = "127.0.0.1"
		m.domain = "localhost"
		m.name = "Localhost"
		#static.save()
		# parms
		p = Parms()
		p.home		    = "/home/testuser"
		p.note		    = ""
		p.uid		    = 1000
		p.gid		    = 1000
		p.discount	    = 0
		p.web_machine	= m
		p.mail_machine	= m
		p.mysql_machine	= m
		p.pgsql_machine	= m
		p.user		    = u
		#p.save()

		self.user = u
		self.parms = p
		self.machine = m

		self.factory = RequestFactory()
		self.basic_request = self.factory.get("/")
		self.basic_request.user = self.user
		self.basic_request.session = {}
Exemplo n.º 2
0
    def setUp(self):
        u = User.objects.create_user("testuser", "info@localhost", "******")
        u.is_active = False
        #u.save()
        # machine
        m = Machine()
        m.ipv6 = "::1"
        m.ipv4 = "127.0.0.1"
        m.domain = "localhost"
        m.name = "Localhost"
        #static.save()
        # parms
        p = Parms()
        p.home = "/home/testuser"
        p.note = ""
        p.uid = 1000
        p.gid = 1000
        p.discount = 0
        p.web_machine = m
        p.mail_machine = m
        p.mysql_machine = m
        p.pgsql_machine = m
        p.user = u
        #p.save()

        self.user = u
        self.parms = p
        self.machine = m

        self.factory = RequestFactory()
        self.basic_request = self.factory.get("/")
        self.basic_request.user = self.user
        self.basic_request.session = {}
Exemplo n.º 3
0
	def setUp(self):
		u = User.objects.create_user("testuser", "info@localhost", "******")
		u.is_active = False
		#u.save()
		# adresa
		a = Address()
		a.company				= "xxx"
		a.residency_name		= "xxx"
		a.residency_street		= "xxx"
		a.residency_city		= "xxx"
		a.residency_city_num	= "56301"
		a.residency_ic			= "1234"
		a.residency_dic			= "CZ1234"
		a.residency_email		= "info@localhost"
		a.residency_phone		= "+420123456789"
		#a.save()
		# machine
		m = Machine()
		m.ipv6 = "::1"
		m.ipv4 = "127.0.0.1"
		m.domain = "localhost"
		m.name = "Localhost"
		#m.save()
		# parms
		p = Parms()
		p.home		    = "/home/testuser"
		p.note		    = ""
		p.uid		    = 1000
		p.gid		    = 1000
		p.discount	    = 0
		p.address	    = a
		p.web_machine	= m
		p.mail_machine	= m
		p.mysql_machine	= m
		p.pgsql_machine	= m
		p.user		    = u
		#p.save()

		self.user = u
		self.parms = p
		self.machine = m
		self.address = a

		self.factory = RequestFactory()
		self.basic_request = self.factory.get("/")
		self.basic_request.user = self.user
		self.basic_request.session = {}
Exemplo n.º 4
0
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)
    )
Exemplo n.º 5
0
Arquivo: views.py Projeto: 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)
    )
Exemplo n.º 6
0
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))
Exemplo n.º 7
0
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))
Exemplo n.º 8
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))
Exemplo n.º 9
0
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)
    )