[Yapcom-commit] rev 100 - in yapcom/trunk: . lib/YAPC t templates

[prev] [thread] [next] [lurker] [Date index for 2003/11/30]

From: svn
Subject: [Yapcom-commit] rev 100 - in yapcom/trunk: . lib/YAPC t templates
Date: 23:50 on 30 Nov 2003
Author: gabor
Date: 2003-11-30 23:50:47 +0200 (Sun, 30 Nov 2003)
New Revision: 100

Removed:
   yapcom/trunk/templates/admin.tmpl
   yapcom/trunk/templates/admin_list_people.tmpl
Modified:
   yapcom/trunk/MANIFEST
   yapcom/trunk/lib/YAPC/Organizer.pm
   yapcom/trunk/t/11-web-admin.t
   yapcom/trunk/templates/list_people.tmpl
   yapcom/trunk/templates/user_account.tmpl
Log:
eliminate the nead for admin_list_people integrating the listing into the list_people page

Modified: yapcom/trunk/MANIFEST
===================================================================
--- yapcom/trunk/MANIFEST	2003-11-30 21:15:40 UTC (rev 99)
+++ yapcom/trunk/MANIFEST	2003-11-30 21:50:47 UTC (rev 100)
@@ -57,8 +57,6 @@
 templates/email/register.tmpl
 templates/email/register_subject.tmpl
 templates/personal_info.tmpl
-templates/admin.tmpl
-templates/admin_list_people.tmpl
 templates/admin_list_proposals.tmpl
 templates/email/password.tmpl
 templates/email_sent.tmpl

Modified: yapcom/trunk/lib/YAPC/Organizer.pm
===================================================================
--- yapcom/trunk/lib/YAPC/Organizer.pm	2003-11-30 21:15:40 UTC (rev 99)
+++ yapcom/trunk/lib/YAPC/Organizer.pm	2003-11-30 21:50:47 UTC (rev 100)
@@ -25,7 +25,7 @@
                    user_account logout list_my_proposals edit_my_proposal);  
 
 # list of pages accessible to administrators only
-my @admin_pages = qw(admin admin_list_people admin_list_proposals); 
+my @admin_pages = qw(admin admin_list_proposals); 
 
 # other pages that can be directly access but which don't need any authentication
 my @other_pages = qw(list_people login registration validation lost_validation lost_password
@@ -337,23 +337,29 @@
 sub list_people {
     my $self = shift;
 
+    my $id = $self->is_logged_in;
+    my $admin = $self->is_admin_user($id);
+
     my $ar = [];
-    foreach my $p (YAPC::Person->search(acked => 1, { order_by=>'fname' })) {
+    my @people;
+
+    if ($admin) { 
+       @people = YAPC::Person->retrieve_all;
+    } else {
+       @people = YAPC::Person->search(acked => 1, { order_by=>'fname' });
+    }
+
+    foreach my $p (@people) {
        my $url  =  $p->url;
        $url = "http://$url"; if ($url and substr($url, 0, 7) ne 'http://');
-       push @$ar, {
-                    fname   => $p->fname, 
-                    lname   => $p->lname,
-                    url     => $url,
-                    pauseid => $p->pauseid,
-                    mongers => $p->mongers,
-                    id      => $p->id,
-                  };
+        $p->{admin} = 1 if $admin;  # in each row we'll have to know if adminstrator looks at it or not. 
+        push @$ar, $p;
     }
     my $t = $self->_server_page('list_people');
     my $stat = YAPC::Person->get_statistics();
     $t->param(%$stat);
     $t->param(USERS => $ar);
+#    $t->param(admin => 1) if $admin;
     return $t->output;
 }
 
@@ -363,23 +369,6 @@
    return $t->output;
 }
 
-sub admin_list_people {
-    my $self = shift;
-
-    my $ar = [];
-    foreach my $p (YAPC::Person->retrieve_all) {
-       my $url  =  $p->url;
-       $url = "http://$url"; if ($url and substr($url, 0, 7) ne 'http://');
-        push @$ar, $p;
-
-    }
-    my $t = $self->_server_page('admin_list_people');
-    my $stat = YAPC::Person->get_statistics();
-    $t->param(%$stat);
-    $t->param(USERS => $ar);
-    return $t->output;
-}
-
 sub admin_list_proposals {
     my $self = shift;
 

Modified: yapcom/trunk/t/11-web-admin.t
===================================================================
--- yapcom/trunk/t/11-web-admin.t	2003-11-30 21:15:40 UTC (rev 99)
+++ yapcom/trunk/t/11-web-admin.t	2003-11-30 21:50:47 UTC (rev 100)
@@ -39,19 +39,11 @@
 YAPC::Test::Data::submit_talk(0, $cookies[0]);
 
 
-### access admin page(s)  by unauthenticated user
-{
-   local $ENV{REQUEST_URI}   = '/admin.html';
-   my $q = CGI->new();
-   my $webapp = YAPC::Organizer->new;
-   $webapp->query($q);
-   my $result = $webapp->run();
-   like($result, qr@<h2>Login</h2>@, "Access to 'admin.html' refused for unauthenticated user");
-}
 
-
 ### access admin page(s)  by authenticated user who is not an admin
-foreach my $page (qw(admin admin_list_people admin_list_proposals)) {
+### this should check with the regualar pages and see if the reveal sensitive information to 
+### someone who is not an admin ?
+foreach my $page (qw(admin_list_proposals)) {
    local $ENV{REQUEST_URI}   = "/$page.html";
    local $ENV{HTTP_COOKIE} = "Yapcom=$cookies[0]";
    my $q = CGI->new();
@@ -62,26 +54,14 @@
 }
    
 
-
-### access admin page(s)  by authenticated user who is an admin
+### access page(s)  by authenticated user who is an admin
 {
-   local $ENV{REQUEST_URI}   = '/admin.html';
+   local $ENV{REQUEST_URI}   = '/list_people.html';
    local $ENV{HTTP_COOKIE} = "Yapcom=$cookies[2]";
    my $q = CGI->new();
    my $webapp = YAPC::Organizer->new;
    $webapp->query($q);
    my $result = $webapp->run();
-   like($result, qr/Administrators page/, 'Access approved');
-}
-
-### access admin page(s)  by authenticated user who is an admin
-{
-   local $ENV{REQUEST_URI}   = '/admin_list_people.html';
-   local $ENV{HTTP_COOKIE} = "Yapcom=$cookies[2]";
-   my $q = CGI->new();
-   my $webapp = YAPC::Organizer->new;
-   $webapp->query($q);
-   my $result = $webapp->run();
    like($result, qr/$YAPC::Test::Data::people[0]{fname}/, "First name listed");
 }
 
@@ -98,7 +78,7 @@
 
 
 ### access admin page(s)  by unauthenticated user using run=admin  on the URL 
-foreach my $page (qw(admin admin_list_people admin_list_proposals)) {
+foreach my $page (qw(admin_list_proposals)) {
    local $ENV{REQUEST_URI}   = '/index.html';
    my $q = CGI->new({run => $page});
    my $webapp = YAPC::Organizer->new;

Deleted: yapcom/trunk/templates/admin.tmpl
===================================================================
--- yapcom/trunk/templates/admin.tmpl	2003-11-30 21:15:40 UTC (rev 99)
+++ yapcom/trunk/templates/admin.tmpl	2003-11-30 21:50:47 UTC (rev 100)
@@ -1,9 +0,0 @@
-<TMPL_VALUE NAME="title" VALUE="My YAPC Admin">
-<TMPL_INCLUDE NAME="header.tmpl">
-<h2>Administrators page</h2>
-<a href="./admin_list_people.html">List people</a><br />
-<a href="./admin_list_proposals.html">List proposals</a><br />
-<a href="./logout.html">Logout</a><br>
-Access to administrators only
-<TMPL_INCLUDE NAME="footer.tmpl">
-

Deleted: yapcom/trunk/templates/admin_list_people.tmpl
===================================================================
--- yapcom/trunk/templates/admin_list_people.tmpl	2003-11-30 21:15:40 UTC (rev 99)
+++ yapcom/trunk/templates/admin_list_people.tmpl	2003-11-30 21:50:47 UTC (rev 100)
@@ -1,34 +0,0 @@
-<TMPL_VALUE NAME="title" VALUE="Administrative List of People">
-<TMPL_INCLUDE NAME="header.tmpl">
-<p>
-
-Total number of registered people: <b><TMPL_VAR NAME="total"></b><br />
-Number of people who have also validated their e-mail: <b><TMPL_VAR NAME="validated"></b>
-</p>
-<p> 
-<table>
-<TMPL_LOOP NAME="users">
-<tr><td colspan="3"><hr /></td></tr>
-<tr>
-  <td>
-  <TMPL_IF NAME="url">
-     <a href="<TMPL_VAR NAME="url">"><TMPL_VAR NAME="fname"> <TMPL_VAR NAME="lname"></a>
-  <TMPL_ELSE>
-     <TMPL_VAR NAME="fname"> <TMPL_VAR NAME="lname">
-  </TMPL_IF>
-  </a></td>
-  <td><TMPL_VAR NAME="mongers"></td>
-  <td><a href="http://search.cpan.org/author/<TMPL_VAR NAME="pauseid">"><TMPL_VAR NAME="pauseid"></a></td>
-</tr>
-<tr>
-  <td><TMPL_IF NAME="acked">Validated<TMPL_ELSE>NOT Validated</TMPL_IF></td>
-  <td><TMPL_VAR NAME="company"></td>
-  <td><TMPL_VAR NAME="email"></td>
-</tr>
-<tr><td colspan="3"><TMPL_VAR NAME="bio"></td></tr>
-
-</TMPL_LOOP>
-</table>
-</p>
-<TMPL_INCLUDE NAME="footer.tmpl">
-

Modified: yapcom/trunk/templates/list_people.tmpl
===================================================================
--- yapcom/trunk/templates/list_people.tmpl	2003-11-30 21:15:40 UTC (rev 99)
+++ yapcom/trunk/templates/list_people.tmpl	2003-11-30 21:50:47 UTC (rev 100)
@@ -12,6 +12,7 @@
   </td>
   <td><TMPL_VAR NAME="mongers"></td>
   <td><a href="http://search.cpan.org/author/<TMPL_VAR NAME="pauseid">"><TMPL_VAR NAME="pauseid"></a></td>
+  <TMPL_IF NAME="admin"><td><TMPL_IF NAME="acked">&nbsp;<TMPL_ELSE>NACK</TMPL_IF></td></TMPL_IF>
 </tr>
 </TMPL_LOOP>
 </table>

Modified: yapcom/trunk/templates/user_account.tmpl
===================================================================
--- yapcom/trunk/templates/user_account.tmpl	2003-11-30 21:15:40 UTC (rev 99)
+++ yapcom/trunk/templates/user_account.tmpl	2003-11-30 21:50:47 UTC (rev 100)
@@ -11,7 +11,7 @@
 <TMPL_IF NAME="admin">
 <p>
 Administrative interface:<br />
-<a href="./admin_list_people.html">List people</a><br />
+<a href="./list_people.html">List people</a><br />
 <a href="./admin_list_proposals.html">List proposals</a><br />
 </TMPL_IF>
 </p>

Generated at 22:10 on 02 Dec 2003 by mariachi 0.51