sunnyman's (sunnyman) wrote in changelog,
sunnyman's
sunnyman
changelog

[ljcom] r11663: LJSUP-11372: selfpromo_ua disable flag a...

Committer: vtroitsky
LJSUP-11372: selfpromo_ua disable flag added
U   trunk/cgi-bin/LJ/Pay/Payment/PayItem/SelfPromo.pm
U   trunk/cgi-bin/LJ/Pay/SelfPromo.pm
U   trunk/cgi-bin/LJ/Widget/Shop/View/SelfPromo.pm
U   trunk/templates/Shop/SelfPromo.tmpl
Modified: trunk/cgi-bin/LJ/Pay/Payment/PayItem/SelfPromo.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Payment/PayItem/SelfPromo.pm	2012-03-30 15:08:03 UTC (rev 11662)
+++ trunk/cgi-bin/LJ/Pay/Payment/PayItem/SelfPromo.pm	2012-04-02 19:18:20 UTC (rev 11663)
@@ -73,7 +73,7 @@
     # return $promo_object->owner;
     my ($self) = @_;
 
-    #my $promo_object = LJ::Pay::SelfPromo::Promo->create_from_item($self);   #cache object creation
+    #my $promotion_object = LJ::Pay::Promotion->new_from_item($self);   #cache object creation
     # return $promo_object->owner;
 
     my $object = $self->get_object;

Modified: trunk/cgi-bin/LJ/Pay/SelfPromo.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/SelfPromo.pm	2012-03-30 15:08:03 UTC (rev 11662)
+++ trunk/cgi-bin/LJ/Pay/SelfPromo.pm	2012-04-02 19:18:20 UTC (rev 11663)
@@ -301,16 +301,7 @@
     LJ::Pay::SelfPromo->debug_msg( "piid=" . $item->get_piid );
 
 # TODO: Refactoring: Move most of that code have to be refactored more and to be moved into the LJ/Pay/SelfPromo* modules!, just put here necesasary functions calls
-
-    # if we cannot get a lock straight away, let this be delivered later;
-    # resolves race condition with ljmaint.pl and webs trying to deliver
-    # the same item simultaneously
-    #if ( LJ::Pay::SelfPromo->lock_taken_elsewhere ) {
-    #    LJ::Pay::SelfPromo->debug_msg(
-    #        "actually, another process got the lock, quitting");
-    #    return;
-    #}
-
+    
     # this should be temporary until we l10n the shop
     my $lang = ($rcpt_u && $rcpt_u->prop('browselang')) ? $rcpt_u->prop('browselang') : $LJ::DEFAULT_LANG;
     my $ml = sub {
@@ -318,17 +309,8 @@
         return LJ::Lang::get_text( $lang, $code, undef, $params );
     };
 
-    # my $class = LJ::Pay::SelfPromo->get_class_by_type($class_type , (view_ua_ratings($promoter) ? 'ua' : 'cyr'));
     my $object_type = $class->type;
 
-    #LJ::Pay::SelfPromo->debug_msg("acquiring the lock");
-    #my $lock = $class->lock;
-    # LJ::Pay::SelfPromo->debug_msg("got the lock");
-
-    #LJ::Pay::SelfPromo->debug_msg("checking the current entry");
-    #$class->check_current_promo;
-    #LJ::Pay::SelfPromo->debug_msg("current entry checked");
-
     my $type = $item->get_prop('selfpromo_type'); # action type
 
     LJ::Pay::SelfPromo->debug_msg("type = $type, object_type = $object_type, class = $class");

Modified: trunk/cgi-bin/LJ/Widget/Shop/View/SelfPromo.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/Shop/View/SelfPromo.pm	2012-03-30 15:08:03 UTC (rev 11662)
+++ trunk/cgi-bin/LJ/Widget/Shop/View/SelfPromo.pm	2012-04-02 19:18:20 UTC (rev 11663)
@@ -57,7 +57,8 @@
     LJ::need_string('/shop/selfpromo.bml.confirm.delete.promoted');
     LJ::need_string('/shop/selfpromo.bml.confirm.poster.cancel');
 
-    my ($view_ua_ratings, $ua_rating_is_enabled) = view_ua_ratings();
+    my ($view_ua_ratings, $ua_rating_is_enabled) = (0, 0);
+    ($view_ua_ratings, $ua_rating_is_enabled) = view_ua_ratings() if (LJ::is_enabled('selfpromo_ua')); 
 
     my $result = {
         'type'                  => $active_type,
@@ -70,7 +71,7 @@
   
     # Get all data for all types ob promo objects!!!!
     foreach my $type qw( entry journal community ) {
-        my $class = LJ::Pay::SelfPromo->get_class_by_type($type , ($view_ua_ratings ? 'ua' : 'cyr'));
+        my $class = LJ::Pay::SelfPromo->get_class_by_type($type , (LJ::is_enabled('selfpromo_ua') && $view_ua_ratings ? 'ua' : 'cyr'));
 
         my $ml_info_title_object = LJ::Lang::ml("/shop/selfpromo.bml.info.title.$type");
 
@@ -80,7 +81,7 @@
         # my $current_promo = LJ::Pay::SelfPromo->get_current_promo(type => $type);
         # my $data_selfpromo = $current_promo ? $current_promo->get_template_params() : [];
 
-        my $data_selfpromo = LJ::PersonalStats->get_selfpromo_data( { 'type' => $type , 'country' => ($view_ua_ratings ? 'ua' : 'cyr') } );
+        my $data_selfpromo = LJ::PersonalStats->get_selfpromo_data( { 'type' => $type , 'country' => (LJ::is_enabled('selfpromo_ua') && $view_ua_ratings ? 'ua' : 'cyr') } );
 
     # TODO (refactoring): encapsulate all thet logic into PromoObject::get_template_params() function 
         my $buyout_cost = $class->buyout_cost;
@@ -162,7 +163,7 @@
     my $type = LJ::Request->post_param('type');
     $type = 'entry' unless $type =~ /(entry|journal|community)/;
     my ($view_ua_ratings, $ua_rating_is_enabled) = view_ua_ratings();
-    my $class = LJ::Pay::SelfPromo->get_class_by_type($type , ($view_ua_ratings ? 'ua' : 'cyr')); 
+    my $class = LJ::Pay::SelfPromo->get_class_by_type($type , (LJ::is_enabled('selfpromo_ua') && $view_ua_ratings ? 'ua' : 'cyr')); 
     my $action = LJ::Request->post_param('action');
 
    if ( $action eq 'promote' ) {
@@ -211,7 +212,7 @@
     $type = 'entry' unless $type =~ /(entry|journal|community)/;
     my ($view_ua_ratings, $ua_rating_is_enabled) = view_ua_ratings();
 # TODO (refactoring) Incapsulate that logic into SelfPromo facade + PromoObject
-    my $class = LJ::Pay::SelfPromo->get_class_by_type($type  , ($view_ua_ratings ? 'ua' : 'cyr')); 
+    my $class = LJ::Pay::SelfPromo->get_class_by_type($type, (LJ::is_enabled('selfpromo_ua') && $view_ua_ratings ? 'ua' : 'cyr')); 
 
 
 # TODO (refactoring): 
@@ -312,14 +313,16 @@
 # TODO (refactoring): move that logic into PromoObject abstraction
     $object_url = ($type eq 'entry' ? $object->url : $object->journal_base );
 
-    my ($view_ua_ratings, $ua_rating_is_enabled) = view_ua_ratings();
-    my $anti_class = LJ::Pay::SelfPromo->get_class_by_type($type , ($view_ua_ratings ? 'cyr' : 'ua')); 
-    my $anti_object = $anti_class->current_promoted_object();
+    if(LJ::is_enabled('selfpromo_ua')) {
+        my ($view_ua_ratings, $ua_rating_is_enabled) = view_ua_ratings();
+        my $anti_class = LJ::Pay::SelfPromo->get_class_by_type($type , ($view_ua_ratings ? 'cyr' : 'ua')); 
+        my $anti_object = $anti_class->current_promoted_object();
 
-    if ( $type eq 'entry' ? $object->ditemid == $anti_object->{'ditemid'} : $object->userid == $anti_object->{'userid'} ) {
-        $type eq 'entry' ? $self->ml_error('selfpromo.error.two_promos_entry') :
-        ($type eq 'journal' ? $self->ml_error('selfpromo.error.two_promos_journal') :
+        if ( $type eq 'entry' ? $object->ditemid == $anti_object->{'ditemid'} : $object->userid == $anti_object->{'userid'} ) {
+            $type eq 'entry' ? $self->ml_error('selfpromo.error.two_promos_entry') :
+            ($type eq 'journal' ? $self->ml_error('selfpromo.error.two_promos_journal') :
                               $self->ml_error('selfpromo.error.two_promos_community'));
+        }
     }
 
     my $ineligible_reason;

Modified: trunk/templates/Shop/SelfPromo.tmpl
===================================================================
--- trunk/templates/Shop/SelfPromo.tmpl	2012-03-30 15:08:03 UTC (rev 11662)
+++ trunk/templates/Shop/SelfPromo.tmpl	2012-04-02 19:18:20 UTC (rev 11663)
@@ -5,7 +5,7 @@
 	<p><TMPL_VAR expr="ml('shop.view.selfpromo.promo.text')"></p>
 </div>
 
-<TMPL_IF ua_rating_is_enabled>
+<TMPL_IF ua_selfpromo_is_enabled>
     <ul class="opt-menu opt-menu-sort">
         <li>
             <TMPL_IF view_ua_ratings>

Tags: ljcom, pm, sunnyman, tmpl, vtroitsky
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments