Send account details in email

This commit is contained in:
M.Ravi 2017-09-22 12:01:09 +02:00
parent f67b69d490
commit 994ffaf117
4 changed files with 25 additions and 4 deletions

View File

@ -10,5 +10,13 @@ You can activate your Data Center Light account by <a href="{{base_url}}{{activa
You can also copy and paste the following link into the address bar of your browser<br/>
to activate your Data Center Light account.<br/>
{{base_url}}{{activation_link}}
{% if account_details %}
<br/><br/>
Your account details are as follows:<br/><br/>
Username : Your email address<br/>
Password : {{account_details}}<br/><br/>
You can reset your password here:
{% url 'hosting:reset_password' %}
{% endif %}
{% endblocktrans %}
{% endblock %}

View File

@ -6,5 +6,14 @@
You can also copy and paste the following link into the address bar of your browser
to activate your Data Center Light account.
{{base_url}}{{activation_link}}
{% if account_details %}
Your account details are as follows:
Username : Your email address
Password : {{account_details}}
You can reset your password here:
{% url 'hosting:reset_password' %}
{% endif %}
{% endblocktrans %}
{% endblock %}

View File

@ -598,7 +598,8 @@ class OrderConfirmationView(DetailView):
custom_user = CustomUser.register(
user.get('name'), password,
user.get('email'),
app='dcl', base_url=None, send_email=False
app='dcl', base_url=None, send_email=True,
account_details=password
)
logger.debug("Created user {}.".format(user.get('email')))
stripe_customer = StripeCustomer.objects. \

View File

@ -82,7 +82,7 @@ class CustomUser(AbstractBaseUser, PermissionsMixin):
@classmethod
def register(cls, name, password, email, app='digital_glarus',
base_url=None, send_email=True):
base_url=None, send_email=True, account_details=None):
user = cls.objects.filter(email=email).first()
if not user:
user = cls.objects.create_user(name=name, email=email,
@ -112,6 +112,9 @@ class CustomUser(AbstractBaseUser, PermissionsMixin):
'template_name': 'user_activation',
'template_path': 'datacenterlight/emails/'
}
if account_details:
email_data['context'][
'account_details'] = account_details
email = BaseEmail(**email_data)
email.send()
return user
@ -177,7 +180,8 @@ class StripeCustomer(models.Model):
return "%s - %s" % (self.stripe_id, self.user.email)
@classmethod
def create_stripe_api_customer(cls, email=None, token=None, customer_name=None):
def create_stripe_api_customer(cls, email=None, token=None,
customer_name=None):
"""
This method creates a Stripe API customer with the given
email, token and customer_name. This is different from
@ -194,7 +198,6 @@ class StripeCustomer(models.Model):
else:
return None
@classmethod
def get_or_create(cls, email=None, token=None):
"""