madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[ljcom] r10986: LJSUP-9695: New tab added

Committer: sbelyaev
LJSUP-9695: New tab added
U   trunk/cgi-bin/LJ/Widget/Shop/View/Wallet.pm
U   trunk/templates/Shop/Wallet.tmpl
Modified: trunk/cgi-bin/LJ/Widget/Shop/View/Wallet.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/Shop/View/Wallet.pm	2011-09-09 09:06:31 UTC (rev 10985)
+++ trunk/cgi-bin/LJ/Widget/Shop/View/Wallet.pm	2011-09-09 10:04:03 UTC (rev 10986)
@@ -99,22 +99,25 @@
     );
 
     my $show_tab = LJ::Request->get_param('show');
-    $show_tab = 'buy' unless $show_tab =~ /(buy|send)/;
+    $show_tab = 'buy' unless $show_tab =~ /(buy|send|free)/;
 
     # autocomplete To field on Add form
     my @flist =
         LJ::isu($remote) ?
         map { $_->user } ($remote->people_friends) : ();
     my $js_complete = LJ::JSUtil::autocomplete(list => \@flist);
+    my $free_tokens_status = __is_free_tokens_enabled();
 
     return {
         'siteroot' => $LJ::SITEROOT,
         'promo_block_for_empty_wallet' => ($balance == 0),
+        'free_tokens_enabled' => $free_tokens_status,
         'balance' => $balance,
         'self_uri' => LJ::Request->uri,
 
         'tab_buy_active' => $show_tab eq 'buy',
         'tab_send_active' => $show_tab eq 'send',
+        'tab_tokens_free' => $show_tab eq 'free',
 
         'buy_select_options' => $buy_select_options,
         'proceed_buy_btn' => $proceed_buy_btn,
@@ -130,6 +133,20 @@
     };
 }
 
+sub __is_free_tokens_enabled {
+    my $u_sapato = LJ::load_user("test");
+    if ( !$u_sapato ) {
+        return 0;
+    }
+
+    if (!LJ::SUP->is_remote_sup) {
+        return 0;
+    }
+
+    my $balance = LJ::Pay::Wallet->get_user_balance( $u_sapato );
+    return ($balance >= 100);
+}
+
 sub _assert_remote_eligible {
     my ($self) = @_;
 

Modified: trunk/templates/Shop/Wallet.tmpl
===================================================================
--- trunk/templates/Shop/Wallet.tmpl	2011-09-09 09:06:31 UTC (rev 10985)
+++ trunk/templates/Shop/Wallet.tmpl	2011-09-09 10:04:03 UTC (rev 10986)
@@ -20,11 +20,23 @@
 
 <ul class="m-shop-tabs">
 <TMPL_IF name="tab_buy_active">
-	<li class="current"><a href="<TMPL_VAR self_uri>?show=buy"><TMPL_VAR expr="ml('wallet.bml.landing.tab.buy')"></a></li>
-	<li><a href="<TMPL_VAR self_uri>?show=send"><TMPL_VAR expr="ml('wallet.bml.landing.tab.send')"></a></li>
+    <li class="current"><a href="<TMPL_VAR self_uri>?show=buy"> <TMPL_VAR expr="ml('wallet.bml.landing.tab.buy')"></a></li>
+    <li><a href="<TMPL_VAR self_uri>?show=send"><TMPL_VAR expr="ml('wallet.bml.landing.tab.send')"></a></li>
+    <TMPL_IF free_tokens_enabled>
+        <li><a href="<TMPL_VAR self_uri>?show=free"><TMPL_VAR expr="ml('wallet.bml.landing.tab.free')"></a></li>
+    </TMPL_IF>
+<TMPL_ELSIF name="tab_send_active">
+	<li><a href="<TMPL_VAR self_uri>?show=buy"><TMPL_VAR expr="ml('wallet.bml.landing.tab.buy')"></a></li>
+    <li class="current"><a href="<TMPL_VAR self_uri>?show=send"><TMPL_VAR expr="ml('wallet.bml.landing.tab.send')"></a></li>
+    <TMPL_IF free_tokens_enabled>
+        <li><a href="<TMPL_VAR self_uri>?show=free"><TMPL_VAR expr="ml('wallet.bml.landing.tab.free')"></a></li>
+    </TMPL_IF>
 <TMPL_ELSE>
-	<li><a href="<TMPL_VAR self_uri>?show=buy"><TMPL_VAR expr="ml('wallet.bml.landing.tab.buy')"></a></li>
-	<li class="current"><a href="<TMPL_VAR self_uri>?show=send"><TMPL_VAR expr="ml('wallet.bml.landing.tab.send')"></a></li>
+    <li><a href="<TMPL_VAR self_uri>?show=free"><TMPL_VAR expr="ml('wallet.bml.landing.tab.buy')"></a></li>
+    <li><a href="<TMPL_VAR self_uri>?show=send"><TMPL_VAR expr="ml('wallet.bml.landing.tab.send')"></a></li>
+    <TMPL_IF free_tokens_enabled>
+        <li class="current"><a href="<TMPL_VAR self_uri>?show=free"><TMPL_VAR expr="ml('wallet.bml.landing.tab.free')"></a></li>
+    </TMPL_IF>   
 </TMPL_IF>
 </ul>
 
@@ -65,6 +77,12 @@
 		<p><TMPL_VAR proceed_xfer_btn></p>
 		</form>
 	</li>
+    <li class="b-wallet-tokens-item b-wallet-tokens-free<TMPL_IF name='tab_tokens_free'> current</TMPL_IF>">
+        <form action="<TMPL_VAR self_uri>" method="post">
+       
+        </form>
+    </li>
+
 </ul>
 
 <script type="text/javascript">

Tags: ljcom, madeon, 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