From 9c8cafc6e77cf0cd202b22740f9c7d6e2df7fc59 Mon Sep 17 00:00:00 2001
From: Romain Courteaud <romain@nexedi.com>
Date: Thu, 20 Jan 2011 09:28:56 +0000
Subject: [PATCH] Automatically approve Computer registration.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42505 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../vifib_hosting/WebSection_registerNewComputer.xml | 12 ++++++++++--
 bt5/vifib_web/bt/revision                            |  2 +-
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_registerNewComputer.xml b/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_registerNewComputer.xml
index f223448a5f..80ae4117a6 100644
--- a/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_registerNewComputer.xml
+++ b/bt5/vifib_web/SkinTemplateItem/portal_skins/vifib_hosting/WebSection_registerNewComputer.xml
@@ -54,16 +54,23 @@
 \n
 computer_portal_type = "Computer"\n
 \n
-certificate_dict = context.getPortalObject().portal_certificate_authority.getNewCertificate()\n
+reference = "COMP-%s" % portal.portal_ids.generateNewId(\n
+    id_group=\'slap_computer_reference\',\n
+    id_generator=\'uid\')\n
+\n
+certificate_dict = context.getPortalObject().portal_certificate_authority.getNewCertificate(reference)\n
 \n
 module = portal.getDefaultModule(portal_type=computer_portal_type)\n
 computer = module.newContent(\n
   portal_type=computer_portal_type,\n
   title=title,\n
-  reference=certificate_dict["id"],\n
+  reference=reference,\n
+  destination_reference=certificate_dict["id"],\n
 )\n
 \n
 computer.requestComputerRegistration()\n
+computer.approveComputerRegistration()\n
+\n
 computer = context.restrictedTraverse(computer.getRelativeUrl())\n
 \n
 context.REQUEST.set("computer_certificate", certificate_dict["certificate"])\n
@@ -114,6 +121,7 @@ return computer.Computer_viewConnectionInformationAsWeb()\n
                             <string>context</string>
                             <string>portal</string>
                             <string>computer_portal_type</string>
+                            <string>reference</string>
                             <string>certificate_dict</string>
                             <string>module</string>
                             <string>_getitem_</string>
diff --git a/bt5/vifib_web/bt/revision b/bt5/vifib_web/bt/revision
index ce83bd94b3..ddc17b20b7 100644
--- a/bt5/vifib_web/bt/revision
+++ b/bt5/vifib_web/bt/revision
@@ -1 +1 @@
-258
\ No newline at end of file
+260
\ No newline at end of file
-- 
2.30.9