From: Jordan Augé Date: Mon, 29 Jul 2013 03:42:55 +0000 (+0200) Subject: Merge branch 'jordan' of ssh://git.onelab.eu/git/myslice into jordan X-Git-Tag: myslice-0.2-1~86^2~1 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=c0c7175e6883ad9bc746692e7c71202e64ec2351;hp=4e348dd653e2f7124550f153a30744293eab3b2f;p=myslice.git Merge branch 'jordan' of ssh://git.onelab.eu/git/myslice into jordan --- diff --git a/portal/forms.py b/portal/forms.py index 513b9526..ab563d9d 100644 --- a/portal/forms.py +++ b/portal/forms.py @@ -5,6 +5,7 @@ # # Authors: # Jordan Augé +# Mohammed-Yasin Rahman # Copyright 2013, UPMC Sorbonne Universités / LIP6 # # This program is free software; you can redistribute it and/or modify it under @@ -49,6 +50,11 @@ class UserRegisterForm(forms.Form): # Not ModelForm max_length=30, label=_("Last name"), error_messages={'invalid': _("This value may contain only letters, numbers and @/./+/-/_ characters.")}) + affiliation = forms.RegexField(regex=r'^[\w.@+-]+$', + max_length=30, + label=_("Affiliation"), + error_messages={'invalid': _("This value may contain only letters, numbers and @/./+/-/_ characters.")}) + email = forms.EmailField(label=_("E-mail")) password1 = forms.CharField(widget=forms.PasswordInput, label=_("Password")) @@ -106,3 +112,21 @@ class SliceRequestForm(forms.ModelForm): # DEPRECATED #class RegisterUserStep2Form(forms.ModelForm): # DEPRECATED # class Meta: # DEPRECATED # model = PendingUser + +class ContactForm(forms.Form): + first_name = forms.CharField() + last_name = forms.CharField() + affiliation = forms.CharField() + subject = forms.CharField(max_length=100) + 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/models.py b/portal/models.py index da0e0863..0dcbc6d4 100644 --- a/portal/models.py +++ b/portal/models.py @@ -210,6 +210,7 @@ class PendingUser(models.Model): # simplify form creation in forms.py first_name = models.TextField() last_name = models.TextField() + affiliation = models.TextField() email = models.EmailField() #validators=[validate_email]) password = models.TextField() keypair = models.TextField() diff --git a/portal/templates/contact.html b/portal/templates/contact.html new file mode 100644 index 00000000..f9e2e4ef --- /dev/null +++ b/portal/templates/contact.html @@ -0,0 +1,22 @@ +{% extends "layout-unfold1.html" %} +{% load i18n %} + +{% block head %} +{{ wizard.form.media }} +{% endblock %} + +{% block unfold1_main %} + + +
+

Onelab Support

+

If you have already registered then send an e-mail or visit us

+
+ +
{% csrf_token %} +{{ form.as_p }} + +
+ +{% endblock %} + diff --git a/portal/templates/contact_sent.html b/portal/templates/contact_sent.html new file mode 100644 index 00000000..ca12d5f5 --- /dev/null +++ b/portal/templates/contact_sent.html @@ -0,0 +1,9 @@ +{% extends "layout-unfold1.html" %} + +{% block unfold1_main %} + +

Query Received !

+ +We will study your problem and get back to you as soon as possible. +{% endblock %} + 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 53d4b7c2..64333b67 100644 --- a/portal/urls.py +++ b/portal/urls.py @@ -42,7 +42,9 @@ urlpatterns = patterns('', # User validation url(r'^user/validate/?$', UserValidateView.as_view(), name='user_validate'), 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 f27b178c..4f1ea08d 100644 --- a/portal/views.py +++ b/portal/views.py @@ -5,6 +5,7 @@ # # Authors: # Jordan Augé +# Mohammed Yasin Rahman # Copyright 2013, UPMC Sorbonne Universités / LIP6 # # This program is free software; you can redistribute it and/or modify it under @@ -28,12 +29,13 @@ from django.views.generic.base import TemplateView from django.shortcuts import render from plugins.lists.simplelist import SimpleList from portal import signals -from portal.forms import UserRegisterForm, SliceRequestForm +from portal.forms import UserRegisterForm, SliceRequestForm, ContactForm from portal.util import RegistrationView, ActivationView from portal.models import PendingUser, PendingSlice from manifold.core.query import Query from unfold.page import Page from myslice.viewutils import topmenu_items, the_user +from django.http import HttpResponseRedirect class DashboardView(TemplateView): template_name = "dashboard.html" @@ -151,8 +153,10 @@ class UserRegisterView(RegistrationView): """ first_name = cleaned_data['first_name'] last_name = cleaned_data['last_name'] + affiliation= cleaned_data['affiliation'] email = cleaned_data['email'] password = cleaned_data['password1'] + #password2 = cleaned_data['password2'] keypair = cleaned_data['keypair'] @@ -418,3 +422,60 @@ class UserValidateView(ActivationView): # DEPRECATED # p << wizard.render(request) # in portal page if possible # DEPRECATED # # DEPRECATED # return p.render() + + +# view for contact form +def contact(request): + if request.method == 'POST': # If the form has been submitted... + form = ContactForm(request.POST) # A form bound to the POST data + if form.is_valid(): # All validation rules pass + # Process the data in form.cleaned_data + first_name = form.cleaned_data['first_name'] + last_name = form.cleaned_data['last_name'] + affiliation = form.cleaned_data['affiliation'] + subject = form.cleaned_data['subject'] + message = form.cleaned_data['message'] + 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(email) + + from django.core.mail import send_mail + 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 + + return render(request, 'contact.html', { + '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, + }) + diff --git a/views/templates/view-login.html b/views/templates/view-login.html index f958c601..d68f8cff 100644 --- a/views/templates/view-login.html +++ b/views/templates/view-login.html @@ -23,7 +23,7 @@ Currently hard wired users are:

Welcome to the OneLab portal !

-

New to OneLab? Please register or learn more about the project.

+

New to OneLab? Please register or learn more about the project.