From: Yasin Date: Thu, 25 Jul 2013 14:16:18 +0000 (+0200) Subject: OneLab Contact Us form created. Email to be tested from dev machine. X-Git-Tag: myslice-0.2-1~91 X-Git-Url: http://git.onelab.eu/?p=myslice.git;a=commitdiff_plain;h=2f4e3e456c0f10f3316c9eafb09cc95bbd4a3043 OneLab Contact Us form created. Email to be tested from dev machine. --- diff --git a/portal/forms.py b/portal/forms.py index 513b9526..f28a9edf 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,12 @@ 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) 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/urls.py b/portal/urls.py index 53d4b7c2..1cb551e4 100644 --- a/portal/urls.py +++ b/portal/urls.py @@ -42,6 +42,7 @@ 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, name='slice_request'), # Slice confirmation diff --git a/portal/views.py b/portal/views.py index 597f319d..c3466d4a 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" @@ -153,8 +155,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'] @@ -420,3 +424,33 @@ 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'] + cc_myself = form.cleaned_data['cc_myself'] + + recipients = ['yasin.upmc@gmail.com'] + if cc_myself: + recipients.append(sender) + + from django.core.mail import send_mail + send_mail(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, + }) +