Андрей (andy) wrote in changelog,
Андрей
andy
changelog

[ljcom] r10898: LJSUP-9572 (Display 'time left' on shop ...

Committer: ailyin
LJSUP-9572 (Display 'time left' on shop page)
U   trunk/cgi-bin/LJ/Widget/Shop/View/SelfPromo.pm
U   trunk/htdocs/shop/selfpromo.bml.text.local
U   trunk/templates/Shop/SelfPromo.tmpl
Modified: trunk/cgi-bin/LJ/Widget/Shop/View/SelfPromo.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/Shop/View/SelfPromo.pm	2011-08-23 00:06:58 UTC (rev 10897)
+++ trunk/cgi-bin/LJ/Widget/Shop/View/SelfPromo.pm	2011-08-23 01:21:02 UTC (rev 10898)
@@ -4,6 +4,8 @@
 
 use base qw( LJ::Widget::Shop::View );
 
+use List::Util qw();
+
 use LJ::Pay::SelfPromo qw(:codes);
 
 sub require_remote {1}
@@ -28,13 +30,31 @@
             'ditemid' => $row->{'post_id'}, );
 
         $row->{'can_withdraw'} = $entry->poster->equals($remote);
+
+        my $info =
+            LJ::Pay::SelfPromo->current_entry_info( $row->{'promoid'} );
+
+        # if for some reason the entry has already expired, this silently
+        # casts its remaining time to zero:
+        my $remtime         = List::Util::max( $info->{'exptime'} - 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 $hide_buyout = 0;
 
-    # if ( my $entry = LJ::Pay::SelfPromo->current_entry ) {
-    # $hide_buyout = ( $entry->posterid == $remote->userid );
-    # }
+    if ( my $entry = LJ::Pay::SelfPromo->current_entry ) {
+        $hide_buyout = ( $entry->posterid == $remote->userid );
+    }
 
     return {
         'ml_current_price' => $ml_current_price,

Modified: trunk/htdocs/shop/selfpromo.bml.text.local
===================================================================
--- trunk/htdocs/shop/selfpromo.bml.text.local	2011-08-23 00:06:58 UTC (rev 10897)
+++ trunk/htdocs/shop/selfpromo.bml.text.local	2011-08-23 01:21:02 UTC (rev 10898)
@@ -24,6 +24,12 @@
 
 .error.wallet_insufficient_funds=You only have [[have]] [[?have|LJ Token|LJ Tokens]] in your Wallet, which is not enough to pay [[need]] [[?need|LJ Token||LJ Tokens]] for promotion.
 
+.info.btn.withdraw=Withdraw
+
+.info.title.remote=You already promote an entry
+
+.info.title.somebody=Somebody already promotes an entry
+
 .label.current_price=Current price:
 
 .label.entry_link=Link to your post:
@@ -36,5 +42,7 @@
 
 .price_description=Enter number of tokens (a multiple of 100) you would like to pay.
 
+.remaining_time=Time left: [[hours]] [[?hours|hour|hours|hours]] [[minutes]] [[?minutes|minute|minutes|minutes]].
+
 .title=Self Promo
 

Modified: trunk/templates/Shop/SelfPromo.tmpl
===================================================================
--- trunk/templates/Shop/SelfPromo.tmpl	2011-08-23 00:06:58 UTC (rev 10897)
+++ trunk/templates/Shop/SelfPromo.tmpl	2011-08-23 01:21:02 UTC (rev 10898)
@@ -14,7 +14,7 @@
 			<TMPL_VAR form_auth>
 			<input type="hidden" name="action" value="withdraw" />
 			<input type="hidden" name="withdraw_url" value="<TMPL_VAR post_url>" />
-			<h3>You already promote an entry</h3>
+			<h3><TMPL_VAR expr="ml('/shop/selfpromo.bml.info.title.remote')"></h3>
 			<dl class="rate-posts-item">
 				<dt>
 					<em><a href="<TMPL_VAR post_url>"><TMPL_IF subject><TMPL_VAR subject><TMPL_ELSE>no subject</TMPL_IF></a></em>
@@ -22,10 +22,11 @@
 				</dt>
 				<TMPL_IF body><dd><TMPL_VAR body></dd></TMPL_IF>
 			</dl>
-			<button type="submit">Withdraw</button>
+			<p class="remaining"><TMPL_VAR ml_remaining></p>
+			<button type="submit"><TMPL_VAR expr="ml('/shop/selfpromo.bml.info.btn.withdraw')"></button>
 		</form>
 		<TMPL_ELSE>
-		<h3>Somebody already promotes an entry</h3>
+		<h3><TMPL_VAR expr="ml('/shop/selfpromo.bml.info.title.somebody')"></h3>
 		<dl class="rate-posts-item selfpromo-post">
 			<dt>
 				<em><a href="<TMPL_VAR post_url>"><TMPL_IF subject><TMPL_VAR subject><TMPL_ELSE>no subject</TMPL_IF></a></em>
@@ -33,6 +34,7 @@
 			</dt>
 			<TMPL_IF body><dd><TMPL_VAR body></dd></TMPL_IF>
 		</dl>
+		<p class="remaining"><TMPL_VAR ml_remaining></p>
 		</TMPL_IF>
 	</div>
 </TMPL_LOOP>

Tags: andy, ljcom, local, pm, tmpl
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