[Yapcom-commit] rev 119 - in yapcom/trunk: bin lib/YAPC templates

[prev] [thread] [next] [lurker] [Date index for 2003/12/17]

From: svn
Subject: [Yapcom-commit] rev 119 - in yapcom/trunk: bin lib/YAPC templates
Date: 16:58 on 17 Dec 2003
Author: gabor
Date: 2003-12-17 16:58:29 +0200 (Wed, 17 Dec 2003)
New Revision: 119

Modified:
   yapcom/trunk/bin/sqlite.pl
   yapcom/trunk/lib/YAPC/Organizer.pm
   yapcom/trunk/lib/YAPC/Talk.pm
   yapcom/trunk/templates/admin_list_proposals.tmpl
   yapcom/trunk/templates/proposal.tmpl
Log:
enable admins to edit any proposal and to set them as accepted

Modified: yapcom/trunk/bin/sqlite.pl
===================================================================
--- yapcom/trunk/bin/sqlite.pl	2003-12-17 13:22:53 UTC (rev 118)
+++ yapcom/trunk/bin/sqlite.pl	2003-12-17 14:58:29 UTC (rev 119)
@@ -61,7 +61,7 @@
 $sth->execute;
 while (my $hr = $sth->fetchrow_hashref) {
    no warnings 'uninitialized';
-   print join "|", @$hr{qw(id user_id title length language abstract other)};
+   print join "|", @$hr{qw(id user_id title length language accepted abstract other)};
    print "\n";
 }
 $sth->finish;

Modified: yapcom/trunk/lib/YAPC/Organizer.pm
===================================================================
--- yapcom/trunk/lib/YAPC/Organizer.pm	2003-12-17 13:22:53 UTC (rev 118)
+++ yapcom/trunk/lib/YAPC/Organizer.pm	2003-12-17 14:58:29 UTC (rev 119)
@@ -586,6 +586,7 @@
    my $id = $self->is_logged_in;
 
    my $t = $self->_server_page('proposal');
+   $t->param(ADMIN => $self->is_admin_user($id));
 
    # See logic in &lost_validation
    return $self->_build_prop_page($t) if not $q->param('submit');
@@ -593,7 +594,7 @@
    eval {
       if ($update)
       {
-         $talk = YAPC::Talk->change_talk($q->Vars, user_id => $id);
+         $talk = YAPC::Talk->change_talk(($self->is_admin_user($id) ? 1 : 0), $q->Vars, user_id => $id);
       }
       else {
          $talk = YAPC::Talk->propose($q->Vars, user_id => $id);
@@ -622,9 +623,13 @@
 
    my $user_id = $self->is_logged_in;
    my $t;
-   eval {($t) = YAPC::Talk->search(user_id => $user_id, id => $q->param('id'));};
-   return $self->send_message('no_such_proposal') if not $t;
-
+   if ($self->is_admin_user($user_id)) {
+     eval {($t) = YAPC::Talk->search(id => $q->param('id'));};
+     return $self->send_message('no_such_proposal') if not $t;
+   } else {
+     eval {($t) = YAPC::Talk->search(user_id => $user_id, id => $q->param('id'));};
+     return $self->send_message('no_such_proposal') if not $t;
+   }
    return $self->proposal('update') if $q->param('submit');
 
    $self->query->param(abstract => $t->abstract);
@@ -633,6 +638,9 @@
    $self->query->param(language => $t->language);
    $self->query->param(comment  => $t->other);
    $self->query->param(id       => $t->id);
+   if ($self->is_admin_user($user_id)) {
+      $self->query->param(accepted       => $t->accepted);
+   }
 
    $self->proposal('update');
 }

Modified: yapcom/trunk/lib/YAPC/Talk.pm
===================================================================
--- yapcom/trunk/lib/YAPC/Talk.pm	2003-12-17 13:22:53 UTC (rev 118)
+++ yapcom/trunk/lib/YAPC/Talk.pm	2003-12-17 14:58:29 UTC (rev 119)
@@ -21,19 +21,21 @@
 
    #croak("id should not be defined\n") if defined $args{id};
    delete $args{id};
+   delete $args{accepted};
 
    __PACKAGE__->create(\%args);
 }
 
 sub change_talk {
    my $self = shift;
+   my $admin = shift;
    my %args = $self->_check_values(@_);
 
    croak("id should be defined\n") if not defined $args{id};
    my ($t) = __PACKAGE__->search(id => $args{id});
-   my @valid_args = qw(id user_id title language length abstract other accepted);
+   my @valid_args = qw(title language length abstract other);
+   push @valid_args, 'accepted' if $admin;
    foreach my $a (@valid_args) {
-      next if ($a eq 'user_id' or $a eq 'id' or $a eq 'accepted');
       $t->set($a => $args{$a});
    }
    $t->update;
@@ -49,7 +51,6 @@
    $args{title} = $args{subject};
    croak("No length provided\n")   if not $args{'length'};
    croak("No abstract provided\n") if not $args{abstract};
-   $args{accepted} = 0;    # no trick from the outside please !
 
    # the form will have comment field and now we use the other field for our purposes
    $args{other} = $args{comment};

Modified: yapcom/trunk/templates/admin_list_proposals.tmpl
===================================================================
--- yapcom/trunk/templates/admin_list_proposals.tmpl	2003-12-17 13:22:53 UTC (rev 118)
+++ yapcom/trunk/templates/admin_list_proposals.tmpl	2003-12-17 14:58:29 UTC (rev 119)
@@ -6,6 +6,7 @@
 <tr><td><hr></td></tr>
 <tr><td><b><a href="<TMPL_VAR NAME="cgi_path">/talk.html?id=<TMPL_VAR NAME="talk_id">"><TMPL_VAR NAME="title"></a></b></pre></td></tr>  
 <tr><td>by: <a href="<TMPL_VAR NAME="cgi_path">/person.html?id=<TMPL_VAR NAME="id">"><TMPL_VAR NAME="fname"> <TMPL_VAR NAME="lname"></a></td></tr>
+<tr><td><a href="<TMPL_VAR NAME="cgi_path">/edit_my_proposal.html?id=<TMPL_VAR NAME="talk_id">">edit</a></td></tr>
 </TMPL_LOOP>
 </table>
 </p>

Modified: yapcom/trunk/templates/proposal.tmpl
===================================================================
--- yapcom/trunk/templates/proposal.tmpl	2003-12-17 13:22:53 UTC (rev 118)
+++ yapcom/trunk/templates/proposal.tmpl	2003-12-17 14:58:29 UTC (rev 119)
@@ -5,6 +5,16 @@
 <p>
 <font color="red"><TMPL_VAR NAME="MESSAGE"></font>
 </p>
+
+<TMPL_IF NAME="admin">
+<table bgcolor="red" border="1">
+ <tr><td>
+ <b> You are an administrator, think twice before editing some elses proposal.</b>
+ </td></tr>
+</table>
+
+</TMPL_IF>
+
 <p>
 <form method="post">
 <input type="hidden" name="submit" value="Submit" />
@@ -28,6 +38,25 @@
         <textarea cols="60" rows="20" name="abstract"><TMPL_VAR NAME="abstract"></textarea></td></tr>
 <tr><td colspan="2">Comments and special requests to the organizers<br />
         <textarea cols="60" rows="10" name="comment"><TMPL_VAR NAME="comment"></textarea></td></tr>
+
+<TMPL_IF NAME="admin">
+<tr><td colspan="2">
+<p />
+<table bgcolor="red" border="1">
+ <tr><td>
+ <b>This block is available only for administrators:</b>
+ </td></tr>
+ <tr><td>
+  Accepted: <input name="accepted" type="checkbox" <TMPL_IF NAME="accepted">checked</TMPL_IF> />
+ </td></tr>
+</table>
+
+</td></tr>
+</TMPL_IF>
+
+
+
+	
 <tr><td>&nbsp;</td><td><input type="submit" name="submitbtn" value="Submit" /></td></tr>
 </table>
 </form>

Generated at 18:00 on 17 Dec 2003 by mariachi 0.52