holyandrew (holyandrew) wrote in changelog,
holyandrew
holyandrew
changelog

[ljcom] r11594: LJSUP-11372: Develop regional self promo...

Committer: akanashin
LJSUP-11372: Develop regional self promo for Ukraine
U   trunk/bin/upgrading/en_LJ.dat
U   trunk/bin/upgrading/update-db-local.pl
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/htdocs/shop/selfpromo.bml
U   trunk/htdocs/shop/selfpromo.bml.text.local
Modified: trunk/bin/upgrading/en_LJ.dat
===================================================================
--- trunk/bin/upgrading/en_LJ.dat	2012-03-15 09:30:06 UTC (rev 11593)
+++ trunk/bin/upgrading/en_LJ.dat	2012-03-16 12:36:48 UTC (rev 11594)
@@ -4738,19 +4738,6 @@
 nokia.ny.2010.reskining.href|staleness=1
 nokia.ny.2010.reskining.href=http://www.livejournal.ru/nokia2010
 
-notification.rename-revoke-20120305.subject=Your LJ Tokens
-
-notification.rename-revoke-20120305.body<<
-Dear [[username]], 
-
-This email is to let you know that we've revoked 1500 tokens from your account, since you were mistakenly credited these tokens after your recent rename: [[cart_link]]
-
-If you have any questions about this, please contact our Billing department at: http://www.livejournal.com/contact/?dept=billing 
-
-Regards, 
-LiveJournal Team
-.
-
 notification.sms.befriended|staleness=1
 notification.sms.befriended=User '[[friend]]' has added you to their friends list. [[mobile_url]]
 
@@ -7257,6 +7244,10 @@
 
 selfpromo.entry.shop_item.name=Promotion of the <a href="[[object_url]]">entry</a>
 
+selfpromo.error.two_promos_entry=You can't promote your entries in Ukrainian and Default Promo at the same time. Please try again later.
+selfpromo.error.two_promos_journal=You can't promote your journal in Ukrainian and Default Promo at the same time. Please try again later
+selfpromo.error.two_promos_community=You can't promote your community in Ukrainian and Default Promo at the same time. Please try again later.
+
 selfpromo.journal.notification.activate.body<<
 Dear [[user]]!
  Promotion of your journal [[object_url]] was enabled successfully.
@@ -7621,21 +7612,9 @@
 
 setting.invisibleguests.option.self=I want to use My Guests to see who visits my journal and to be visible when visiting other journals and communities.
 
-setting.videoplaceholders.option2=Replace inline videos with a placeholder:
-setting.videoplaceholders.option2.checkbox1=In any entry
-setting.videoplaceholders.option2.checkbox2=In comments
-
 setting.ljtimes.label|staleness=1
 setting.ljtimes.label=LJTIMES
 
-setting.lastfm.prompt=Enter your username on LastFM
-setting.lastfm.label=Last.FM
-setting.music.label=Music Connect
-setting.trava.label|staleness=1
-setting.trava.label=TRAVA.ru
-setting.trava.connect=Connect
-setting.trava.disconnect=Disconnect
-
 setting.ljtimes.option.self|staleness=1
 setting.ljtimes.option.self=Display LJTIMES
 
@@ -8104,14 +8083,6 @@
 
 shop.reports.column.time.months=[[qty]] [[?qty|month|months|months]]
 
-shop.reports.detailed.discrepancies.name=Discrepancies
-
-shop.reports.detailed.discrepancies.payid.name=Cart ID
-
-shop.reports.detailed.discrepancies.cart.name=Total cost of items
-
-shop.reports.detailed.discrepancies.history.name=Sum of wallet history changes
-
 shop.reports.detailed.diskquota.name=Disk Quota
 
 shop.reports.detailed.diskquota.tokens.name=Tokens spent

Modified: trunk/bin/upgrading/update-db-local.pl
===================================================================
--- trunk/bin/upgrading/update-db-local.pl	2012-03-15 09:30:06 UTC (rev 11593)
+++ trunk/bin/upgrading/update-db-local.pl	2012-03-16 12:36:48 UTC (rev 11594)
@@ -1724,6 +1724,7 @@
         `active`    int(11) NOT NULL default '1',
         `finished`  int(11) NOT NULL default '0',
         `type`      enum('entry','journal','community') NOT NULL default 'entry',
+        `country`   enum('cyr','ua') NOT NULL default 'cyr',
         PRIMARY KEY  (`promoid`)
     ) ENGINE=InnoDB
 });
@@ -2288,6 +2289,13 @@
         );
     }
 
+    unless (column_type('selfpromo', 'country')) {
+        do_alter(
+            'selfpromo',
+            "ALTER TABLE selfpromo ADD COLUMN country enum('cyr','ua') NOT NULL DEFAULT 'cyr'",
+        );
+    }
+
     unless (column_type("userapps", "userhead")) {
         do_alter("userapps", qq{
             ALTER TABLE userapps

Modified: trunk/cgi-bin/LJ/Pay/Payment/PayItem/SelfPromo.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Payment/PayItem/SelfPromo.pm	2012-03-15 09:30:06 UTC (rev 11593)
+++ trunk/cgi-bin/LJ/Pay/Payment/PayItem/SelfPromo.pm	2012-03-16 12:36:48 UTC (rev 11594)
@@ -23,6 +23,22 @@
 
 # TODO (Refactoring): Incapsulate all that logic in PromoObject object + add constructor to create Promo object from the cart item SelfPromo + use methods of Promo object
 
+sub view_ua_ratings {
+     my $remote = shift;
+     my $view_ua_ratings = 0;
+     if (LJ::is_enabled('personal_stats_ua')) {
+         my $country = LJ::GeoLocation->get_country_info_by_ip;
+         $country = $remote->prop('country') if $remote && $country ne 'UA';
+         if ($country eq 'UA') {
+             my $view_ua_ratings_cookie = LJ::Request->cookie('view_ua_ratings')||'Y';
+             my $view_ua_ratings_prop = $remote ? ($remote->prop('view_ua_ratings')||'Y') : 'N';
+             $view_ua_ratings = 1 if $view_ua_ratings_cookie eq 'Y' || $view_ua_ratings_prop eq 'Y';
+         }
+     }
+     return $view_ua_ratings;
+}
+
+
 sub get_object {
     #return  LJ::Pay::SelfPromo::Promo->create_from_item($self);
     my ($self) = @_;
@@ -151,7 +167,7 @@
 
 
     my $class_type = $self->get_prop('selfpromo');
-    my $class = LJ::Pay::SelfPromo->get_class_by_type($class_type);
+    my $class = LJ::Pay::SelfPromo->get_class_by_type($class_type , (view_ua_ratings($buyer_u) ? 'ua' : 'cyr'));
 
     LJ::Pay::SelfPromo->debug_msg("acquiring the lock");
     my $lock = $class->lock;

Modified: trunk/cgi-bin/LJ/Pay/SelfPromo.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/SelfPromo.pm	2012-03-15 09:30:06 UTC (rev 11593)
+++ trunk/cgi-bin/LJ/Pay/SelfPromo.pm	2012-03-16 12:36:48 UTC (rev 11594)
@@ -8,6 +8,9 @@
 use LJ::Pay::SelfPromo::EntryPromo;
 use LJ::Pay::SelfPromo::JournalPromo;
 use LJ::Pay::SelfPromo::CommunityPromo;
+use LJ::Pay::SelfPromo::EntryPromoUA;
+use LJ::Pay::SelfPromo::JournalPromoUA;
+use LJ::Pay::SelfPromo::CommunityPromoUA;
 
 use Sys::Hostname qw();
 
@@ -34,9 +37,16 @@
 use constant $errors;
 
 my %classes_map = (
+'cyr' => {
     'entry' => 'LJ::Pay::SelfPromo::EntryPromo',
     'community' => 'LJ::Pay::SelfPromo::CommunityPromo',
     'journal' => 'LJ::Pay::SelfPromo::JournalPromo',
+},
+'ua' => {
+    'entry' => 'LJ::Pay::SelfPromo::EntryPromoUA',
+    'community' => 'LJ::Pay::SelfPromo::CommunityPromoUA',
+    'journal' => 'LJ::Pay::SelfPromo::JournalPromoUA',
+},
 );
   
 my %objects_map = (
@@ -47,10 +57,12 @@
   
 sub type { 'entry' }
 sub class { 'entry' };      # TODO: remove that function from base SelfPromo class
+sub country {''}
   
 sub get_class_by_type {
-    my ($class, $type) = @_;
-    return $classes_map{$type};
+    my ($class, $type, $country) = @_;
+    $country ||= 'cyr';
+    return $classes_map{$country}{$type};
 }
   
 sub get_object_by_type {
@@ -655,6 +667,9 @@
     push @where, 'type = ?';
     push @binds, $class->type;
 
+    push @where, 'country = ?';
+    push @binds, $class->country;
+
     if ( my $started_min = delete $params->{'started_min'} ) {
         push @where, 'started > ?';
         push @binds, $started_min;
@@ -734,6 +749,7 @@
 
     unless ($promoid) {
         my $from_memcache;
+
         unless ( $opts{'require_db'} ) {
             $from_memcache = LJ::MemCache::get( $class->memcache_key );
         }
@@ -747,6 +763,7 @@
             return LJ::Pay::SelfPromo::Promo->new($from_memcache);
         }
 
+
         my $rows = $class->find_promos(         # perform select for class specific rows
             { 'require_active' => 1, 'return_rows' => 1 } );
 
@@ -933,20 +950,16 @@
 
     ($it) = $cart->get_items;
 
-    my $effective_profit =
-        $opts->{'price'} - $opts->{'refund'} - $opts->{'remainder'};
-
     # set payitem props as appropriate
-    $it->set_prop( 'selfpromo'                  => $class->class );
-    $it->set_prop( 'selfpromo_type'             => $opts->{'type'} );
-    $it->set_prop( 'selfpromo_profit'           => $opts->{'profit'} );
-    $it->set_prop( 'selfpromo_refund'           => $opts->{'refund'} );
-    $it->set_prop( 'selfpromo_refund_userid'    => $opts->{'refund_userid'} );
-    $it->set_prop( 'selfpromo_refund_promoid'   => $opts->{'refund_promoid'} );
-    $it->set_prop( 'selfpromo_remainder'        => $opts->{'remainder'} );
-    $it->set_prop(                              
-        'selfpromo_remainder_userid' => $opts->{'remainder_userid'} );
-    $it->set_prop( 'selfpromo_effective_profit' => $effective_profit );
+    $it->set_prop( 'selfpromo'                => $class->class );
+    $it->set_prop( 'selfpromo_type'           => $opts->{'type'} );
+    $it->set_prop( 'selfpromo_profit'         => $opts->{'profit'} );
+    $it->set_prop( 'selfpromo_refund'         => $opts->{'refund'} );
+    $it->set_prop( 'selfpromo_refund_userid'  => $opts->{'refund_userid'} );
+    $it->set_prop( 'selfpromo_refund_promoid' => $opts->{'refund_promoid'} );
+    $it->set_prop( 'selfpromo_remainder'      => $opts->{'remainder'} );
+    $it->set_prop( 
+                 'selfpromo_remainder_userid' => $opts->{'remainder_userid'} );
 
     # Add object specific properties, if object exists (in case of non refunding cart)
     if ( my $object = $opts->{'object'} ) {
@@ -1087,6 +1100,7 @@
     my $dbh = LJ::get_db_writer();
 
     $args{'type'} = $class->type;
+    $args{'country'} = $class->country;
 
     my ( @sets, @binds );
     while ( my ( $k, $v ) = each %args ) {
@@ -1110,8 +1124,8 @@
     }
     my $sets = join( ',', @sets );
 
-    $dbh->do( "UPDATE selfpromo SET $sets WHERE promoid=? AND type=?",
-        undef, @binds, $promoid, $class->type );
+    $dbh->do( "UPDATE selfpromo SET $sets WHERE promoid=? AND type=? AND country=?",
+        undef, @binds, $promoid, $class->type, $class->country);
 }
 
 sub clear_memcache {
@@ -1120,8 +1134,11 @@
     LJ::MemCache::delete( $class->was_promoted_key($ownerid, $objectid) ) if $ownerid and $objectid;
 }
 
-sub memcache_key     { 'self_promo_'.shift->class().'_active' }
-sub was_promoted_key { 'self_promo_'.$_[0]->class().'_ids_promoted:'. join ':', $_[1], $_[2] }
+sub memcache_key { 
+    my $self = shift; 
+    return 'self_promo_'.$self->class().$self->country().'_active';
+}
+sub was_promoted_key { 'self_promo_'.$_[0]->class().$_[0]->country().'_ids_promoted:'. join ':', $_[1], $_[2] }
 
 sub raise_error {
     my ( $class, @args ) = @_;

Modified: trunk/cgi-bin/LJ/Widget/Shop/View/SelfPromo.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/Shop/View/SelfPromo.pm	2012-03-15 09:30:06 UTC (rev 11593)
+++ trunk/cgi-bin/LJ/Widget/Shop/View/SelfPromo.pm	2012-03-16 12:36:48 UTC (rev 11594)
@@ -8,12 +8,39 @@
 
 use LJ::Pay::SelfPromo qw(:codes);
 
+BML::set_language_scope('/shop/selfpromo.bml');
+
 sub require_remote {0}
 sub require_cart   {0}
 
 sub get_subpage       {'selfpromo'}
 sub get_template_file {'SelfPromo'}
 
+sub view_ua_ratings {
+    my $remote = LJ::get_remote(); 
+    my $get_country = LJ::Request->get_param('country');
+    my $view_ua_ratings = 0;
+    my $ua_rating_is_enabled = 0;
+    if (LJ::is_enabled('personal_stats_ua')) {
+        my $country = LJ::GeoLocation->get_country_info_by_ip;
+        $country = $remote->prop('country') if $remote && $country ne 'UA';
+        if ($country eq 'UA') {
+             $ua_rating_is_enabled = 1; 
+             if ( $get_country ) {
+                    $view_ua_ratings = 1 if $get_country eq 'ua';
+                    LJ::Request->set_cookie('view_ua_ratings' => $view_ua_ratings ? 'Y' : 'N', 'expires' => time + 60*60*24*180);
+                    $remote->set_prop('view_ua_ratings', $view_ua_ratings ? 'Y' : 'N') if $remote;
+              } else {
+                   my $view_ua_ratings_cookie = LJ::Request->cookie('view_ua_ratings')||'Y';
+                   my $view_ua_ratings_prop = $remote ? ($remote->prop('view_ua_ratings')||'Y') : 'N';
+                   $view_ua_ratings = 1 if $view_ua_ratings_cookie eq 'Y' || $view_ua_ratings_prop eq 'Y';
+              }
+        }
+    }
+
+    return ($view_ua_ratings, $ua_rating_is_enabled);
+}
+
 sub get_page_params {
     my ($self) = @_;
 
@@ -32,16 +59,20 @@
     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 $result = {
         'type'                  => $active_type,
         'tab_entry_active'      => $active_type eq 'entry',
         'tab_journal_active'    => $active_type eq 'journal',
         'tab_community_active'  => $active_type eq 'community',
+        'view_ua_ratings'       => $view_ua_ratings,
+        'ua_rating_is_enabled'  => $ua_rating_is_enabled,
     };
   
     # 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);
+        my $class = LJ::Pay::SelfPromo->get_class_by_type($type , ($view_ua_ratings ? 'ua' : 'cyr'));
 
         my $ml_info_title_object = LJ::Lang::ml("/shop/selfpromo.bml.info.title.$type");
 
@@ -51,7 +82,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 } );
+        my $data_selfpromo = LJ::PersonalStats->get_selfpromo_data( { 'type' => $type , ($view_ua_ratings ? 'ua' : 'cyr') } );
 
     # TODO (refactoring): encapsulate all thet logic into PromoObject::get_template_params() function 
         my $buyout_cost = $class->buyout_cost;
@@ -67,7 +98,7 @@
 
             # TODO (refactoring): Incapsulate that logic into PromoObject + SelfPromo processor
             my $promo = $class->current_promo_info( $row->{'promoid'} );
-        
+
             # TODO (refactoring): Incapsulate that logic inside PromoObject functions  $promo->can_withdraw($remote);
             my $can_withdraw = LJ::u_equals($promo->promoter, $remote) || LJ::u_equals($promo->owner, $remote);
 
@@ -130,15 +161,14 @@
         $self->ml_error('/shop/selfpromo.bml.error.not_logged_in');
     }
 
-
     my $type = LJ::Request->post_param('type');
     $type = 'entry' unless $type =~ /(entry|journal|community)/;
-    my $class = LJ::Pay::SelfPromo->get_class_by_type($type); 
-
+    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 $action = LJ::Request->post_param('action');
 
-    if ( $action eq 'promote' ) {
-        unless ( LJ::Request->post_param('confirm') ) {
+   if ( $action eq 'promote' ) {
+       unless ( LJ::Request->post_param('confirm') ) {
             $self->ml_error('error.unconfirmed');
             return;
         }
@@ -181,8 +211,9 @@
 
     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();
 # TODO (refactoring) Incapsulate that logic into SelfPromo facade + PromoObject
-    my $class = LJ::Pay::SelfPromo->get_class_by_type($type); 
+    my $class = LJ::Pay::SelfPromo->get_class_by_type($type  , ($view_ua_ratings ? 'ua' : 'cyr')); 
 
 
 # TODO (refactoring): 
@@ -251,7 +282,7 @@
     # Fill in data required to show the item
     # TODO (refactoring) Here may be the point of extraction of the real promoted object (entry/user) from stub object PromoObject ???? Or incapsulate all of the ligic inside PromoObject
     my $data =
-        LJ::PersonalStats->get_selfpromo_data( { 'fake_object' => $object, type => $type } );
+        LJ::PersonalStats->get_selfpromo_data( { 'fake_object' => $object, type => $type} );
     $template->param( 'data_selfpromo' => $data );
 
     return $format_result->( 'success', $template->output );
@@ -283,6 +314,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 ( $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;
     my $object_eligible =
         $class->is_object_eligible( $object, $remote,

Modified: trunk/htdocs/shop/selfpromo.bml
===================================================================
--- trunk/htdocs/shop/selfpromo.bml	2012-03-15 09:30:06 UTC (rev 11593)
+++ trunk/htdocs/shop/selfpromo.bml	2012-03-16 12:36:48 UTC (rev 11594)
@@ -3,6 +3,8 @@
 use strict;
 use warnings;
 
+BML::set_language_scope('/shop/selfpromo.bml');
+
 if ( LJ::Request->did_post ) {
     my $action = LJ::Request->post_param('action');
     if ( $action eq 'preview' ) {

Modified: trunk/htdocs/shop/selfpromo.bml.text.local
===================================================================
--- trunk/htdocs/shop/selfpromo.bml.text.local	2012-03-15 09:30:06 UTC (rev 11593)
+++ trunk/htdocs/shop/selfpromo.bml.text.local	2012-03-16 12:36:48 UTC (rev 11594)
@@ -160,6 +160,11 @@
 .promote.your.entry|staleness=1
 .promote.your.entry=Promote your entry
 
+.ratings.view.default=Default
+.ratings.view.default.description=Cyrillic rating
+.ratings.view.ua=Ukraine
+.ratings.view.ua.description=Ukraine rating
+
 .remaining_time=Time remaining: [[hours]] [[?hours|hour|hours|hours]] [[minutes]] [[?minutes|minute|minutes|minutes]].
 
 .tab.entry|staleness=1
@@ -183,4 +188,3 @@
 .your.journal.could.be.here=Your journal could be here
 .your.community.could.be.here=Your community could be here
 
-.confirm.cancel.text=Are you sure? Money will not be returned
\ No newline at end of file

Tags: akanashin, bml, dat, holyandrew, ljcom, local, pl, pm
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