/[Frey]/trunk/lib/App/RoomReservation/Confirmation.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/App/RoomReservation/Confirmation.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1152 by dpavlin, Wed Jul 1 22:25:11 2009 UTC revision 1178 by dpavlin, Tue Jul 7 20:11:44 2009 UTC
# Line 16  sub verify_as_markup { Line 16  sub verify_as_markup {
16    
17          my $dbh = $self->dbh;          my $dbh = $self->dbh;
18    
19            my $size = $self->room->seats;
20    
21          my $sth = $dbh->prepare(qq{          my $sth = $dbh->prepare(qq{
22                  update reservation                  update reservation
23                  set                  set
# Line 23  sub verify_as_markup { Line 25  sub verify_as_markup {
25                          _seat_number = (                          _seat_number = (
26                                  select                                  select
27                                          min(seat.nr)                                          min(seat.nr)
28                                  from (select generate_series(1,600) as nr) as seat                                  from (select generate_series(1,$size) as nr) as seat
29                                  full join reservation on reservation._seat_number = seat.nr                                  full join reservation on reservation._seat_number = seat.nr
30                                  where id is null                                  where id is null
31                                  group by seat.nr                                  group by seat.nr
# Line 33  sub verify_as_markup { Line 35  sub verify_as_markup {
35                  where                  where
36                          md5(id||email) = ?                          md5(id||email) = ?
37                          and _confirmed is false                          and _confirmed is false
38                            and _canceled is false
39          });          });
40    
41          $sth->execute( $self->token );          my $token = $self->token;
42    
43            $sth->execute( $token );
44    
45          if ( $sth->rows == 0 ) {          if ( $sth->rows == 0 ) {
46                  warn "can't confirm ", $self->token, " check if it's allready confirmed";                  warn "can't confirm ", $self->token, " check if it's allready confirmed";
# Line 46  sub verify_as_markup { Line 51  sub verify_as_markup {
51                                  md5(id||email) = ?                                  md5(id||email) = ?
52                                  and _confirmed is true                                  and _confirmed is true
53                  });                  });
54                  $sth->execute( $self->token );                  $sth->execute( $token );
55          }          }
56    
57          if ( $sth->rows == 1 ) {          if ( $sth->rows == 1 ) {
58    
59                  die "can't find account associated with ", $self->token unless $sth->rows == 1;                  die qq|<error>can't find account associated with $token</error>| unless $sth->rows == 1;
60    
61                  return $self->seat_confirmation_message( token => $self->token );                  return $self->seat_confirmation_message( token => $token );
62    
63          } else {          } else {
64                  die "Problem with confirmation.\n";                  die qq|<error>Can't find confirmation $token<br>
65                            Did you copy-pasted whole URL in your browser?</error>|;
66          }          }
67  }  }
68    
# Line 68  sub cancel_as_markup { Line 74  sub cancel_as_markup {
74          my $sth = $dbh->prepare(qq{          my $sth = $dbh->prepare(qq{
75                  update reservation                  update reservation
76                  set                  set
77                          _confirmed = false,                          _canceled = true,
78                          _seat_number = null                          _seat_number = null
79                  where                  where
80                          md5(id||email) = ?                          md5(id||email) = ?
# Line 81  sub cancel_as_markup { Line 87  sub cancel_as_markup {
87                          Your <em>reservation is canceled</em>, thanks for your effort to provide seat to somebody else                          Your <em>reservation is canceled</em>, thanks for your effort to provide seat to somebody else
88                  |;                  |;
89          } else {          } else {
90                  die "Problem with cancelation.\n";                  die qq|<error>Can't find reservation which you are trying to cancel.<br>
91                            Did you copy-pasted whole URL in your browser?</error>|;
92          }          }
93  }  }
94    

Legend:
Removed from v.1152  
changed lines
  Added in v.1178

  ViewVC Help
Powered by ViewVC 1.1.26