[cig-commits] r12569 - in cs/portal/trunk/northridge/SeismoWebPortal: . templates/SeismoWebPortal

leif at geodynamics.org leif at geodynamics.org
Wed Aug 6 17:09:24 PDT 2008


Author: leif
Date: 2008-08-06 17:09:24 -0700 (Wed, 06 Aug 2008)
New Revision: 12569

Modified:
   cs/portal/trunk/northridge/SeismoWebPortal/forms.py
   cs/portal/trunk/northridge/SeismoWebPortal/management.py
   cs/portal/trunk/northridge/SeismoWebPortal/models.py
   cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/cpu_time_request_form.html
   cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/publication_info.html
   cs/portal/trunk/northridge/SeismoWebPortal/views.py
Log:
Added pub. fields to CPU time request form.  Changed wording of some
items.


Modified: cs/portal/trunk/northridge/SeismoWebPortal/forms.py
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/forms.py	2008-08-07 00:09:06 UTC (rev 12568)
+++ cs/portal/trunk/northridge/SeismoWebPortal/forms.py	2008-08-07 00:09:24 UTC (rev 12569)
@@ -248,11 +248,57 @@
 
 
 pubTypeChoices = (
-    (0, 'Background information'),
+    (0, 'Background papers in support of my allocation request'),
     (1, 'Publication resulting from CIG software/resources'),
     )
 
 
+def addPubFields(fields):
+    fields.extend([
+        forms.RadioSelectField('pubType', choices=pubTypeChoices),
+        forms.TextField('authors', maxlength=100),
+        forms.TextField('title', maxlength=100),
+        forms.TextField('journal', maxlength=100),
+        forms.TextField('biblio', maxlength=100),
+        forms.FileUploadField(field_name='paper1'),
+        forms.FileUploadField(field_name='paper2'),
+        ])
+    return
+
+
+def pubDefaults():
+    return {'pubType': 0}
+
+
+def extractPubInfo(extraInfo, new_data):
+    pubType = new_data['pubType']
+    for value, displayName in pubTypeChoices:
+        if str(value) == pubType:
+            pubType = displayName
+            break
+    
+    extraInfo.update(dict(
+        pubType          = pubType,
+        authors          = new_data['authors'],
+        title            = new_data['title'],
+        journal          = new_data['journal'],
+        biblio           = new_data['biblio'],
+        ))
+    
+    attachments = []
+    for key in ['paper1', 'paper2']:
+        attachment = new_data.get(key)
+        if attachment:
+            attachments.append({
+                'filename':     attachment['filename'],
+                'content-type': attachment['content-type'],
+                'content':      attachment['content'],
+                })
+    extraInfo['attachments'] = attachments
+
+    return
+
+
 class RegistrationManipulator(forms.Manipulator):
     
     def __init__(self):
@@ -292,15 +338,8 @@
             # project information
             forms.LargeTextField('projectAbstract', is_required=True),
             forms.IntegerField('requestedSUs', is_required=True),
-            # publication information
-            forms.RadioSelectField('pubType', choices=pubTypeChoices, is_required=True),
-            forms.TextField('authors', maxlength=100, is_required=True),
-            forms.TextField('title', maxlength=100, is_required=True),
-            forms.TextField('journal', maxlength=100, is_required=True),
-            forms.TextField('biblio', maxlength=100, is_required=True),
-            forms.FileUploadField(field_name='paper1'),
-            forms.FileUploadField(field_name='paper2'),
             ])
+        addPubFields(self.fields)
         
     def save(self, new_data, inviteCode):
 
@@ -346,37 +385,17 @@
         if user is not None:
             login(self.request, user)
 
-        pubType = new_data['pubType']
-        for value, displayName in pubTypeChoices:
-            if str(value) == pubType:
-                pubType = displayName
-                break
         extraInfo = dict(
             # project information
             projectAbstract  = new_data['projectAbstract'],
             requestedSUs     = new_data['requestedSUs'],
-            # publication information
-            pubType          = pubType,
-            authors          = new_data['authors'],
-            title            = new_data['title'],
-            journal          = new_data['journal'],
-            biblio           = new_data['biblio'],
             )
-        attachments = []
-        for key in ['paper1', 'paper2']:
-            attachment = new_data.get(key)
-            if attachment:
-                attachments.append({
-                    'filename':     attachment['filename'],
-                    'content-type': attachment['content-type'],
-                    'content':      attachment['content'],
-                    })
-        extraInfo['attachments'] = attachments
+        extractPubInfo(extraInfo, new_data)
 
         return user, extraInfo, {}
 
     def flatten_data(self):
-        return {'pubType': 0}
+        return pubDefaults()
     
     def usernameValidatorList(self):
         validator_list = super(RegistrationAddManipulator, self).usernameValidatorList()

Modified: cs/portal/trunk/northridge/SeismoWebPortal/management.py
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/management.py	2008-08-07 00:09:06 UTC (rev 12568)
+++ cs/portal/trunk/northridge/SeismoWebPortal/management.py	2008-08-07 00:09:24 UTC (rev 12569)
@@ -289,7 +289,7 @@
                 user         = user,
                 institution  = "CIG",
                 phone        = "(626) 395-1699",
-                role         = -1,
+                role         = 5, # other
                 approved     = True,
                 )
     return

Modified: cs/portal/trunk/northridge/SeismoWebPortal/models.py
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/models.py	2008-08-07 00:09:06 UTC (rev 12568)
+++ cs/portal/trunk/northridge/SeismoWebPortal/models.py	2008-08-07 00:09:24 UTC (rev 12569)
@@ -924,12 +924,11 @@
 
 
 ROLE_CHOICES = (
-    # (-1, 'staff'),
-    # (0, 'unknown'),
     (1, 'faculty'),
     (2, 'researcher'),
     (3, 'graduate student'),
     (4, 'post-doc'),
+    (5, 'other'),
     )
 
 class UserInfo(Model):

Modified: cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/cpu_time_request_form.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/cpu_time_request_form.html	2008-08-07 00:09:06 UTC (rev 12568)
+++ cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/cpu_time_request_form.html	2008-08-07 00:09:24 UTC (rev 12569)
@@ -11,7 +11,7 @@
 <p><span class=error>Please correct the following error{{ form.error_dict|pluralize }}.</span>
 {% endif %}
 
-<form method="post" action="{{action}}">
+<form method="post" action="{{action}}" enctype="multipart/form-data">
 
     <div class=tab30ex>
 
@@ -35,6 +35,8 @@
         {% if form.plans.errors %}<span class=error>{{ form.plans.errors|join:", " }}</span>{% endif %}
     </div>
 
+    {% include "SeismoWebPortal/publication_info.html" %}
+
     <div><input class=submit type="submit" value="Send Request"/></div>
 
     </div> <!-- tab30ex -->

Modified: cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/publication_info.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/publication_info.html	2008-08-07 00:09:06 UTC (rev 12568)
+++ cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/publication_info.html	2008-08-07 00:09:24 UTC (rev 12569)
@@ -1,7 +1,7 @@
 
     <p><i>We need to know of any published, in-press, or planned
     papers you are generating that use the results of your work with
-    CIG's TeraGrid allocation.</i></p>
+    CIG Software or its TeraGrid allocation.</i></p>
 
     <div class="radio">
         {{ form.pubType }}
@@ -31,7 +31,7 @@
         {% if form.biblio.errors %}<span class=error>{{ form.biblio.errors|join:", " }}</span>{% endif %}
     </div>
 
-    <p><i>Use the fields below to upload papers resulting from CIG software/resources.</i></p>
+    <p><i>Use the fields below to upload papers (if available) resulting from CIG software/resources.</i></p>
 
     <div>
         <label for="id_paper1" class=before>paper #1</label>

Modified: cs/portal/trunk/northridge/SeismoWebPortal/views.py
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/views.py	2008-08-07 00:09:06 UTC (rev 12568)
+++ cs/portal/trunk/northridge/SeismoWebPortal/views.py	2008-08-07 00:09:24 UTC (rev 12569)
@@ -779,19 +779,28 @@
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 def cpuTime(request, pathname):
+    from forms import addPubFields, pubDefaults, extractPubInfo
     root = rootURL(request, pathname)
-    new_data, errors = {}, {}
+    new_data, errors = pubDefaults(), {}
     form = forms.Manipulator()
     form.fields.extend([
         forms.LargeTextField('results', is_required=True),
         forms.IntegerField('requestedSUs', is_required=True),
         forms.LargeTextField('plans', is_required=True),
         ])
+    addPubFields(form.fields)
     if request.POST:
         new_data = request.POST.copy()
+        new_data.update(request.FILES)
         errors = form.get_validation_errors(new_data)
         if not errors:
-            sendCPUTimeRequest(request, new_data)
+            extraInfo = dict(
+                results      = new_data['results'],
+                requestedSUs = new_data['requestedSUs'],
+                plans        = new_data['plans'],
+                )
+            extractPubInfo(extraInfo, new_data)
+            sendCPUTimeRequest(request, extraInfo)
             request.user.message_set.create(message="Your request has been sent.")
             return HttpResponseRedirect("%s/" % root)
     return render_to_response("SeismoWebPortal/cpu_time_request_form.html", dict(
@@ -801,26 +810,32 @@
         ), context_instance=RequestContext(request))
 
 
-def sendCPUTimeRequest(request, new_data):
+def sendCPUTimeRequest(request, extraInfo):
     from django.core.mail import mail_managers
 
     username = request.user.username
 
     subject = 'SU request from %s' % username
-    message = ["The user %s has requested %s SUs." % (username, new_data['requestedSUs']),
+    message = ["The user %s has requested %s SUs." % (username, extraInfo['requestedSUs']),
                ""]
     message.extend([
         "results",
         "-------",
-        new_data['results'],
+        extraInfo['results'],
         "",
         "plans",
         "-----",
-        new_data['plans'],
+        extraInfo['plans'],
+        "",
+        "pubType: " + extraInfo['pubType'],
+        "authors: " + extraInfo['authors'],
+        "title: " + extraInfo['title'],
+        "journal: " + extraInfo['journal'],
+        "biblio: " + extraInfo['biblio'],
         ])
     message = "\n".join(message)
     
-    mail_managers(subject, message, fail_silently=True)
+    mailManagers(subject, message, extraInfo['attachments'], fail_silently=True)
     
     return
 



More information about the cig-commits mailing list