Fixed PEP8 violations

This commit is contained in:
siarheipuhach 2017-06-29 19:23:25 +03:00
parent e681b0d8c2
commit a9c9f74aed
5 changed files with 63 additions and 63 deletions

View file

@ -1,6 +1,7 @@
from django.conf.urls import url
from .views import IndexView, BetaProgramView, LandingProgramView, BetaAccessView, PricingView, SuccessView, PaymentOrderView, OrderConfirmationView
from .views import IndexView, BetaProgramView, LandingProgramView, \
BetaAccessView, PricingView, SuccessView, PaymentOrderView, OrderConfirmationView
urlpatterns = [

View file

@ -13,12 +13,11 @@ from django.core.exceptions import ValidationError
from django.views.decorators.cache import cache_control
from django.conf import settings
from utils.forms import BillingAddressForm, UserBillingAddressForm
from membership.models import StripeCustomer
from hosting.models import HostingOrder, HostingBill
from hosting.models import HostingOrder
from utils.stripe_utils import StripeUtils
from datetime import datetime
from membership.models import CustomUser, StripeCustomer
from oca.pool import WrongIdError
from opennebula_api.models import OpenNebulaManager
from opennebula_api.serializers import VirtualMachineTemplateSerializer, VirtualMachineSerializer
@ -38,6 +37,7 @@ class SuccessView(TemplateView):
del request.session['user']
return render(request, self.template_name)
class PricingView(TemplateView):
template_name = "datacenterlight/pricing.html"
@ -93,7 +93,6 @@ class BetaAccessView(FormView):
success_message = "Thank you, we will contact you as soon as possible"
def form_valid(self, form):
context = {
'base_url': "{0}://{1}".format(self.request.scheme, self.request.get_host())
}
@ -332,7 +331,7 @@ class PaymentOrderView(FormView):
final_price = specs.get('price')
token = form.cleaned_data.get('token')
try:
custom_user = CustomUser.objects.get(email=user.get('email'))
CustomUser.objects.get(email=user.get('email'))
except CustomUser.DoesNotExist:
password = CustomUser.get_random_password()
# Register the user, and do not send emails
@ -342,7 +341,6 @@ class PaymentOrderView(FormView):
app='dcl',
base_url=None, send_email=False)
# Get or create stripe customer
customer = StripeCustomer.get_or_create(email=user.get('email'),
token=token)
@ -392,8 +390,9 @@ class PaymentOrderView(FormView):
)
# Create a Hosting Bill
bill = HostingBill.create(
customer=customer, billing_address=billing_address)
# not used
# bill = HostingBill.create(
# customer=customer, billing_address=billing_address)
# Create Billing Address for User if he does not have one
if not customer.user.billing_addresses.count():
@ -438,10 +437,12 @@ class PaymentOrderView(FormView):
else:
return self.form_invalid(form)
class OrderConfirmationView(DetailView):
template_name = "datacenterlight/order_detail.html"
context_object_name = "order"
model = HostingOrder
def get_context_data(self, **kwargs):
# Get context
context = super(DetailView, self).get_context_data(**kwargs)

View file

@ -1,3 +1,4 @@
from oca.pool import WrongNameError, WrongIdError
from django.shortcuts import render
from django.http import Http404
from django.core.urlresolvers import reverse_lazy, reverse
@ -15,9 +16,7 @@ from guardian.mixins import PermissionRequiredMixin
from stored_messages.settings import stored_messages_settings
from stored_messages.models import Message
from stored_messages.api import mark_read
from django.utils.safestring import mark_safe>>>>>>> master
246
from django.utils.safestring import mark_safe
from membership.models import CustomUser, StripeCustomer
from utils.stripe_utils import StripeUtils
@ -34,8 +33,6 @@ from opennebula_api.serializers import VirtualMachineSerializer,\
from django.utils.translation import ugettext_lazy as _
from oca.pool import WrongNameError, WrongIdError
CONNECTION_ERROR = "Your VMs cannot be displayed at the moment due to a backend \
connection error. please try again in a few minutes."
@ -140,7 +137,6 @@ class HostingPricingView(ProcessVMSelectionMixin, View):
'templates': templates,
'configuration_options': configuration_options,
}
return context
@ -171,7 +167,6 @@ class IndexView(View):
return context
def get(self, request, *args, **kwargs):
context = self.get_context_data()
return render(request, self.template_name, context)
@ -213,7 +208,9 @@ class SignupValidateView(TemplateView):
home_url = '<a href="' + reverse('datacenterlight:index') + '">Data Center Light</a>'
message = '{signup_success_message} {lurl}</a> \
<br />{go_back} {hurl}.'.format(
signup_success_message = _('Thank you for signing up. We have sent an email to you. Please follow the instructions in it to activate your account. Once activated, you can login using'),
signup_success_message=_(
'Thank you for signing up. We have sent an email to you. '
'Please follow the instructions in it to activate your account. Once activated, you can login using'),
go_back=_('Go back to'),
lurl=login_url,
hurl=home_url

View file

@ -85,7 +85,8 @@ class CustomUser(AbstractBaseUser, PermissionsMixin):
dg.send_mail(to=user.email)
elif app == 'dcl':
dcl_text = settings.DCL_TEXT
dcl_from_address = settings.DCL_SUPPORT_FROM_ADDRESS
# not used
# dcl_from_address = settings.DCL_SUPPORT_FROM_ADDRESS
user.is_active = False
if send_email is True:
@ -94,7 +95,8 @@ class CustomUser(AbstractBaseUser, PermissionsMixin):
'from_address': settings.DCL_SUPPORT_FROM_ADDRESS,
'to': user.email,
'context': {'base_url': base_url,
'activation_link' : reverse('hosting:validate', kwargs={'validate_slug': user.validation_slug}),
'activation_link': reverse('hosting:validate',
kwargs={'validate_slug': user.validation_slug}),
'dcl_text': dcl_text
},
'template_name': 'user_activation',

View file

@ -208,7 +208,7 @@ class OpenNebulaManager():
except:
raise ConnectionRefusedError
def create_vm(self, template_id, specs, ssh_key=None):
def create_vm(self, template_id, specs, ssh_key=None, vm_name=None):
template = self.get_template(template_id)
vm_specs_formatter = """<TEMPLATE>
@ -256,7 +256,6 @@ class OpenNebulaManager():
image=image,
image_uname=image_uname)
vm_specs += "<CONTEXT>"
if ssh_key:
vm_specs += "<SSH_PUBLIC_KEY>{ssh}</SSH_PUBLIC_KEY>".format(ssh=ssh_key)