Tightened up login-form, welcome page
authorgfawcett <gfawcett@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Sat, 10 Jan 2009 21:02:08 +0000 (21:02 +0000)
committergfawcett <gfawcett@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Sat, 10 Jan 2009 21:02:08 +0000 (21:02 +0000)
* Added a tab-bar for anonymous users, and dropped the ugly right-side panel
* Login form returns with an error instead of an ugly text-message
* Logout returns you to the Home page
* Cleaned up the tab-bar a bit; some items there really belong elsewhere.

git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@99 6d9bc8c9-1ec2-4278-b937-99fde70a366f

conifer/static/main.css
conifer/syrup/views.py
conifer/templates/auth/login.xhtml
conifer/templates/master.xhtml
conifer/templates/tabbar.xhtml
conifer/templates/tabbar_anonymous.xhtml [new file with mode: 0644]
conifer/templates/welcome.xhtml

index f82e52c..b56585b 100644 (file)
@@ -28,7 +28,9 @@ body {
 
 #brandheader { background-color: white; padding: 8; }
 
-#header a { color: #fff; font-weight: bold;  }
+#header a { color: #fff; font-weight: bold;  padding: 8 6; }
+#header a.loginbutton { background-color: #a44; padding: 8 16; }
+#header a:hover { background-color: #fb7; color: black; text-decoration: none; }
 
 #footer {  
     margin-top: 12;
@@ -99,3 +101,11 @@ a:hover {  text-decoration: underline;  }
 .topheading th {
     background-color: #ddf;
 }
+
+
+p.todo, div.todo { background-color: #fdd; padding: 6; margin: 12; border-left: #d99 6px solid; }
+
+
+.newsitem { 
+    max-width: 600;
+}
\ No newline at end of file
index 9eb71f3..91c9285 100644 (file)
@@ -11,24 +11,36 @@ from django.db.models import Q
 
 
 #------------------------------------------------------------
+# Authentication
 
 def auth_handler(request, path):
     if path == 'login/':
         if request.method == 'GET':
-            return g.render('auth/login.xhtml')
+            next=request.GET.get('next', '/syrup/')
+            if request.user.is_authenticated():
+                return HttpResponseRedirect(next)
+            else:
+                return g.render('auth/login.xhtml', 
+                                next=request.GET.get('next'),
+                                err=None # fixme, this shouldn't be
+                                         # necessary. Genshi should treat
+                                         # missing names as None, but something
+                                         # is wrong.
+                                )
         else:
             userid, password = request.POST['userid'], request.POST['password']
+            next = request.POST['next']
             user = authenticate(username=userid, password=password)
             if user is None:
-                return HttpResponse('invalid login.')
+                return g.render('auth/login.xhtml', err='Invalid username or password. Please try again.', next=next)
             elif not user.is_active:
-                return HttpResponse('disabled account.')
+                return g.render('auth/login.xhtml', err='Sorry, this account has been disabled.', next=next)
             else:
                 login(request, user)
-                return HttpResponseRedirect(request.POST['next'])
+                return HttpResponseRedirect(request.POST.get('next', '/syrup/'))
     elif path == 'logout':
         logout(request)
-        return HttpResponse('Logged out. Thanks for coming!')
+        return HttpResponseRedirect('/syrup/')
     else:
         return HttpResponse('auth_handler: ' + path)
 
index 74c7538..fad126a 100644 (file)
@@ -14,7 +14,8 @@ title = 'Syrup E-Reserves: Please log in'
 <body>
   <h1>Please log in.</h1>
   <form action="." method="post">
-    <input type="hidden" name="next" value="${request.GET['next']}"/>
+    <input type="hidden" name="next" value="${next}"/>
+    <div class="errors" py:if="err">${err}</div>
   <table>
     <tr>
       <th>User ID:</th>
index c9d715d..962e535 100644 (file)
@@ -45,9 +45,11 @@ app_name = 'Syrup E-Reserve System'
       </span>
       <span py:if="not user.is_authenticated()">
        <strong style="padding-right: 18;">Welcome!</strong>
+       <a class="loginbutton" href="/accounts/login/">Log In</a>
       </span>
     </div>
       <xi:include py:if="user.is_authenticated()" href="tabbar.xhtml"/>
+      <xi:include py:if="not user.is_authenticated()" href="tabbar_anonymous.xhtml"/>
       <div id="mainpanel">
        ${select('*|text()')}
       </div>
index 281efc2..abcdfc6 100644 (file)
@@ -8,10 +8,10 @@
 -->
 <ul id="tabbar">
   <li><a href="/syrup/">Home</a></li>
+  <li><a href="/syrup/browse/">Browse</a></li>
   <li class="active"><a href="/syrup/course/">My Courses</a></li>
-  <li><a href="/syrup">Add a Reserve</a></li>
-  <li><a href="/syrup/join/">Join Course</a></li>
-  <li><a href="/syrup">Manage Users</a></li>
-  <li><a href="/syrup">Preferences</a></li>
+  <li><a href="/syrup/join/">Join a Course</a></li>
+  <!-- <li><a href="/syrup">Add a Reserve</a></li> -->
+  <!-- <li><a href="/syrup">Manage Users</a></li> -->
 </ul>
 </html>
diff --git a/conifer/templates/tabbar_anonymous.xhtml b/conifer/templates/tabbar_anonymous.xhtml
new file mode 100644 (file)
index 0000000..eb72aed
--- /dev/null
@@ -0,0 +1,13 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+      xmlns:py="http://genshi.edgewall.org/"
+      xmlns:xi="http://www.w3.org/2001/XInclude"
+      py:strip="">
+<!--
+    eventually these should be customized based on user level
+    use one for now
+-->
+<ul id="tabbar">
+  <li><a href="/syrup/">Home</a></li>
+  <li><a href="/syrup/browse/">Browse</a></li>
+</ul>
+</html>
index b91869b..9da242e 100644 (file)
@@ -9,12 +9,8 @@ title = 'Welcome!'
   <title>${title}</title>
 </head>
 <body>
-  <div style="float: right; margin: 0 24; background-color: #feb; padding: 24;">
-    <p py:if="not user.is_authenticated()"><a href="/accounts/login/?next=/syrup/">Log in</a></p>
-    <p><a href="browse">Browse</a></p> 
-  </div>
   <h1>News</h1>
-  <div py:for="news in models.NewsItem.objects.all().order_by('-published')[0:5]">
+  <div class="newsitem" py:for="news in models.NewsItem.objects.all().order_by('-published')[0:5]">
     <h2>${news.subject}</h2>
     <div>${news.body}</div>
   </div>