From e33ccb0d215722ca404f3fde37f7a9c83e41ab0b Mon Sep 17 00:00:00 2001 From: Yasin Date: Thu, 25 Jul 2013 17:50:23 +0200 Subject: [PATCH] Slice Request page added /portal/slice_request --- portal/forms.py | 9 ++++++++ portal/templates/slice_request.html | 6 ++--- portal/templates/slicereq_recvd.html | 9 ++++++++ portal/urls.py | 1 + portal/views.py | 33 +++++++++++++++++++++++++--- 5 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 portal/templates/slicereq_recvd.html diff --git a/portal/forms.py b/portal/forms.py index f28a9edf..ab563d9d 100644 --- a/portal/forms.py +++ b/portal/forms.py @@ -121,3 +121,12 @@ class ContactForm(forms.Form): message = forms.CharField(widget=forms.Textarea) email = forms.EmailField() cc_myself = forms.BooleanField(required=False) + +class SliceRequestForm(forms.Form): + slice_name = forms.CharField() + number_of_nodes = forms.DecimalField() + type_of_nodes = forms.CharField() + purpose = forms.CharField(widget=forms.Textarea) + email = forms.EmailField() + cc_myself = forms.BooleanField(required=False) + diff --git a/portal/templates/slice_request.html b/portal/templates/slice_request.html index 01f48d0e..e60e8810 100644 --- a/portal/templates/slice_request.html +++ b/portal/templates/slice_request.html @@ -3,16 +3,14 @@ {% block head %} {{ wizard.form.media }} - {% endblock %} {% block unfold1_main %} -

Slice request

+

Request a Slice

-{% if envoi %}Votre message a bien été envoyé !{% endif %} -
{% csrf_token %} +{% csrf_token %} {{ form.as_p }}
diff --git a/portal/templates/slicereq_recvd.html b/portal/templates/slicereq_recvd.html new file mode 100644 index 00000000..7ea26ed8 --- /dev/null +++ b/portal/templates/slicereq_recvd.html @@ -0,0 +1,9 @@ +{% extends "layout-unfold1.html" %} + +{% block unfold1_main %} + +

Slice request Received !

+ +We will process your request and get back to you as soon as possible. +{% endblock %} + diff --git a/portal/urls.py b/portal/urls.py index 1cb551e4..64333b67 100644 --- a/portal/urls.py +++ b/portal/urls.py @@ -44,6 +44,7 @@ urlpatterns = patterns('', url(r'^dashboard/?$', DashboardView.as_view(), name='dashboard'), url(r'^contact/?$', views.contact), # Slice request + url(r'^slice_request/?$', views.slice_request), #url(r'^slice/request/?$', views.slice_request, name='slice_request'), # Slice confirmation #url(r'^slice/validate/?$', views.slice_validate, name='slice_validate'), diff --git a/portal/views.py b/portal/views.py index efa58d4f..74c56eaf 100644 --- a/portal/views.py +++ b/portal/views.py @@ -435,15 +435,15 @@ def contact(request): affiliation = form.cleaned_data['affiliation'] subject = form.cleaned_data['subject'] message = form.cleaned_data['message'] - email = form.cleaned_data['email'] + email = form.cleaned_data['email'] # email of the sender cc_myself = form.cleaned_data['cc_myself'] recipients = ['yasin.upmc@gmail.com'] if cc_myself: - recipients.append(sender) + recipients.append(email) from django.core.mail import send_mail - send_mail(subject, message, email, recipients) + send_mail("Onelab user submitted a query ", [first_name,last_name,affiliation,subject,message], email, recipients) return render(request,'contact_sent.html') # Redirect after POST else: form = ContactForm() # An unbound form @@ -452,3 +452,30 @@ def contact(request): 'form': form, }) + +def slice_request(request): + if request.method == 'POST': # If the form has been submitted... + form = SliceRequestForm(request.POST) # A form bound to the POST data + if form.is_valid(): # All validation rules pass + # Process the data in form.cleaned_data + slice_name = form.cleaned_data['slice_name'] + number_of_nodes = form.cleaned_data['number_of_nodes'] + type_of_nodes = form.cleaned_data['type_of_nodes'] + purpose = form.cleaned_data['purpose'] + email = form.cleaned_data['email'] # email of the sender + cc_myself = form.cleaned_data['cc_myself'] + + recipients = ['yasin.upmc@gmail.com','jordan.auge@lip6.fr'] + if cc_myself: + recipients.append(email) + + from django.core.mail import send_mail + send_mail("Onelab New Slice request form submitted", [slice_name,number_of_nodes,type_of_nodes,purpose], email, recipients) + return render(request,'slicereq_recvd.html') # Redirect after POST + else: + form = SliceRequestForm() # An unbound form + + return render(request, 'slice_request.html', { + 'form': form, + }) + -- 2.43.0