nuther check point

This commit is contained in:
David Delikat 2009-03-18 17:50:56 +00:00
parent e6fc38a502
commit 3c56bb64ae
4 changed files with 371 additions and 23 deletions

View file

@ -6,7 +6,7 @@ sub install {
print "inside install function\n";
my $confg = $ARGV[0];
my $home = $ARGV[1] || "/data/WebGUI";
my $className = "WebGUI::Asset::SKu::Ad";
my $className = "WebGUI::Asset::Sku::Ad";
unless ($home && $confg) {
die "usage: Perl -M$className -e install yoursite.conf\n";
}
@ -40,11 +40,16 @@ sub install {
#Create the templates
print "create purchase Ad Template\n";
my $purchaseAdTmpl = q|
<a name="id<tmpl_var assetId>" id="id<tmpl_var assetId>"></a>
<tmpl_if session.var.adminOn>
<p><tmpl_var controls></p>
</tmpl_if>
<tmpl_if error_msg>
<div class="error"><tmpl_var error_msg></div>
</tmpl_if>
<h3><tmpl_var adsku_title></h3>
<h4>TODO:Manage my ads link</h4>
<h4><a href='<tmpl_var manageLink>'>^International("form manage link","Asset_AdSku");</a></h4>
<tmpl_var adsku_description>
<tmpl_var form_header>
<tmpl_var form_hidden>
@ -64,13 +69,13 @@ sub install {
</tr>
<tr>
<td>number of clicks</td>
<td><tmpl_var form_clicks> @ <tmpl_var clicks_price> per click</td>
<td><tmpl_var click_discount></td>
<td><tmpl_var form_clicks> ^International("per click","Asset_AdSku", <tmpl_var click_price> );
<br>^International("click discount","Asset_AdSku",<tmpl_var click_discount>);</td>
</tr>
<tr>
<td>number of impressions</td>
<td><tmpl_var form_impressions> @ <tmpl_var clicks_price> per impression</td>
<td><tmpl_var impression_discount></td>
<td><tmpl_var form_impressions> ^International("per impression","Asset_AdSku", <tmpl_var impression_price> );
<br>^International("impression discount","Asset_AdSku",<tmpl_var impression_discount>);</td>
</tr>
<tr>
<td colspan="2" align="right"><tmpl_var form_submit></td>
@ -81,24 +86,36 @@ sub install {
|;
print "Manage Ads Template\n";
my $manageAdTmpl = q|
<h3>Manage My Ads</h3>
<h4>TODO:Buy Ad Space link</h4>
<a name="id<tmpl_var assetId>" id="id<tmpl_var assetId>"></a>
<tmpl_if session.var.adminOn>
<p><tmpl_var controls></p>
</tmpl_if>
<tmpl_if error_msg>
<div class="error"><tmpl_var error_msg></div>
</tmpl_if>
<h3>^International("form manage title","Asset_AdSku");</h3>
<h4><a href='<tmpl_var purchaseLink>'>^International("form purchase link","Asset_AdSku");</a></h4>
<br /><br />
<table border="0" cellpadding="3" cellspacing="0">
<tbody>
<tr>Title<th>
<tr>Clicks<th>
<tr>impressions<th>
<tr>renew<th>
</th>
<loop my_ads>
<tbody> <tr>
<th>^International("manage form table header title","Asset_AdSku");</th>
<th>^International("manage form table header clicks","Asset_AdSku");</th>
<th>^International("manage form table header impressions","Asset_AdSku");</th>
<th>^International("manage form table header renew","Asset_AdSku");</th>
</tr>
<tmpl_loop myAds>
</tr>
<td><tmpl_var loop.title></td>
<td><tmpl_var loop.clicks></td>
<td><tmpl_var loop.impressions></td>
<td><tmpl_var loop.renew></td>
<td><tmpl_var rowTitle></td>
<td><tmpl_var rowClicks></td>
<td><tmpl_var rowImpressions></td>
<td><tmpl_if rowDeleted>
^International("manage form table value deleted","Asset_AdSku");
<tmpl_else>
<a href="rowRenewLink">^International("manage form table value renew","Asset_AdSku");</a>
</tmpl_if></td>
</tr>
</loop>
</tmpl_loop>
</tbody>
</table>
|;

View file

@ -167,9 +167,80 @@ sub prepareView {
#-------------------------------------------------------------------
=head2 prepareManage
Prepares the template.
=cut
sub prepareManage {
my $self = shift;
$self->SUPER::prepareView();
my $templateId = $self->get("manageTemplate");
my $template = WebGUI::Asset::Template->new($self->session, $templateId);
$template->prepare($self->getMetaDataAsTemplateVariables);
$self->{_viewTemplate} = $template;
}
#-------------------------------------------------------------------
=head2 www_manage
manage previously purchased ads
=cut
sub www_manage {
my $self = shift;
my $check = $self->checkView;
return $check if (defined $check);
$self->session->http->setLastModified($self->getContentLastModified);
$self->session->http->sendHeader;
$self->prepareManage;
my $style = $self->processStyle($self->getSeparator);
my ($head, $foot) = split($self->getSeparator,$style);
$self->session->output->print($head, 1);
$self->session->output->print($self->manage);
$self->session->output->print($foot, 1);
return "chunked";
}
#-------------------------------------------------------------------
=head2 manage
generate template vars for manage page
=cut
sub manage {
my ($self) = @_;
my $session = $self->session;
my $i18n = WebGUI::International->new($session, "Asset_AdSku");
# TODO get the user id, get the asset collateral crud by uid, sort by purchase date descending, pull out unique adids
my %var = (
formHeader => WebGUI::Form::formHeader($session, { action=>$self->getUrl })
. WebGUI::Form::hidden( $session, { name=>"func", value=>"purchaseAdSku" }),
formFooter => WebGUI::Form::formFooter($session),
form_submit => WebGUI::Form::submit( $session, { value => $i18n->get("purchase button") }),
hasAddedToCart => $self->{_hasAddedToCart},
continueShoppingUrl => $self->getUrl,
purchaseLink => $self->getUrl,
myAds => [
# TODO foreach unique adis create a row here
{ rowTitle => 'here is an ad', rowClicks => '5/200', rowImpressions => '100/2000', rowDeleted => 0, rowRenewLink => '' },
{ rowTitle => 'yet another ad', rowClicks => '99/4000', rowImpressions => '10/200', rowDeleted => 1, rowRenewLink => '' },
],
);
return $self->processTemplate(\%var,undef,$self->{_viewTemplate});
}
#-------------------------------------------------------------------
=head2 view
Displays the donation form.
Displays the purchase adspace form
=cut
@ -182,16 +253,88 @@ sub view {
formHeader => WebGUI::Form::formHeader($session, { action=>$self->getUrl })
. WebGUI::Form::hidden( $session, { name=>"func", value=>"purchaseAdSku" }),
formFooter => WebGUI::Form::formFooter($session),
purchaseButton => WebGUI::Form::submit( $session, { value => $i18n->get("purchase button") }),
form_submit => WebGUI::Form::submit( $session, { value => $i18n->get("purchase button") }),
hasAddedToCart => $self->{_hasAddedToCart},
continueShoppingUrl => $self->getUrl,
price => sprintf("%.2f", $self->getPrice),
manageLink => $self->getUrl("func=manage"),
adSkuTitle => $self->get('title'),
adSkuDescription => $self->get('description'),
form_title => WebGUI::Form::text($session, {
-name=>"form_title",
-value=>$self->{title},
-size=>40
}),
form_link => WebGUI::Form::Url($session, {
-name=>"form_link",
-value=>$self->{link},
-size=>40
}),
form_image => WebGUI::Form::Image($session, {
-name=>"form_image",
-value=>$self->{image},
-size=>40
}),
form_clicks => WebGUI::Form::Integer($session, {
-name=>"form_clicks",
-value=>$self->{clicks},
-size=>40
}),
form_impressions => WebGUI::Form::Integer($session, {
-name=>"form_impressions",
-value=>$self->{impressions},
-size=>40
}),
click_price => $self->get('pricePerClick'),
impression_price => $self->get('pricePerImpression'),
click_discount => $self->getClickDiscountText,
impression_discount => $self->getImpressionDiscountText,
);
return $self->processTemplate(\%var,undef,$self->{_viewTemplate});
}
#-------------------------------------------------------------------
=head2 getDiscountCountList -- class level function
returns a string with a coma seperated list of counts fromt he discount text
=cut
sub getDiscountCountList {
# TODO
# parse the discount text -- for each line, get the first number
# join all the number in a coma,list
return '500';
}
#-------------------------------------------------------------------
=head2 getClickDiscountText
returns the text to display the number of clicks purchasaed where discounts apply
=cut
sub getClickDiscountText {
my $self = shift;
return getDiscountCountList($self->get('ClickDiscounts'));
}
#-------------------------------------------------------------------
=head2 getImpressionDiscountText
returns the text to display the number of impressions purchased where discounts apply
=cut
sub getImpressionDiscountText {
my $self = shift;
return getDiscountCountList($self->get('impressionDiscounts'));
}
#-------------------------------------------------------------------
=head2 www_purchaseAdSKu
Add this subscription to the cart.

View file

@ -0,0 +1,80 @@
package WebGUI::AssetCollateral::Sku::Ad::Ad;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2009 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use strict;
use base WebGUI::Crud;
#------------------------------------------------
=head crud_definition
defines the field this crud will contain
userID => the id of the user that purchased the ad
transactionItemid => the id if the transaction item that completes this purchase
adId => th id if the ad purchased
clicksPurchased => the number of clicks the user purchased
impressionsPurchased => the number of impressions the user purchased
storedImage => temp storage for the image
isRenewal => indicates if this purchase is a renewal -- are the counts increased or just assigned
isDeleted => boolean that indicates whether the ad has been deleted from the system
=cut
sub crud_definition {
my ($class, $session) = @_;
my $definition = $class->SUPER::crud_definition($session);
$definition->{tableName} = 'adSkuPurchase';
$definition->{tableKey} = 'userId';
$definition->{properties} = {
userId => {
fieldType => 'user',
defaultValue => undef,
},
transactionItemid => {
fieldType => 'guid',
defaultValue => undef,
},
adId => {
fieldType => 'guid',
defaultValue => undef,
},
clicksPurchased => {
fieldType => 'integer',
defaultValue => undef,
},
impressionsPurchased => {
fieldType => 'integer',
defaultValue => undef,
},
storedImage => {
fieldType => 'guid',
defaultValue => undef,
},
isRenewal => {
fieldType => 'yesNo',
defaultValue => 0,
},
isDeleted => {
fieldType => 'yesNo',
defaultValue => 0,
},
};
return $definition;
}

View file

@ -117,6 +117,114 @@ our $I18N = {
context => q|name for the Ad Space Sku|
},
'Ad Title' => {
message => q|Ad Title|,
lastUpdated => 0,
context => q|TODO|
},
'Ad Link' => {
message => q|Ad Link|,
lastUpdated => 0,
context => q|TODO|
},
'Image' => {
message => q|Image|,
lastUpdated => 0,
context => q|TODO|
},
'number of clicks' => {
message => q|number of clicks|,
lastUpdated => 0,
context => q|TODO|
},
'number of impressions' => {
message => q|number of impressions|,
lastUpdated => 0,
context => q|TODO|
},
'click discount' => {
message => q|Discount at %s clicks|,
lastUpdated => 0,
context => q|TODO|
},
'impression discount' => {
message => q|Discount at %s impressions|,
lastUpdated => 0,
context => q|TODO|
},
'per click' => {
message => q|@ %f per click|,
lastUpdated => 0,
context => q|TODO|
},
'per impression' => {
message => q|@ %f per impression|,
lastUpdated => 0,
context => q|TODO|
},
'form manage title' => {
message => q|Manage My Ads|,
lastUpdated => 0,
context => q|text for the title of the form where the user can manage previously purchased advertisements|
},
'form manage link' => {
message => q|Manage My Ads|,
lastUpdated => 0,
context => q|text for a link to the form where the user can manage previously purchased advertisements|
},
'form purchase link' => {
message => q|Purchase Ads|,
lastUpdated => 0,
context => q|text for a link to the form where the user can purchase advertisements|
},
'manage form table header title' => {
message => q|Title|,
lastUpdated => 0,
context => q|header for the adspace manage form: the title field|
},
'manage form table header clicks' => {
message => q|Clicks|,
lastUpdated => 0,
context => q|header for the adspace manage form: the clicks field|
},
'manage form table header impressions' => {
message => q|Impressions|,
lastUpdated => 0,
context => q|header for the adspace manage form: the impressions field|
},
'manage form table header renew' => {
message => q|Renew|,
lastUpdated => 0,
context => q|header for the adspace manage form: the renew field|
},
'manage form table value deleted' => {
message => q|Deleted|,
lastUpdated => 0,
context => q|contents for the renew field on the manage ads table: indicates a deleted item|
},
'manage form table value renew' => {
message => q|Renew|,
lastUpdated => 0,
context => q|contents for the renew field on the manage ads table: indicates a renewable item|
},
'TODO' => {
message => q|TODO|,
lastUpdated => 0,