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

leif at geodynamics.org leif at geodynamics.org
Tue Jul 15 19:23:19 PDT 2008


Author: leif
Date: 2008-07-15 19:23:19 -0700 (Tue, 15 Jul 2008)
New Revision: 12419

Modified:
   cs/portal/trunk/northridge/SeismoWebPortal/forms.py
   cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/home.html
   cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/register.html
   cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/run_detail.html
   cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/run_list.html
   cs/portal/trunk/northridge/SeismoWebPortal/urls.py
   cs/portal/trunk/northridge/SeismoWebPortal/views.py
Log:
Resurrected the "invitation code" concept.  This time, the invitation
code is a part of the URL, as suggested many moons ago by Walter.
Also, there is now ample UI feedback aimed at "uninvited" users.


Modified: cs/portal/trunk/northridge/SeismoWebPortal/forms.py
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/forms.py	2008-07-16 01:03:40 UTC (rev 12418)
+++ cs/portal/trunk/northridge/SeismoWebPortal/forms.py	2008-07-16 02:23:19 UTC (rev 12419)
@@ -256,16 +256,6 @@
     return
 
 
-def isValidInvitationCode(field_data, all_data):
-    try:
-        invite = models.Invite.objects.get(code = field_data)
-    except models.Invite.DoesNotExist:
-        raise validators.ValidationError, "Invalid invitation code."
-    if invite.hasExpired():
-        raise validators.ValidationError, "This invitation code has expired."
-    return
-
-
 class RegistrationManipulator(forms.Manipulator):
     
     def __init__(self):
@@ -296,19 +286,21 @@
             forms.TextField('username',     maxlength=30,  is_required=True, validator_list=self.usernameValidatorList()),
             forms.PasswordField('password1', maxlength=128, is_required=True),
             forms.PasswordField('password2', maxlength=128, is_required=True, validator_list=[passwordsMatch]),
-            
-            forms.TextField('invite', maxlength=128, validator_list=[isValidInvitationCode]),
             ])
         
-    def save(self, new_data):
+    def save(self, new_data, inviteCode):
 
         # Check the invitation code, if given.
         approved = False
         invite = None
-        inviteCode = new_data['invite']
         if inviteCode:
-            invite = models.Invite.objects.get(code = inviteCode)
-            approved = True
+            try:
+                invite = models.Invite.objects.get(code__iexact = inviteCode)
+            except models.Invite.DoesNotExist:
+                pass
+            else:
+                if not invite.hasExpired():
+                    approved = True
         
         user, created = User.objects.get_or_create(
             username = new_data['username'],

Modified: cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/home.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/home.html	2008-07-16 01:03:40 UTC (rev 12418)
+++ cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/home.html	2008-07-16 02:23:19 UTC (rev 12419)
@@ -1,6 +1,8 @@
 
 <h2><img src="{{root}}/images/home.gif" width=32 height=32> Home</h2>
 
+{% if user.userinfo.approved %}
+
 <h3>Quick Start</h3>
 
 <p>To run Specfem 3D Globe or Mineos, proceed as follows:</p>
@@ -37,6 +39,21 @@
 site, creating your own custom station lists, parameter sets, meshes,
 etc.</p>
 
+{% else %}
+
+<h3>Howdy, Stranger!</h3>
+
+<p>Welcome! This web portal gives users access to powerful
+supercomputing clusters. As such, you will not be able to run the
+codes until an administrator reviews your registration information and
+approves it.</p>
+
+<p>In the meantime, feel free to explore the site. Be sure to check
+out the examples on the &ldquo;Runs&rdquo; page. These examples
+demonstrate the capabilities offered by the site.</p>
+
+{% endif %}
+
 <h3>Tips</h3>
 
 <p><img src="{{root}}/images/kml.icon.gif"> If you have <a

Modified: cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/register.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/register.html	2008-07-16 01:03:40 UTC (rev 12418)
+++ cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/register.html	2008-07-16 02:23:19 UTC (rev 12419)
@@ -46,19 +46,6 @@
     </fieldset>
 
 
-    <fieldset><legend>invitation</legend>
-
-    <p>If you were given an invitation code, enter it below.
-       A valid invitation enables you to start running simulations immediately!
-
-    <div>
-        <label for="id_invite" class=before>invitation code</label>
-        {{ form.invite }}
-        {% if form.invite.errors %}<span class=error>{{ form.invite.errors|join:", " }}</span>{% endif %}
-    </div>
-
-    </fieldset>
-
     <div><input class=submit type="submit" value="Register"/></div>
 
     </div> <!-- tab30ex -->

Modified: cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/run_detail.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/run_detail.html	2008-07-16 01:03:40 UTC (rev 12418)
+++ cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/run_detail.html	2008-07-16 02:23:19 UTC (rev 12419)
@@ -2,13 +2,18 @@
 <h2><img src="{{root}}/images/rocket.gif" width=32 height=32> {{ object }}</h2>
 
 {% ifequal object.status 'draft' %}
+{% if user.userinfo.approved %}
 {% if object.breaksTheBank %}
 <p class="message">You do not have enough SUs to perform this run. Please <a href="mailto:portal at geodynamics.org">contact us</a> to request more SUs.</p>
 {% else %}
 <p class="message">This run has not been started. Verify that the parameters below are correct.  Then click the "Start" button at the bottom of this page.</p>
 {% endif %}
+{% else %}
+<p class="message">You will not be able to start this run until you are approved by a site administrator.</p>
+{% endif %}
 {% endifequal %}
 
+
 <dl class=parameters>
     <dt>status</dt>
     <dd>
@@ -82,6 +87,7 @@
     </dd>
 
     {% if object.isDraft %}
+    {% if user.userinfo.approved %}
     <dt>estimated cost</dt>
     <dd>
         <table class="calc" cellspacing=20>
@@ -102,6 +108,7 @@
             </td></tr>
         </table>
     </dd>
+    {% endif %}
     {% else %}
     <dt>cost</dt>
     <dd>
@@ -162,6 +169,7 @@
 </dl>
 
 {% ifequal object.status 'draft' %}
+{% if user.userinfo.approved %}
 {% if object.breaksTheBank %}
 {% else %}
 <form method="post" action="{{root}}/?class=Run&object={{object.id}}&action=start">
@@ -171,4 +179,6 @@
     </div> <!-- tab30ex -->
 </form>
 {% endif %}
+{% else %}
+{% endif %}
 {% endifequal %}

Modified: cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/run_list.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/run_list.html	2008-07-16 01:03:40 UTC (rev 12418)
+++ cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/run_list.html	2008-07-16 02:23:19 UTC (rev 12419)
@@ -1,7 +1,11 @@
 
 <h2><img src="{{root}}/images/rocket.gif" width=32 height=32> Runs</h2>
 
+{% if user.userinfo.approved %}
 <center><p>{{ user.userinfo.availableSUs }} SUs available ~ <small>E</small> <img src="{{root}}/images/progress_box.gif" style="background: white url({{root}}/images/progress_bar.gif) top left no-repeat; background-position: -{{user.userinfo.availableSUsPx154}}px 0px;"> <small>F</small> ~ {{ user.userinfo.usedSUs }} SUs used</p></center>
+{% else %}
+<center><p>&diams; <b>Please note:</b> You will not be able to run the codes until you are approved by a site administrator.</p></center>
+{% endif %}
 
 {% if object_list %}
     <table rules=cols class="clickable">

Modified: cs/portal/trunk/northridge/SeismoWebPortal/urls.py
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/urls.py	2008-07-16 01:03:40 UTC (rev 12418)
+++ cs/portal/trunk/northridge/SeismoWebPortal/urls.py	2008-07-16 02:23:19 UTC (rev 12419)
@@ -16,6 +16,7 @@
     (r'^(?P<pathname>pwreset/done/)$', 'SeismoWebPortal.views.directToTemplate', dict(template = 'registration/pwreset_done.html')),
     
     (r'^(?P<pathname>registration/)$', 'SeismoWebPortal.views.registration'),
+    (r'^(?P<pathname>registration/)(?P<inviteCode>\w+)/$', 'SeismoWebPortal.views.registration'),
     (r'^(?P<pathname>registration/password/)$', 'SeismoWebPortal.views.password_change', dict(template_name = 'SeismoWebPortal/password_change_form.html')),
 
     (r'^(?P<pathname>style.css)$', 'SeismoWebPortal.views.directToTemplate', dict(template = 'SeismoWebPortal/style.css', mimetype='text/css')),

Modified: cs/portal/trunk/northridge/SeismoWebPortal/views.py
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/views.py	2008-07-16 01:03:40 UTC (rev 12418)
+++ cs/portal/trunk/northridge/SeismoWebPortal/views.py	2008-07-16 02:23:19 UTC (rev 12419)
@@ -37,7 +37,7 @@
     className = request.REQUEST.get('class')
     if className is None:
         t = loader.get_template('SeismoWebPortal/home.html')
-        ret = t.render({'root': root})
+        ret = t.render({'root': root, 'user': request.user})
 
     else:
 
@@ -615,7 +615,7 @@
 # registration
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-def registration(request, pathname):
+def registration(request, pathname, inviteCode=None):
     from forms import RegistrationAddManipulator, RegistrationChangeManipulator
     from management import createExamplesForUser
 
@@ -634,7 +634,7 @@
         errors = manipulator.get_validation_errors(new_data)
         if not errors:
             manipulator.do_html2python(new_data)
-            user, errors = manipulator.save(new_data)
+            user, errors = manipulator.save(new_data, inviteCode)
             if not errors:
                 if isNewUser:
                     request.session.delete_test_cookie()
@@ -671,7 +671,7 @@
     subject = 'new user %s (%s)' % (user.username, invite or "UNINVITED")
     message = ["A new user has registered.",
                ""]
-    if not invite:
+    if not userInfo.approved:
         message.extend([
             """NOTE: Before this new user can run simulations, you must approve them by selecting the "approved" checkbox on the following page:""",
             "",



More information about the cig-commits mailing list