Committer: vtroitsky
LJSUP-12403: Console commands with commercial promoU trunk/cgi-bin/LJ/Console/Command/SelfPromo.pm
Modified: trunk/cgi-bin/LJ/Console/Command/SelfPromo.pm =================================================================== --- trunk/cgi-bin/LJ/Console/Command/SelfPromo.pm 2012-08-07 08:44:52 UTC (rev 12430) +++ trunk/cgi-bin/LJ/Console/Command/SelfPromo.pm 2012-08-07 10:10:25 UTC (rev 12431) @@ -7,10 +7,10 @@ use LJ::Pay::PromotionSlot qw(:classes :regions); use LJ::Pay::PromotedObject qw(:types); -sub cmd {'selfpromo'} +sub cmd {'promo'} sub desc { - return 'SelfPromo administration tools'; + return 'Promo services administration tools'; } sub usage { @@ -26,8 +26,8 @@ 'the username to cancel promotion or to ban or unban.', 'promo' => - 'Promo type to perform cmd for. Default value "*" that means it apply for all promos. ' . - 'Available values: *, '.join(', ', PROMO_SELF(), PROMO_COMMERCIAL(), PROMO_NOTIFICATIONS()).'.', + 'Promo type to perform cmd for. Default: no value that means it apply for all promos. ' . + 'Available values: '.join(', ', PROMO_SELF(), PROMO_COMMERCIAL(), PROMO_NOTIFICATIONS()).'.', 'region' => 'For "cancel" only, an optional flag that specifies ' . @@ -67,7 +67,7 @@ $message .= ', without refund' unless $refund; $message .= '. Reason: '. $reason if $reason; - LJ::statushistory_add( $object->owner, $admin, 'selfpromo', $message ); + LJ::statushistory_add( $object->owner, $admin, $slot->class(), $message ); $slot->admin_cancel_promo( 'object' => $object, @@ -173,13 +173,13 @@ # check all current promotions foreach my $pc (@promo_classes) { foreach my $cc (LJ::Pay::PromotionSlot->get_all_regions($pc)) { - foreach my $ptype (LJ::Pay::PromotionSlot->get_all_types($pc,$cc)) { + foreach my $ptype (LJ::Pay::PromotionSlot->get_all_types($pc, $cc)) { my $slot = LJ::Pay::PromotionSlot->find_slot(class => $pc, type => $ptype, country => $cc); $slot->check_current_promotion; my $current_promo = $slot->current_promotion(); - if ( $current_promo && ( $current_promo->is_promoter($u) || $current_promo->is_promoting($u)) ) { # $current_promo->is_owner($u) || - $self->info("The ban will affect the currently promoted $ptype in $cc promo, so cancelling that."); + if ( $current_promo && ( $current_promo->is_promoter($u) || $current_promo->is_promoting($object)) ) { # $current_promo->is_owner($u) || + $self->info("The ban will affect the currently promoted $ptype in $cc $pc promo, so cancelling that."); my $current_object = $current_promo->promoted_object(); $self->_cancel_object( 'slot' => $slot, 'type' => $ptype, 'object' => $current_object, 'reason' => $reason ); } @@ -188,7 +188,6 @@ } $object->ban_for_promos($reason, $admin, @promo_classes); - $self->info( $object->name . " banned successfully from $promo_class promo" . ($promo_class eq 'all' ? 's' : '') . '.' ); return 1; } @@ -196,23 +195,19 @@ if ( $type eq PROMO_OBJECT_TYPE_ENTRY() ) { my $entry = $object->object; foreach my $pc (@promo_classes) { - # check all regions foreach my $cc (LJ::Pay::PromotionSlot->get_all_regions($pc)) { - - my $slot = LJ::Pay::PromotionSlot->find_slot(class => PROMO_SELF(), type => $type, country => $cc); - + my $slot = LJ::Pay::PromotionSlot->find_slot(class => $pc, type => $type, country => $cc); $slot->check_current_promotion; my $current_promo = $slot->current_promotion(); if ( $current_promo && $current_promo->is_promoting($object) ) { - $self->info("The ban will affect the currently promoted entry in $country promo, so cancelling that."); + $self->info("The ban will affect the currently promoted entry in $country $pc promo, so cancelling that."); $self->_cancel_object( 'slot' => $slot, 'type' => $type, 'object' => $object, 'reason' => $reason ); } } } $object->ban_for_promos($reason, $admin, @promo_classes); - $self->info( $object->name . " banned successfully from $promo_class promo" . ($promo_class eq 'all' ? 's' : '') . '.' ); return 1; }