Commit 3533fd26 authored by alexAubin's avatar alexAubin

Add missing custom form for VPS subscription request

parent 65f8162b
# -*- coding: utf-8 -*-
from django import forms
from coin.offers.forms import OfferSubscriptionRequestStep2Form
from .models import VPSOperatingSystem, VPSSubscriptionRequest, PublicSSHKeyValidator
class VPSSubscriptionRequestStep2Form(OfferSubscriptionRequestStep2Form):
offer_type = "VPS"
subscriptionrequest_class = VPSSubscriptionRequest
operating_system = forms.ModelChoiceField(queryset=VPSOperatingSystem.objects.all(), label="Système d'exploitation", required=True)
ssh_key = forms.CharField(label="Clef SSH", max_length=1024, widget=forms.Textarea(attrs={'style': 'height: 10em;'}), required=True, validators=[PublicSSHKeyValidator])
def __init__(self, *args, **kwargs):
super(VPSSubscriptionRequestStep2Form, self).__init__(*args, **kwargs)
# Put the comment + agree tos checkbox at the end of the form
member_comments = self.fields.pop("member_comments")
agree_tos = self.fields.pop("agree_tos")
self.fields["member_comments"] = member_comments
self.fields["agree_tos"] = agree_tos
def create_offersubscriptionrequest(self, request):
subscriptionrequest = super(VPSSubscriptionRequestStep2Form, self).create_offersubscriptionrequest(request)
subscriptionrequest.operating_system = self.cleaned_data["operating_system"]
subscriptionrequest.ssh_key = self.cleaned_data["ssh_key"]
return subscriptionrequest
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment