[wellwell-devel] [SCM] Interchange wellwell catalog branch, master, updated. dd29dd807639e10fe71571367d3f2a8a0e65e785

Stefan Hornburg racke at rt.icdevgroup.org
Tue Jun 9 14:33:59 UTC 2009


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Interchange wellwell catalog".

The branch, master has been updated
       via  dd29dd807639e10fe71571367d3f2a8a0e65e785 (commit)
      from  8e6e91482f313d208ce2774202846b995f4be5c0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit dd29dd807639e10fe71571367d3f2a8a0e65e785
Author: Stefan Hornburg (Racke) <racke at linuxia.de>
Date:   Tue Jun 9 16:33:27 2009 +0200

    new status field in carts
    carts can be finalized

-----------------------------------------------------------------------

Summary of changes and diff:
 plugins/wishlists/code/wishlist.tag        |   43 ++++++++++++++++++++++++++--
 plugins/wishlists/code/wishlists.sub       |    6 ++++
 plugins/wishlists/database/pgsql/carts.sql |    1 +
 3 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/plugins/wishlists/code/wishlist.tag b/plugins/wishlists/code/wishlist.tag
index 1713966..ddf9cc3 100644
--- a/plugins/wishlists/code/wishlist.tag
+++ b/plugins/wishlists/code/wishlist.tag
@@ -4,7 +4,7 @@ UserTag wishlist HasEndTag
 UserTag wishlist Routine <<EOR
 sub {
 	my ($function, $sku, $name, $type, $opt, $body) = @_;
-	my ($wishlist_code, $set);
+	my ($wishlist_code, $set, $status);
 
 	$function ||= 'list';
 	$name ||= $Variable->{WISHLISTS_DEFAULT_NAME};
@@ -38,6 +38,11 @@ sub {
 		}
 	}
 
+	if ($wishlist_code) {
+		# record wishlist status
+		$status = $Db{carts}->field($wishlist_code, 'status');
+	}
+
 	# determine fields to use for wishlists
 	my $i = 0;
 	my %product_fields;
@@ -57,8 +62,15 @@ sub {
 			return;
 		}
 
-		# create new wishlist if necessary
-		unless ($wishlist_code) {
+		if ($wishlist_code) {			
+			if ($status eq 'final') {
+				# no updates allowed to finalized wishlists
+				$Tag->error({name => 'wishlist', set => 'Wishlist finalized'});
+				return;
+			}
+		}
+		else {
+			# create new wishlist
 			$wishlist_code = $Db{carts}->autosequence();
 			$Db{carts}->set_slice($wishlist_code, uid => $Session->{username},
 								  created => $Tag->time({format => '%s'}),
@@ -95,6 +107,12 @@ sub {
 	}
 	
 	if ($function eq 'update') {
+		if ($status eq 'final') {
+			# no updates allowed to finalized wishlists
+			$Tag->error({name => 'wishlist', set => 'Wishlist finalized'});
+			return;
+		}
+
 		# update product in wishlist
 		my %data;
 
@@ -107,6 +125,12 @@ sub {
 		$Db{cart_products}->set_slice([$wishlist_code, $sku], %data);
 	}
 	elsif ($function eq 'remove') {
+		if ($status eq 'final') {
+			# no updates allowed to finalized wishlists
+			$Tag->error({name => 'wishlist', set => 'Wishlist finalized'});
+			return;
+		}
+
 		# remove product from wishlist
 		$Db{cart_products}->delete_record([$wishlist_code, $sku]);
 	}
@@ -118,10 +142,23 @@ sub {
 			$fields = join(',', '', keys %product_fields);			
 		}
 
+		# expose status
+		$Tag->tmp('wishlist_status', $status);
+
 		my $sql = qq{select sku$fields from cart_products where cart = $wishlist_code order by position};
 
 		return $Tag->query ({sql => $sql, list => 1, prefix => 'item',
 				body => $body});
 	}
+	elsif ($function eq 'status') {
+		my $status;
+
+		if ($opt->{status}) {
+			$Db{carts}->set_field($wishlist_code, 'status', $opt->{status});
+			return;
+		}
+
+		return $status;
+	}
 }
 EOR
diff --git a/plugins/wishlists/code/wishlists.sub b/plugins/wishlists/code/wishlists.sub
index 533921e..58016e2 100644
--- a/plugins/wishlists/code/wishlists.sub
+++ b/plugins/wishlists/code/wishlists.sub
@@ -77,6 +77,12 @@ sub {
 		}
 	}
 
+	# whether to finalize wishlist
+	if ($CGI->{finalize}) {
+		$Tag->wishlist({function => 'status', name => $wishlist_name,
+			code => $wishlist_code, status => 'final'});
+	}
+
 	# show wishlist for the current user
 	if ($args[0] eq 'carts') {
 		$CGI->{mv_nextpage} = 'wishlists/carts';
diff --git a/plugins/wishlists/database/pgsql/carts.sql b/plugins/wishlists/database/pgsql/carts.sql
index 65f6a49..228a4ad 100644
--- a/plugins/wishlists/database/pgsql/carts.sql
+++ b/plugins/wishlists/database/pgsql/carts.sql
@@ -2,6 +2,7 @@ CREATE TABLE carts (
   code serial PRIMARY KEY,
   name varchar(255) NOT NULL default '',
   type varchar(32) NOT NULL default '',
+  status varchar(32) NOT NULL default '',
   uid integer NOT NULL,
   created integer NOT NULL,
   last_modified integer NOT NULL default 0


hooks/post-receive
-- 
Interchange wellwell catalog



More information about the wellwell-devel mailing list