--- /dev/null
+from django.shortcuts import render
+
+from django.views.generic import View
+
+from myslice.viewutils import topmenu_items, the_user
+
+from portal.forms import ContactForm
+
+# view for contact form
+class ContactView (View):
+ def dispatch(self, 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 = authority_get_pi_emails(authority_hrn)
+ recipients = ['yasin.upmc@gmail.com', 'thierry.parmentelat@inria.fr', ]
+ 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,
+ 'topmenu_items': topmenu_items('Contact Us', request),
+ 'username': the_user (request)
+
+ })
+
from django.conf.urls import patterns, include, url
from portal.views import PresViewView, ValidatePendingView
-from portal.views import account_process, contact, slice_request, register_4m_f4f
+from portal.views import account_process, slice_request, register_4m_f4f
from portal.platformsview import PlatformsView
from portal.platformview import PlatformView
from portal.dashboardview import DashboardView
from portal.accountview import AccountView
+from portal.contactview import ContactView
# DEPRECATED #named_register_forms = (
url(r'^platform/(?P<platformname>[\w\.]+)/?$', PlatformView.as_view(), name='platform'),
url(r'^account/account_process/?$', account_process),
url(r'^register/?$', register_4m_f4f),
- url(r'^contact/?$', contact),
+ url(r'^contact/?$', ContactView.as_view(), name='contact'),
# Slice request
url(r'^slice_request/?$', slice_request),
# Validate pending requests
import os.path, re
import json
-#from django.views.generic import View
from django.views.generic.base import TemplateView
from django.shortcuts import render
from django.template.loader import render_to_string
from portal.event import Event
from portal import signals
-from portal.forms import SliceRequestForm, ContactForm
+from portal.forms import SliceRequestForm
from portal.util import RegistrationView, ActivationView
from portal.models import PendingUser, PendingSlice
from portal.actions import authority_get_pi_emails, get_request_by_authority, manifold_add_user, manifold_update_user
})
-# 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 = authority_get_pi_emails(authority_hrn)
- 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,
- 'topmenu_items': topmenu_items('Contact Us', request),
- 'username': the_user (request)
-
- })
-
@login_required
def slice_request(request):
errors = []