Browse Source

Bugfixes en create_datas scripts and admin.py

prieto 7 years ago
parent
commit
503f683b4f
3 changed files with 41 additions and 30 deletions
  1. 6
    3
      plugins/webui/interface/controllers/admin.py
  2. 26
    22
      progs/create_datas
  3. 9
    5
      progs/create_datas.sh

+ 6
- 3
plugins/webui/interface/controllers/admin.py View File

@@ -142,11 +142,14 @@ def admin_create(request):
142 142
 
143 143
         for in_put, in_value in request.form.items():
144 144
             # The classname is handled by the datasource, we are not allowed to modify it
145
-            # uid is not a fieldname
146 145
             # both are hidden in the form, to identify the object here
147
-            if in_put != 'classname' and in_value != '':
146
+             if in_put != 'classname' and in_value != '':
148 147
                 fields[in_put[12:]] = in_value
149
-        
148
+                dhl = target_leo.data_handler(in_put[12:])
149
+                if dhl.is_reference() and in_value != '':
150
+                    in_value.replace(" ","")
151
+                    in_value=in_value.split(',')
152
+                    in_value=list(in_value)
150 153
         # Insertion in the database of the values corresponding to a new object
151 154
         new_uid = target_leo.insert(fields)
152 155
         

+ 26
- 22
progs/create_datas View File

@@ -3,10 +3,12 @@
3 3
 host=$1
4 4
 instance=$2
5 5
 N=$3
6
-HOSTDB=localhost:27017
6
+HOSTDB=localhost
7 7
 
8
-for i in ${1..$N..10)
8
+M=$(expr $N / 10)
9
+for i in `eval echo {1..$M}`;
9 10
 do
11
+    COLPUBLI=""
10 12
     COLT=$(lenmax=100;wcount=5; rlenmax=$(expr $lenmax - 1); echo $(shuf /usr/share/dict/words | head -n $wcount | tr -s "\n" " ") | sed -E "s/^(.{$rlenmax}).*$/\1/") 
11 13
     curl -A "Mozilla/5.0" -L -s -d "field_input_title=$COLT&field_input_publications=$COLPUBLI&classname=Collection" http://$host/$instance/admin/create?classname=Collection
12 14
     ITTHM="themetest"
@@ -21,65 +23,67 @@ do
21 23
     curl -A "Mozilla/5.0" -L -s -d "field_input_lastname=$LN&field_input_firstname=$FN&field_input_password=$PWD&field_input_login=$LOGIN&classname=User" http://$host/$instance/admin/create?classname=User
22 24
 done
23 25
 
24
-for i in ${1..$N..4)
26
+M=$(expr $N / 4)
27
+for i in `eval echo {1..$M}`;
25 28
 do
26
-    persons=$(printf "use lodel2\ndb.Person.find\({}, {lodel_id:1, _id:0}\).limit\(3\)" | mongo  HOSTDB/admin -u lodel_admin -p lapwd  | sed "1,3d" | sed -e "s/{ \"lodel_id\" : //g" | sed -e "s/ }//g" | sed '\$d')
29
+    persons=$(printf "use lodel2_$instance\n db.Person.find({}, {lodel_id:1, _id:0}).limit(3)" | mongo  $HOSTDB/admin -u lodel2_admin -p lapwd | sed "1,3d" | sed -e "s/{ \"lodel_id\" : //g" | sed -e "s/ }//g" | sed "\$d")
27 30
     tmp=""
28 31
     for i in $persons
29 32
     do
30
-        if [ $tmp = "" ]
33
+        if [[ ! -z $tmp ]]
31 34
         then
32
-            tmp=$(printf("$tmp, $i"))
35
+            tmp=$(printf "$tmp, $i")
33 36
         else
34 37
             tmp=$i
35 38
         fi
36 39
     done
37 40
     SECLP=$tmp
38
-    SECST=$(lenmax=120;wcount=10; rlenmax=$(expr $lenmax - 1); echo $(shuf /usr/share/dict/words | head -n $wcount | tr -s "\n" " ") | sed -E "s/^(.{$rlenmax}).*$/\1/")
39
-    res=$(printf "use lodel2\ndb.Indextheme.find\({}, {lodel_id:1, _id:0}\).limit\(5\)" | mongo  HOSTDB/admin -u lodel_admin -p lapwd  | sed "1,3d" | sed -e "s/{ \"lodel_id\" : //g" | sed -e "s/ }//g" | sed '\$d')
41
+    SECST=$(lenmax=60;wcount=10; rlenmax=$(expr $lenmax - 1); echo $(shuf /usr/share/dict/words | head -n $wcount | tr -s "\n" " ") | sed -E "s/^(.{$rlenmax}).*$/\1/")
42
+    res=$(printf "use lodel2_$instance\n db.Indextheme.find({}, {lodel_id:1, _id:0}).limit(5)" | mongo  $HOSTDB/admin -u lodel2_admin -p lapwd  | sed "1,3d" | sed -e "s/{ \"lodel_id\" : //g" | sed -e "s/ }//g" | sed "\$d")
40 43
     tmp=""
41 44
     for i in $res
42 45
     do
43
-        if [ $tmp = "" ]
46
+        if [[ ! -z $tmp ]]
44 47
         then
45
-            tmp=$(printf("$tmp, $i"))
48
+            tmp=$(printf "$tmp, $i")
46 49
         else
47 50
             tmp=$i
48 51
         fi
52
+    done
49 53
     SECIND=$tmp
50
-    SECTTL=$(lenmax=100;wcount=5; rlenmax=$(expr $lenmax - 1); echo $(shuf /usr/share/dict/words | head -n $wcount | tr -s "\n" " ") | sed -E "s/^(.{$rlenmax}).*$/\1/")
54
+    SECTTL=$(lenmax=60;wcount=5; rlenmax=$(expr $lenmax - 1); echo $(shuf /usr/share/dict/words | head -n $wcount | tr -s "\n" " ") | sed -E "s/^(.{$rlenmax}).*$/\1/")
51 55
     curl -A "Mozilla/5.0" -L -s -d "field_input_linked_persons=$SECLP&field_input_subtitle=$SECST&field_input_indexes=$SECIND&field_input_title=$SECTTL&classname=Section" http://$host/$instance/admin/create?classname=Section
52 56
 done
53 57
 
54
-for i in ${seq $N}
58
+for i in `eval echo {1..$N}`;
55 59
 do
56
-    persons=$(printf "use lodel2\ndb.Person.find\({}, {lodel_id:1, _id:0}\).limit\(3\)" | mongo  HOSTDB/admin -u lodel_admin -p lapwd  | sed "1,3d" | sed -e "s/{ \"lodel_id\" : //g" | sed -e "s/ }//g" | sed '\$d')
60
+    persons=$(printf "use lodel2_$instance\n db.Person.find({}, {lodel_id:1, _id:0}).limit(3)" | mongo  $HOSTDB/admin -u lodel2_admin -p lapwd  | sed "1,3d" | sed -e "s/{ \"lodel_id\" : //g" | sed -e "s/ }//g" | sed "\$d")
57 61
     for i in $persons
58 62
     do
59
-        if [ $tmp = "" ]
63
+        if [[ ! -z $tmp ]]
60 64
         then
61
-            tmp=$(printf("$tmp, $i"))
65
+            tmp=$(printf "$tmp, $i")
62 66
         else
63 67
             tmp=$i
64 68
         fi
65 69
     done
66 70
     SSSECLP=$tmp
67
-    SSSECST=$(lenmax=120;wcount=10; rlenmax=$(expr $lenmax - 1); echo $(shuf /usr/share/dict/words | head -n $wcount | tr -s "\n" " ") | sed -E "s/^(.{$rlenmax}).*$/\1/")
68
-    res=$(printf "use lodel2\ndb.Section.find\({}, {lodel_id:1, _id:0}\).limit\(1\)" | mongo  HOSTDB/admin -u lodel_admin -p lapwd  | sed "1,3d" | sed -e "s/{ \"lodel_id\" : //g" | sed -e "s/ }//g" | sed '\$d')
71
+    SSSECST=$(lenmax=60;wcount=10; rlenmax=$(expr $lenmax - 1); echo $(shuf /usr/share/dict/words | head -n $wcount | tr -s "\n" " ") | sed -E "s/^(.{$rlenmax}).*$/\1/")
72
+    res=$(printf "use lodel2_$instance\n db.Section.find({}, {lodel_id:1, _id:0}).limit(1)" | mongo  $HOSTDB/admin -u lodel2_admin -p lapwd  | sed "1,3d" | sed -e "s/{ \"lodel_id\" : //g" | sed -e "s/ }//g" | sed "\$d")
69 73
     SSSECPAR=$res
70
-    res=$(printf "use lodel2\ndb.Indextheme.find\({}, {lodel_id:1, _id:0}\).limit\(3\)" | mongo  HOSTDB/admin -u lodel_admin -p lapwd  | sed "1,3d" | sed -e "s/{ \"lodel_id\" : //g" | sed -e "s/ }//g" | sed '\$d')
74
+    res=$(printf "use lodel2_$instance\n db.Indextheme.find({}, {lodel_id:1, _id:0}).limit(3)" | mongo  $HOSTDB/admin -u lodel2_admin -p lapwd  | sed "1,3d" | sed -e "s/{ \"lodel_id\" : //g" | sed -e "s/ }//g" | sed "\$d")
71 75
     tmp=""
72 76
     for i in $res
73 77
     do
74
-        if [ $tmp = "" ]
78
+        if [[ ! -z $tmp ]]
75 79
         then
76
-            tmp=$(printf("$tmp, $i"))
80
+            tmp=$(printf "$tmp, $i")
77 81
         else
78 82
             tmp=$i
79 83
         fi    
80 84
     SSSECIND=$tmp
81
-    SSSECTTL=$(lenmax=100;wcount=5; rlenmax=$(expr $lenmax - 1); echo $(shuf /usr/share/dict/words | head -n $wcount | tr -s "\n" " ") | sed -E "s/^(.{$rlenmax}).*$/\1/")
82
-    res=$(printf "use lodel2\ndb.Collection.find\({}, {lodel_id:1, _id:0}\).limit\(1\)" | mongo  HOSTDB/admin -u lodel_admin -p lapwd  | sed "1,3d" | sed -e "s/{ \"lodel_id\" : //g" | sed -e "s/ }//g" | sed '\$d')
85
+    SSSECTTL=$(lenmax=60;wcount=5; rlenmax=$(expr $lenmax - 1); echo $(shuf /usr/share/dict/words | head -n $wcount | tr -s "\n" " ") | sed -E "s/^(.{$rlenmax}).*$/\1/")
86
+    res=$(printf "use lodel2_$instance\n db.Collection.find({}, {lodel_id:1, _id:0}).limit\(1\)" | mongo  $HOSTDB/admin -u lodel2_admin -p lapwd  | sed "1,3d" | sed -e "s/{ \"lodel_id\" : //g" | sed -e "s/ }//g" | sed "\$d")
83 87
     PUBCOLLS=$res
84 88
     curl -A "Mozilla/5.0" -L -s -d "field_input_linked_persons=$SSSECLP&field_input_subtitle=$SSSECST&field_input_parent=$SSSECPAR&field_input_indexes=$SSSECIND&field_input_title=$SSSECTTL&classname=Subsection" http://$host/$instance/admin/create?classname=Subsection
85 89
 curl -A "Mozilla/5.0" -L -s -d "field_input_collection=$PUBCOLLS&classname=Publication" http://$host/$instance/admin/create?classname=Publication

+ 9
- 5
progs/create_datas.sh View File

@@ -3,10 +3,12 @@
3 3
 host=$1
4 4
 instance=$2
5 5
 N=$3
6
-HOSTDB=localhost:27017
6
+HOSTDB=localhost
7 7
 
8
-for i in ${1..$N..10)
8
+M=$(expr $N / 10)
9
+for i in `eval echo {1..$M}`;
9 10
 do
11
+    COLPUBLI=""
10 12
     COLT=$(lenmax=100;wcount=5; rlenmax=$(expr $lenmax - 1); echo $(shuf /usr/share/dict/words | head -n $wcount | tr -s "\n" " ") | sed -E "s/^(.{$rlenmax}).*$/\1/") 
11 13
     curl -A "Mozilla/5.0" -L -s -d "field_input_title=$COLT&field_input_publications=$COLPUBLI&classname=Collection" http://$host/$instance/admin/create?classname=Collection
12 14
     ITTHM="themetest"
@@ -21,9 +23,10 @@ do
21 23
     curl -A "Mozilla/5.0" -L -s -d "field_input_lastname=$LN&field_input_firstname=$FN&field_input_password=$PWD&field_input_login=$LOGIN&classname=User" http://$host/$instance/admin/create?classname=User
22 24
 done
23 25
 
24
-for i in ${1..$N..4)
26
+M=$(expr $N / 4)
27
+for i in `eval echo {1..$M}`;
25 28
 do
26
-    persons=$(printf "use lodel2\ndb.Person.find\({}, {lodel_id:1, _id:0}\).limit\(3\)" | mongo  HOSTDB/admin -u lodel_admin -p lapwd  | sed "1,3d" | sed -e "s/{ \"lodel_id\" : //g" | sed -e "s/ }//g" | sed '\$d')
29
+    persons=$(printf "use lodel2_$instance\n db.Person.find({}, {lodel_id:1, _id:0}).limit(3)" | mongo  $HOSTDB/admin -u lodel2_admin -p lapwd | sed "1,3d" | sed -e "s/{ \"lodel_id\" : //g" | sed -e "s/ }//g" | sed "\$d")
27 30
     tmp=""
28 31
     for i in $persons
29 32
     do
@@ -46,12 +49,13 @@ do
46 49
         else
47 50
             tmp=$i
48 51
         fi
52
+    done
49 53
     SECIND=$tmp
50 54
     SECTTL=$(lenmax=100;wcount=5; rlenmax=$(expr $lenmax - 1); echo $(shuf /usr/share/dict/words | head -n $wcount | tr -s "\n" " ") | sed -E "s/^(.{$rlenmax}).*$/\1/")
51 55
     curl -A "Mozilla/5.0" -L -s -d "field_input_linked_persons=$SECLP&field_input_subtitle=$SECST&field_input_indexes=$SECIND&field_input_title=$SECTTL&classname=Section" http://$host/$instance/admin/create?classname=Section
52 56
 done
53 57
 
54
-for i in ${seq $N}
58
+for i in `eval echo {1..$N}`;
55 59
 do
56 60
     persons=$(printf "use lodel2\ndb.Person.find\({}, {lodel_id:1, _id:0}\).limit\(3\)" | mongo  HOSTDB/admin -u lodel_admin -p lapwd  | sed "1,3d" | sed -e "s/{ \"lodel_id\" : //g" | sed -e "s/ }//g" | sed '\$d')
57 61
     for i in $persons

Loading…
Cancel
Save