Committer: vtroitsky
LJSUP-12301: Additional refactoring of common parts with Selfpromo. get_template_params updated.U trunk/cgi-bin/LJ/Widget/Shop/View/SelfPromo.pm
Modified: trunk/cgi-bin/LJ/Widget/Shop/View/SelfPromo.pm =================================================================== --- trunk/cgi-bin/LJ/Widget/Shop/View/SelfPromo.pm 2012-06-15 11:05:33 UTC (rev 12119) +++ trunk/cgi-bin/LJ/Widget/Shop/View/SelfPromo.pm 2012-06-15 11:32:43 UTC (rev 12120) @@ -64,7 +64,7 @@ my $hide_buyout = 0; my $owner_cancel = 0; - my $data_selfpromo = $slot->get_template_params(); + my $data_selfpromo = []; my $buyout_cost = $slot->buyout_cost; my $promo = $slot->current_promotion(); # return current promotion @@ -75,26 +75,33 @@ my $ml_current_price = LJ::Lang::ml( '/shop/selfpromo.bml.current_price', { 'price' => $current_split } ); # add some stuff (actually 1 element in array) + + # TODO: [Refactoring] move that all stuff to Promotion if ($promo) { - foreach my $row (@$data_selfpromo) { - $row->{'can_withdraw'} = $promo->can_withdraw($remote); - $hide_buyout = $row->{'can_withdraw'}; - $owner_cancel = $promo->can_cancel( $remote); + $data_selfpromo = [ $promo->get_template_params(remote => $remote) ]; + $owner_cancel = $promo->can_cancel( $remote ); + $hide_buyout = $owner_cancel; + # MOVED TO Promotion/Auction.pm, sub _template_parameters + + #foreach my $row (@$data_selfpromo) { + # $row->{'can_withdraw'} = $promo->can_withdraw($remote); + + # $hide_buyout = $row->{'can_withdraw'}; # if for some reason the entry has already expired, this silently # casts its remaining time to zero: - my $remtime = List::Util::max( $promo->stop_time - time, 0 ); - my $remtime_hours = int ( $remtime / 3600 ); - my $remtime_minutes = int ( ( $remtime % 3600 ) / 60 ); - $row->{'ml_remaining'} = LJ::Lang::ml( - '/shop/selfpromo.bml.remaining_time', - { - 'hours' => sprintf( '%02d', $remtime_hours ), - 'minutes' => sprintf( '%02d', $remtime_minutes ), - }, - ); + # my $remtime = List::Util::max( $promo->stop_time - time, 0 ); + # my $remtime_hours = int ( $remtime / 3600 ); + # my $remtime_minutes = int ( ( $remtime % 3600 ) / 60 ); + # $row->{'ml_remaining'} = LJ::Lang::ml( + # '/shop/selfpromo.bml.remaining_time', + # { + # 'hours' => sprintf( '%02d', $remtime_hours ), + # 'minutes' => sprintf( '%02d', $remtime_minutes ), + # }, + # ); # $row->{'country_style'} = $result->{'country_style'}; - } + # } } my $elem = { 'type' => $type,