sunnyman's (sunnyman) wrote in changelog,
sunnyman's
sunnyman
changelog

[ljcom] r11373: LJSUP-10937: DB Model updated cosmetic

Committer: vtroitsky
LJSUP-10937: DB Model updated cosmetic
U   trunk/bin/upgrading/update-db-local.pl
U   trunk/cgi-bin/LJ/Pay/SelfPromo.pm
Modified: trunk/bin/upgrading/update-db-local.pl
===================================================================
--- trunk/bin/upgrading/update-db-local.pl	2012-01-31 09:13:24 UTC (rev 11372)
+++ trunk/bin/upgrading/update-db-local.pl	2012-01-31 10:07:51 UTC (rev 11373)
@@ -1723,7 +1723,7 @@
         `cost`      int(11) NOT NULL default '0',
         `active`    int(11) NOT NULL default '1',
         `finished`  int(11) NOT NULL default '0',
-        `type`      enum('E','J','C') NOT NULL default 'E',
+        `type`      enum('entry','journal','community') NOT NULL default 'entry',
         PRIMARY KEY  (`promoid`)
     ) ENGINE=InnoDB
 });
@@ -2269,11 +2269,17 @@
         );
     }
 
-    unless (column_type('selfpromo', 'type')) {
+    my $type_column = column_type('selfpromo', 'type');
+    if ($type_column eq "" ) {
         do_alter(
             'selfpromo',
-            "ALTER TABLE selfpromo ADD COLUMN type enum('E','J','C') NOT NULL DEFAULT 'E'",
+            "ALTER TABLE selfpromo ADD COLUMN type enum('entry','journal','community') NOT NULL DEFAULT 'entry'",
         );
+    } elsif ( $type_column !~ /entry/i ) {
+        do_alter(
+            'selfpromo',
+            "ALTER TABLE selfpromo MODIFY COLUMN type enum('entry','journal','community') NOT NULL DEFAULT 'entry'",
+        );
     }
 
     unless (column_type("userapps", "userhead")) {

Modified: trunk/cgi-bin/LJ/Pay/SelfPromo.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/SelfPromo.pm	2012-01-31 09:13:24 UTC (rev 11372)
+++ trunk/cgi-bin/LJ/Pay/SelfPromo.pm	2012-01-31 10:07:51 UTC (rev 11373)
@@ -40,12 +40,12 @@
 );
   
 my %objects_map = (
-    'entry' => 'E',
-    'community' => 'C',
-    'journal' => 'J',
+    'entry' => 'entry',
+    'community' => 'community',
+    'journal' => 'journal',
 );
   
-sub type { 'E' }
+sub type { 'entry' }
 sub class { 'entry' };      # TODO: remove that function from base SelfPromo class
   
   
@@ -915,10 +915,10 @@
     # Add object specific properties, if object exists (in case of non refunding cart)
     if ( my $object = $opts->{'object'} ) {
 
-        my $ownerid = ($class->type eq 'E' ?  $object->journal->userid : $object->userid);  # TODO: Refactor that
+        my $ownerid = ($class->type eq 'entry' ?  $object->journal->userid : $object->userid);  # TODO: Refactor that
         $it->set_prop( 'selfpromo_journalid' => $ownerid );
 
-        if ( $class->type eq 'E' ) {
+        if ( $class->type eq 'entry' ) {
             $it->set_prop( 'selfpromo_ditemid'   => $object->ditemid );
         }
     }
@@ -1169,7 +1169,7 @@
 
 sub ownerid {
     my ($self) = @_;
-    return ($self->type eq 'E' ? $self->posterid : $self->journalid);
+    return ($self->type eq 'entry' ? $self->posterid : $self->journalid);
 }
 
 # owner of the promoted object:
@@ -1188,12 +1188,12 @@
 
 sub object {
     my ($self) = @_;
-    return ( $self->type eq 'E' ? LJ::Entry->new( $self->journalid, 'jitemid' => $self->jitemid ) : LJ::load_userid( $self->journalid ));
+    return ( $self->type eq 'entry' ? LJ::Entry->new( $self->journalid, 'jitemid' => $self->jitemid ) : LJ::load_userid( $self->journalid ));
 }
 
 sub is_object_deleted {
     my ($self) = @_;
-    return ( $self->type eq 'E' ? ! $self->object : ! ($self->object && $self->object->is_visible) );
+    return ( $self->type eq 'entry' ? ! $self->object : ! ($self->object && $self->object->is_visible) );
 }
 
 # TODO: Entry specific!!!! Incapsulate
@@ -1206,7 +1206,7 @@
 # ??? But if journal/community deleted?
 sub object_url {
     my ($self) = @_;
-    return ( $self->type eq 'E' ?  $self->journal->journal_base . '/' . $self->ditemid . '.html' :  $self->journal->journal_base );
+    return ( $self->type eq 'entry' ?  $self->journal->journal_base . '/' . $self->ditemid . '.html' :  $self->journal->journal_base );
 }
 
 =item is_promoting
@@ -1215,7 +1215,7 @@
 =cut
 sub is_promoting {
     my ($self, $object) = @_;
-    return ($self->type eq 'E' ? $self->journalid == $object->journalid && $self->jitemid == $object->jitemid : LJ::u_equals($object, $self->object));
+    return ($self->type eq 'entry' ? $self->journalid == $object->journalid && $self->jitemid == $object->jitemid : LJ::u_equals($object, $self->object));
 }
 
 

Tags: ljcom, pl, pm, sunnyman, vtroitsky
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