Merge branch 'master' into task/3672/cleaning_existing_tests
This commit is contained in:
commit
6eec131218
118 changed files with 4326 additions and 3310 deletions
|
|
@ -131,6 +131,12 @@ class BillingAddressForm(forms.ModelForm):
|
|||
}
|
||||
|
||||
|
||||
class BillingAddressFormSignup(BillingAddressForm):
|
||||
name = forms.CharField(label=_('Name'))
|
||||
email = forms.EmailField(label=_('Email Address'))
|
||||
field_order = ['name', 'email']
|
||||
|
||||
|
||||
class UserBillingAddressForm(forms.ModelForm):
|
||||
user = forms.ModelChoiceField(queryset=CustomUser.objects.all(),
|
||||
widget=forms.HiddenInput())
|
||||
|
|
|
|||
|
|
@ -1,4 +1,10 @@
|
|||
from hosting.models import UserHostingKey
|
||||
import logging
|
||||
from oca.pool import WrongIdError
|
||||
|
||||
from hosting.models import UserHostingKey, VMDetail
|
||||
from opennebula_api.serializers import VirtualMachineSerializer
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def get_all_public_keys(customer):
|
||||
|
|
@ -9,3 +15,48 @@ def get_all_public_keys(customer):
|
|||
"""
|
||||
return UserHostingKey.objects.filter(user_id=customer.id).values_list(
|
||||
"public_key", flat=True)
|
||||
|
||||
|
||||
def get_or_create_vm_detail(user, manager, vm_id):
|
||||
"""
|
||||
Returns VMDetail object related to given vm_id. Creates the object
|
||||
if it does not exist
|
||||
|
||||
:param vm_id: The ID of the VM which should be greater than 0.
|
||||
:param user: The CustomUser object that owns this VM
|
||||
:param manager: The OpenNebulaManager object
|
||||
:return: The VMDetail object. None if vm_id is less than or equal to 0.
|
||||
Also, for the cases where the VMDetail does not exist and we can not
|
||||
fetch data about the VM from OpenNebula, the function returns None
|
||||
"""
|
||||
if vm_id <= 0:
|
||||
return None
|
||||
try:
|
||||
vm_detail_obj = VMDetail.objects.get(vm_id=vm_id)
|
||||
except VMDetail.DoesNotExist:
|
||||
try:
|
||||
vm_obj = manager.get_vm(vm_id)
|
||||
except (WrongIdError, ConnectionRefusedError) as e:
|
||||
logger.error(str(e))
|
||||
return None
|
||||
vm = VirtualMachineSerializer(vm_obj).data
|
||||
vm_detail_obj = VMDetail.objects.create(
|
||||
user=user, vm_id=vm_id, disk_size=vm['disk_size'],
|
||||
cores=vm['cores'], memory=vm['memory'],
|
||||
configuration=vm['configuration'], ipv4=vm['ipv4'],
|
||||
ipv6=vm['ipv6']
|
||||
)
|
||||
return vm_detail_obj
|
||||
|
||||
|
||||
def get_vm_price(cpu, memory, disk_size):
|
||||
"""
|
||||
A helper function that computes price of a VM from given cpu, ram and
|
||||
ssd parameters
|
||||
|
||||
:param cpu: Number of cores of the VM
|
||||
:param memory: RAM of the VM
|
||||
:param disk_size: Disk space of the VM
|
||||
:return: The price of the VM
|
||||
"""
|
||||
return (cpu * 5) + (memory * 2) + (disk_size * 0.6)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2017-09-25 20:11+0000\n"
|
||||
"POT-Creation-Date: 2017-10-10 21:35+0530\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
|
@ -736,7 +736,7 @@ msgid "Unknown or unspecified country"
|
|||
msgstr ""
|
||||
|
||||
msgid "Enter your name or company name"
|
||||
msgstr "Geben Sie Ihren Namen oder der Ihrer Firma ein"
|
||||
msgstr "Gib Deinen Namen oder den Name Deines Unternehmens ein"
|
||||
|
||||
msgid "Your username and/or password were incorrect."
|
||||
msgstr "Dein Benutzername und/oder Dein Passwort ist falsch."
|
||||
|
|
@ -771,10 +771,13 @@ msgstr ""
|
|||
msgid "Country"
|
||||
msgstr ""
|
||||
|
||||
msgid "Street Building"
|
||||
msgid "Name"
|
||||
msgstr ""
|
||||
|
||||
msgid "Name"
|
||||
msgid "Email Address"
|
||||
msgstr ""
|
||||
|
||||
msgid "Street Building"
|
||||
msgstr ""
|
||||
|
||||
msgid "Email"
|
||||
|
|
@ -786,14 +789,13 @@ msgstr "Telefon"
|
|||
msgid "Message"
|
||||
msgstr "Nachricht"
|
||||
|
||||
msgid "An email with the activation link has been sent to your email"
|
||||
msgstr ""
|
||||
"Der Link zum Zurücksetzen deines Passwortes wurde an deine E-Mail gesendet"
|
||||
msgid "An email with the activation link has been sent to you"
|
||||
msgstr "Es wurde eine E-Mail mit dem Aktivierungslink an Dich gesendet."
|
||||
|
||||
msgid "Account Activation"
|
||||
msgstr "Accountaktivierung"
|
||||
|
||||
msgid "The link to reset your email has been sent to your email"
|
||||
msgid "The link to reset your password has been sent to your email"
|
||||
msgstr ""
|
||||
"Der Link zum Zurücksetzen deines Passwortes wurde an deine E-Mail gesendet"
|
||||
|
||||
|
|
|
|||
|
|
@ -28,28 +28,34 @@ def handleStripeError(f):
|
|||
body = e.json_body
|
||||
err = body['error']
|
||||
response.update({'error': err['message']})
|
||||
logger.error(str(e))
|
||||
return response
|
||||
except stripe.error.RateLimitError as e:
|
||||
response.update(
|
||||
{'error': "Too many requests made to the API too quickly"})
|
||||
return response
|
||||
except stripe.error.InvalidRequestError as e:
|
||||
logger.error(str(e))
|
||||
response.update({'error': "Invalid parameters"})
|
||||
return response
|
||||
except stripe.error.AuthenticationError as e:
|
||||
# Authentication with Stripe's API failed
|
||||
# (maybe you changed API keys recently)
|
||||
logger.error(str(e))
|
||||
response.update({'error': common_message})
|
||||
return response
|
||||
except stripe.error.APIConnectionError as e:
|
||||
logger.error(str(e))
|
||||
response.update({'error': common_message})
|
||||
return response
|
||||
except stripe.error.StripeError as e:
|
||||
# maybe send email
|
||||
logger.error(str(e))
|
||||
response.update({'error': common_message})
|
||||
return response
|
||||
except Exception as e:
|
||||
# maybe send email
|
||||
logger.error(str(e))
|
||||
response.update({'error': common_message})
|
||||
return response
|
||||
|
||||
|
|
@ -238,7 +244,7 @@ class StripeUtils(object):
|
|||
@staticmethod
|
||||
def get_stripe_plan_id(cpu, ram, ssd, version, app='dcl', hdd=None):
|
||||
"""
|
||||
Returns the stripe plan id string of the form
|
||||
Returns the Stripe plan id string of the form
|
||||
`dcl-v1-cpu-2-ram-5gb-ssd-10gb` based on the input parameters
|
||||
|
||||
:param cpu: The number of cores
|
||||
|
|
@ -256,7 +262,19 @@ class StripeUtils(object):
|
|||
if hdd is not None:
|
||||
dcl_plan_string = '{dcl_plan_string}-hdd-{hdd}gb'.format(
|
||||
dcl_plan_string=dcl_plan_string, hdd=hdd)
|
||||
stripe_plan_id_string = '{app}-v{version}-{plan}'.format(app=app,
|
||||
version=version,
|
||||
plan=dcl_plan_string)
|
||||
stripe_plan_id_string = '{app}-v{version}-{plan}'.format(
|
||||
app=app,
|
||||
version=version,
|
||||
plan=dcl_plan_string)
|
||||
return stripe_plan_id_string
|
||||
|
||||
@staticmethod
|
||||
def get_stripe_plan_name(cpu, memory, disk_size):
|
||||
"""
|
||||
Returns the Stripe plan name
|
||||
:return:
|
||||
"""
|
||||
return "{cpu} Cores, {memory} GB RAM, {disk_size} GB SSD".format(
|
||||
cpu=cpu,
|
||||
memory=memory,
|
||||
disk_size=disk_size)
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ class LoginViewMixin(FormView):
|
|||
|
||||
class ResendActivationLinkViewMixin(FormView):
|
||||
success_message = _(
|
||||
"An email with the activation link has been sent to your email")
|
||||
"An email with the activation link has been sent to you")
|
||||
|
||||
def generate_email_context(self, user):
|
||||
context = {
|
||||
|
|
@ -104,7 +104,7 @@ class ResendActivationLinkViewMixin(FormView):
|
|||
|
||||
class PasswordResetViewMixin(FormView):
|
||||
success_message = _(
|
||||
"The link to reset your email has been sent to your email")
|
||||
"The link to reset your password has been sent to your email")
|
||||
site = ''
|
||||
|
||||
def test_generate_email_context(self, user):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue