[ljcom] r12531: LJSUP-13273: Implement PromotionSlot::Jo...
Committer: vtroitsky
LJSUP-13273: Implement PromotionSlot::Journal class and DB storageU 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-08-23 11:29:20 UTC (rev 12530)
+++ trunk/cgi-bin/LJ/Widget/Shop/View/SelfPromo.pm 2012-08-23 11:57:29 UTC (rev 12531)
@@ -40,7 +40,6 @@
my ($promo_regions, $active_region) = LJ::Pay::PromotionSlot->find_available_promo_regions($remote, $country);
# warn "Active region: $active_region / Regions: [".join(',',@$promo_regions)."]";
-
# prepare template variables
my $result = {
@@ -56,69 +55,13 @@
my $slot = LJ::Pay::PromotionSlot->find_slot(class => PROMO_SELF(), type => $type, region => $active_region);
- # use Data::Dumper;
- # warn "SLOT:".Dumper($slot);
-
my $ml_info_title_object = LJ::Lang::ml("/shop/selfpromo.bml.info.title.$type");
- my $hide_buyout = 0;
- my $owner_cancel = 0;
+ my $elem = $slot->get_template_params(remote => $remote, shop_page => 1);
+ $elem->{'ml_info_title_object'} = $ml_info_title_object,
+ $elem->{'form_disabled'} = !$remote ? 1 : 0;
+ $elem->{'buyout_price'} = LJ::Request->post_param('price') if LJ::Request->post_param('price');
- my $data_selfpromo = [];
- my $buyout_cost = $slot->buyout_cost;
- my %hints = ();
-
- my $promo = $slot->current_promotion(); # return current promotion
- my $current_price = $promo ? $promo->cost : 0;
-
- ## 12345678 --> 12 345 678
- my $current_split = $current_price ? join ' ', grep { $_ } ($current_price =~ /^(.?.?.?)(...)*$/) : 0;
- 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) {
- $data_selfpromo = [ $promo->get_template_params(remote => $remote) ];
- $owner_cancel = $promo->can_cancel( $remote );
- $hide_buyout = $owner_cancel;
- %hints = $promo->get_other_promo_hints if $type eq 'entry';
-
- # 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 ),
- # },
- # );
- # $row->{'country_style'} = $result->{'country_style'};
- # }
- }
- my $elem = {
- 'type' => $type,
- 'country' => $active_region,
- 'ml_current_price' => $ml_current_price,
- 'ml_info_title_object' => $ml_info_title_object,
-
- 'buyout_cost' => LJ::Request->post_param('price') || $buyout_cost,
- 'data_selfpromo' => $data_selfpromo,
- 'hide_buyout' => $hide_buyout,
- 'owner_cancel' => $owner_cancel,
- 'form_disabled' => !$remote ? 1 : 0,
- %hints,
- };
-
if ($remote && $type eq 'journal') {
$elem->{'ljuser'} = $remote->ljuser_display();
$elem->{'is_identity'} = $remote->is_identity;
