[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[3547] trunk



Revision: 3547
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3547&view=rev
Author:   einhverfr
Date:     2011-07-20 22:37:11 +0000 (Wed, 20 Jul 2011)

Log Message:
-----------
Correcting audit trail misreference.
Correcting user delete bug (3371764)

Modified Paths:
--------------
    trunk/LedgerSMB/DBObject/Admin.pm
    trunk/LedgerSMB/DBObject/Location.pm
    trunk/scripts/admin.pl
    trunk/sql/Pg-database.sql
    trunk/sql/modules/admin.sql

Added Paths:
-----------
    trunk/sql/modules/3547-constraints-upgrade.sql

Modified: trunk/LedgerSMB/DBObject/Admin.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Admin.pm	2011-07-18 17:12:45 UTC (rev 3546)
+++ trunk/LedgerSMB/DBObject/Admin.pm	2011-07-20 22:37:11 UTC (rev 3547)
@@ -94,7 +94,10 @@
     if ($self->{password} or $self->{import}){
        return $self->{dbh}->commit;
     }
-
+    # The location handling here is really brittle.....
+    # In the future, we need to have a coding standard that says that for
+    # objects, the parent is responsible for the child, and accept a data tree
+    # instead of a sort of ravioli architecture.  --CT.
     my $loc = LedgerSMB::DBObject::Location->new(base=>$self, copy=>'list', 
         merge=>[
             'address1',

Modified: trunk/LedgerSMB/DBObject/Location.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Location.pm	2011-07-18 17:12:45 UTC (rev 3546)
+++ trunk/LedgerSMB/DBObject/Location.pm	2011-07-20 22:37:11 UTC (rev 3547)
@@ -64,13 +64,4 @@
     return $ret->{location__get};
 }
 
-sub get_all {
-    
-    my $self = shift @_;
-    my $user_id = shift @_;
-    my $type = shift @_;
-    
-    my @locations = $self->exec_method(funcname=>$type."__all_locations", args=>[$user_id]);
-    return ..hidden..;
-}
-1;
\ No newline at end of file
+1;

Modified: trunk/scripts/admin.pl
===================================================================
--- trunk/scripts/admin.pl	2011-07-18 17:12:45 UTC (rev 3546)
+++ trunk/scripts/admin.pl	2011-07-20 22:37:11 UTC (rev 3547)
@@ -43,7 +43,7 @@
                 user_roles=>$user_obj->{roles},
                 salutations=>$admin->get_salutations(),
                 contact_classes=>$admin->get_contact_classes(),
-                locations=>$location->get_all($user_obj->{entity_id},"person"),
+                locations=>$user->{employee}->{locations},
                 default_country => $dcsetting->{value},
                 admin => $admin,
                 stylesheet => $request->{stylesheet},

Modified: trunk/sql/Pg-database.sql
===================================================================
--- trunk/sql/Pg-database.sql	2011-07-18 17:12:45 UTC (rev 3546)
+++ trunk/sql/Pg-database.sql	2011-07-20 22:37:11 UTC (rev 3547)
@@ -467,6 +467,19 @@
 COMMENT ON TABLE users IS $$username is the actual primary key here because we 
 do not want duplicate users$$;
 
+create table lsmb_roles (
+    
+    user_id integer not null references users(id) ON DELETE CASCADE,
+    role text not null
+    
+);
+
+COMMENT ON TABLE lsmb_roles IS 
+$$ Tracks role assignments in the front end.  Not sure why we need this.  Will
+rethink for 1.4.
+$$;
+
+
 -- Session tracking table
 
 
@@ -1641,7 +1654,7 @@
   formname text,
   action text,
   transdate timestamp default current_timestamp,
-  person_id integer references person(id) not null,
+  person_id integer references person(entity_id) not null,
   entry_id BIGSERIAL PRIMARY KEY
 );
 

Added: trunk/sql/modules/3547-constraints-upgrade.sql
===================================================================
--- trunk/sql/modules/3547-constraints-upgrade.sql	                        (rev 0)
+++ trunk/sql/modules/3547-constraints-upgrade.sql	2011-07-20 22:37:11 UTC (rev 3547)
@@ -0,0 +1,16 @@
+ALTER TABLE audittrail DROP CONSTRAINT "audittrail_person_id_fkey";
+
+\echo If the update below fails, it may be because the table is set up correctly
+\echo already.  It's safe to ignore constraint errors there.
+--'
+UPDATE audittrail 
+  SET person_id = (select entity_id from person where id = person_id);
+
+\echo If the alter table below fails, there is something wrong.  Please correct
+\echo before proceding.
+ALTER TABLE audittrail ADD FOREIGN KEY (person_id) REFERENCES person(entity_id);
+
+ALTER TABLE lsmb_roles DROP CONSTRAINT "lsmb_roles_user_id_fkey";
+
+ALTER TABLE lsmb_roles ADD foreign key (user_id) references users(id) 
+  ON DELETE CASCADE;

Modified: trunk/sql/modules/admin.sql
===================================================================
--- trunk/sql/modules/admin.sql	2011-07-18 17:12:45 UTC (rev 3546)
+++ trunk/sql/modules/admin.sql	2011-07-20 22:37:11 UTC (rev 3547)
@@ -13,18 +13,6 @@
 --
 -- -CT
 
-create table lsmb_roles (
-    
-    user_id integer not null references users(id),
-    role text not null
-    
-);
-
-COMMENT ON TABLE lsmb_roles IS 
-$$A beginning of a group tracking system.  Not exposed through the front end yet.
-$$;
-
-
 -- work in progress, not documenting yet.
 CREATE OR REPLACE FUNCTION admin__add_user_to_role(in_username TEXT, in_role TEXT) returns INT AS $$
     


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.