gestion 1.9.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (233) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +48 -0
  3. data/.project +14 -0
  4. data/Binaries/adduser_to_buzz +15 -0
  5. data/Binaries/backup +7 -0
  6. data/Binaries/check_gestion +8 -0
  7. data/Binaries/gestion.gnumail +22 -0
  8. data/Binaries/gestion.logrotate +34 -0
  9. data/Binaries/gestion.service +12 -0
  10. data/Binaries/gestion_update.rb +183 -0
  11. data/Binaries/gestion_update.service +10 -0
  12. data/Binaries/get_compta +11 -0
  13. data/Binaries/kill_gestion +16 -0
  14. data/Binaries/ldap/add_indexes +51 -0
  15. data/Binaries/ldap/backup +2 -0
  16. data/Binaries/ldap/install_ldap +92 -0
  17. data/Binaries/ldap/restore +7 -0
  18. data/Binaries/lib_backup +5 -0
  19. data/Binaries/log_scan_errors +8 -0
  20. data/Binaries/loop_gestion +64 -0
  21. data/Binaries/onetimers/sync_courses_from_compta.rb +74 -0
  22. data/Binaries/onetimers/transfer_cash_from_ldap_to_csv +26 -0
  23. data/Binaries/reboot +5 -0
  24. data/Binaries/restore +3 -0
  25. data/Binaries/restore_do +22 -0
  26. data/Binaries/sort_events +31 -0
  27. data/Binaries/start_gestion +18 -0
  28. data/Binaries/swipe_gestion +18 -0
  29. data/Binaries/update_africompta +21 -0
  30. data/Binaries/update_users +3 -0
  31. data/Diplomas.src/accredited.odg +0 -0
  32. data/Diplomas.src/diploma.odg +0 -0
  33. data/Diplomas.src/label.odg +0 -0
  34. data/Diplomas.src/presence_sheet.ods +0 -0
  35. data/Diplomas.src/presence_sheet_small.ods +0 -0
  36. data/Diplomas.src/student_card.odg +0 -0
  37. data/Doc/130514-it-ideas.odt +0 -0
  38. data/Doc/Compta-cash.mm +179 -0
  39. data/Doc/General.odt +0 -0
  40. data/Entities/AccessGroups.rb +117 -0
  41. data/Entities/Activity.rb +178 -0
  42. data/Entities/ChatMsg.rb +142 -0
  43. data/Entities/Classroom.rb +11 -0
  44. data/Entities/Client.rb +19 -0
  45. data/Entities/Computer.rb +21 -0
  46. data/Entities/ConfigBase.rb +280 -0
  47. data/Entities/Course.rb +1588 -0
  48. data/Entities/CourseType.rb +171 -0
  49. data/Entities/DFiles.rb +466 -0
  50. data/Entities/FilesManage.rb +226 -0
  51. data/Entities/Grade.rb +186 -0
  52. data/Entities/Internet.rb +300 -0
  53. data/Entities/Netdev.rb +10 -0
  54. data/Entities/Person.rb +1175 -0
  55. data/Entities/Plug.rb +98 -0
  56. data/Entities/Quiz.rb +33 -0
  57. data/Entities/Recharges.rb +37 -0
  58. data/Entities/Report.rb +136 -0
  59. data/Entities/Room.rb +12 -0
  60. data/Entities/SMS.rb +30 -0
  61. data/Entities/ScheduleType.rb +33 -0
  62. data/Entities/Share.rb +120 -0
  63. data/Entities/Task.rb +51 -0
  64. data/Entities/Ticket.rb +72 -0
  65. data/Entities/Usage.rb +143 -0
  66. data/Entities/Worker.rb +29 -0
  67. data/Files/apache-profeda.conf +36 -0
  68. data/Files/label.erb +121 -0
  69. data/Files/label_notfound.erb +64 -0
  70. data/Files/label_notpassed.erb +84 -0
  71. data/Files/mobileinfo.erb +115 -0
  72. data/Files/smb.conf +333 -0
  73. data/Files/timetable.html +36 -0
  74. data/Files/timetable.js +239 -0
  75. data/Gemfile +12 -0
  76. data/Gemfile.dev +12 -0
  77. data/Gemfile.dev.lock +127 -0
  78. data/Gemfile.lock +127 -0
  79. data/Gemfile.prod +8 -0
  80. data/Gestion +35 -0
  81. data/Gestion.rb +220 -0
  82. data/INSTALL +40 -0
  83. data/Images/connection.xcf +0 -0
  84. data/Images/connection_no.png +0 -0
  85. data/Images/connection_wait.png +0 -0
  86. data/Images/connection_yes.png +0 -0
  87. data/Paths/Exas.rb +13 -0
  88. data/Paths/Files.rb +19 -0
  89. data/Paths/GetDiplomas.rb +20 -0
  90. data/Paths/Info.rb +114 -0
  91. data/Paths/Label.rb +187 -0
  92. data/Paths/MobileInfo.rb +19 -0
  93. data/Paths/internetCash.rb +34 -0
  94. data/Paths/internetWifi.rb +54 -0
  95. data/README.md +60 -0
  96. data/Rakefile +13 -0
  97. data/TODO +1391 -0
  98. data/Test/.gitignore +3 -0
  99. data/Test/Diplomas/base_gestion.odt +0 -0
  100. data/Test/Diplomas/base_report.odt +0 -0
  101. data/Test/Diplomas/carte_etudiant.odg +0 -0
  102. data/Test/Diplomas/exam_language.odt +0 -0
  103. data/Test/Diplomas/label.odg +0 -0
  104. data/Test/Diplomas/presence_sheet.ods +0 -0
  105. data/Test/Diplomas/presence_sheet_small.ods +0 -0
  106. data/Test/Diplomas/student_card.odg +0 -0
  107. data/Test/Manual/testMerge +18 -0
  108. data/Test/config_test.yaml +26 -0
  109. data/Test/db.testGestion +0 -0
  110. data/Test/dfiles/descs/avg-rescue.desc +10 -0
  111. data/Test/dfiles/descs/avg.desc +8 -0
  112. data/Test/dfiles/descs/driver.desc +8 -0
  113. data/Test/dfiles/descs/linuxmint.desc +7 -0
  114. data/Test/dfiles/files/avg-160203.exe +1 -0
  115. data/Test/dfiles/files/avg.iso +1 -0
  116. data/Test/dfiles/files/driver.exe +1 -0
  117. data/Test/dfiles/index_post.html +3 -0
  118. data/Test/dfiles/index_pre.html +8 -0
  119. data/Test/dfiles/priorities +5 -0
  120. data/Test/ge_activity.rb +124 -0
  121. data/Test/ge_chat.rb +106 -0
  122. data/Test/ge_compta.rb +67 -0
  123. data/Test/ge_configbase.rb +54 -0
  124. data/Test/ge_course.rb +1114 -0
  125. data/Test/ge_dfiles.rb +121 -0
  126. data/Test/ge_filesmanage.rb +180 -0
  127. data/Test/ge_info.rb +27 -0
  128. data/Test/ge_internet.rb +246 -0
  129. data/Test/ge_login.rb +55 -0
  130. data/Test/ge_person.rb +373 -0
  131. data/Test/ge_qvinfo.rb +28 -0
  132. data/Test/ge_report.rb +97 -0
  133. data/Test/ge_share.rb +27 -0
  134. data/Test/ge_sms.rb +34 -0
  135. data/Test/ge_tasks.rb +19 -0
  136. data/Test/ge_usage.rb +168 -0
  137. data/Test/ge_view.rb +46 -0
  138. data/Test/multiconf-captive +29 -0
  139. data/Test/test.conf +7 -0
  140. data/Test/test.rb +49 -0
  141. data/Test/test_bytes.png +0 -0
  142. data/VERSION +140 -0
  143. data/Views/Admin/Backup.rb +91 -0
  144. data/Views/Admin/Configuration.rb +44 -0
  145. data/Views/Admin/Credit.rb +32 -0
  146. data/Views/Admin/FilesManage.rb +219 -0
  147. data/Views/Admin/Function.rb +39 -0
  148. data/Views/Admin/Power.rb +49 -0
  149. data/Views/Admin/Printer.rb +37 -0
  150. data/Views/Admin/Server.rb +252 -0
  151. data/Views/Admin/Tabs.rb +5 -0
  152. data/Views/Admin/Update.rb +73 -0
  153. data/Views/Admin/UpdateSystem.rb +26 -0
  154. data/Views/Cashbox/Activity.rb +191 -0
  155. data/Views/Cashbox/Course.rb +141 -0
  156. data/Views/Cashbox/Credit.rb +79 -0
  157. data/Views/Cashbox/Report.rb +115 -0
  158. data/Views/Cashbox/Service.rb +105 -0
  159. data/Views/Cashbox/Tabs.rb +10 -0
  160. data/Views/Compta/Accounts.rb +36 -0
  161. data/Views/Compta/Course.rb +96 -0
  162. data/Views/Compta/Show.rb +6 -0
  163. data/Views/Compta/Transfer.rb +66 -0
  164. data/Views/Course/Diploma.rb +203 -0
  165. data/Views/Course/Grade.rb +401 -0
  166. data/Views/Course/Modify.rb +447 -0
  167. data/Views/Course/Print.rb +94 -0
  168. data/Views/Course/Responsible.rb +44 -0
  169. data/Views/Course/Stats.rb +76 -0
  170. data/Views/Course/Students.rb +92 -0
  171. data/Views/Course/Tabs.rb +220 -0
  172. data/Views/Internet/Access.rb +134 -0
  173. data/Views/Internet/ClassEdit.rb +24 -0
  174. data/Views/Internet/ClassUsers.rb +81 -0
  175. data/Views/Internet/Config.rb +32 -0
  176. data/Views/Internet/Mobile.rb +213 -0
  177. data/Views/Internet/Recharges.rb +49 -0
  178. data/Views/Internet/Tabs.rb +6 -0
  179. data/Views/Inventory/Computer.rb +24 -0
  180. data/Views/Inventory/Room.rb +18 -0
  181. data/Views/Inventory/Tabs.rb +9 -0
  182. data/Views/Inventory/TicketClosed.rb +7 -0
  183. data/Views/Inventory/TicketOpen.rb +23 -0
  184. data/Views/Library/Person.rb +36 -0
  185. data/Views/Library/Tabs.rb +7 -0
  186. data/Views/Network/Block.rb +87 -0
  187. data/Views/Network/Netdevs.rb +21 -0
  188. data/Views/Network/Restriction.rb +37 -0
  189. data/Views/Network/Share.rb +167 -0
  190. data/Views/Network/Tables.rb +28 -0
  191. data/Views/Network/Tabs.rb +6 -0
  192. data/Views/Person/Admin.rb +99 -0
  193. data/Views/Person/Center.rb +48 -0
  194. data/Views/Person/Course.rb +72 -0
  195. data/Views/Person/Modify.rb +153 -0
  196. data/Views/Person/Tabs.rb +162 -0
  197. data/Views/Report/ComptaExecutive.rb +221 -0
  198. data/Views/Report/ComptaFlat.rb +79 -0
  199. data/Views/Report/ReportCourse.rb +47 -0
  200. data/Views/Report/Tabs.rb +8 -0
  201. data/Views/Report/Usage.rb +52 -0
  202. data/Views/Report/UsageCases.rb +59 -0
  203. data/Views/Self/Cash.rb +67 -0
  204. data/Views/Self/Chat.rb +55 -0
  205. data/Views/Self/Concours.rb +109 -0
  206. data/Views/Self/Email.rb +34 -0
  207. data/Views/Self/Internet.rb +255 -0
  208. data/Views/Self/Results.rb +17 -0
  209. data/Views/Self/Services.rb +85 -0
  210. data/Views/Self/Show.rb +47 -0
  211. data/Views/Self/Tabs.rb +5 -0
  212. data/Views/Special/DFileEdit.rb +13 -0
  213. data/Views/Special/PlugEdit.rb +56 -0
  214. data/Views/Special/Tabs.rb +6 -0
  215. data/Views/Special/Vnc.rb +39 -0
  216. data/Views/Task/Client.rb +21 -0
  217. data/Views/Task/Edit.rb +33 -0
  218. data/Views/Task/List.rb +55 -0
  219. data/Views/Task/Tabs.rb +9 -0
  220. data/Views/Task/Worker.rb +30 -0
  221. data/Views/Template/Activity.rb +33 -0
  222. data/Views/Template/CourseType.rb +63 -0
  223. data/Views/Template/ScheduleType.rb +29 -0
  224. data/Views/Template/Tabs.rb +5 -0
  225. data/Views/Welcome.rb +121 -0
  226. data/config.yaml.default +36 -0
  227. data/po/Gestion-ar.po +2356 -0
  228. data/po/Gestion-en.mo +0 -0
  229. data/po/Gestion-en.po +4363 -0
  230. data/po/Gestion-fr.mo +0 -0
  231. data/po/Gestion-fr.po +4345 -0
  232. data/po/traduction-ar.rtf +76 -0
  233. metadata +381 -0
data/Test/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ descs.save
2
+ dfiles
3
+ *.test
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,18 @@
1
+ #!/bin/bash
2
+
3
+ killall ruby
4
+ if pgrep ruby > /dev/null; then
5
+ echo Waiting 5 seconds before termination
6
+ sleep 5
7
+ killall -9 ruby
8
+ fi
9
+ cd $( dirname $0 )/../..
10
+
11
+ cp Test/db.testGestion data/compta.db
12
+ ./Gestion &
13
+ sleep 5
14
+ return
15
+
16
+ cd ../AfriCompta
17
+ cp db.testGestion.orig db.testGestion
18
+ ./startAfriCompta testGestion
@@ -0,0 +1,26 @@
1
+ StorageType:
2
+ CSV:
3
+ csv_dir: ./data2/
4
+
5
+ #autologin: linus
6
+ #autologin: admin
7
+
8
+ title: "Gestion du Markas-al-Nour"
9
+
10
+ log: events.log
11
+
12
+ StorageHandler:
13
+ Replace:
14
+ LDAP: CSV
15
+
16
+ LibNet:
17
+ simulation: true
18
+
19
+ Entities:
20
+ Persons:
21
+ user_simulation: true
22
+
23
+ Accounting:
24
+ lending: Root::Lending
25
+ cash: Root::Cash
26
+ service: Root::Income::Internet
Binary file
@@ -0,0 +1,10 @@
1
+ http://avg-rescue/avg.iso
2
+ http://avg.com
3
+
4
+ ISO-image for rescue
5
+
6
+ 5 windows
7
+ 3 antivirus
8
+ 3 avg
9
+ 3 iso
10
+ 1 rescue
@@ -0,0 +1,8 @@
1
+ :avg-160203.exe:http://avg.com/avg.exe
2
+ http://avg.com
3
+
4
+ AVG antivirus from 3rd of February 2016
5
+
6
+ 2 windows
7
+ 2 antivirus
8
+ 1 avg
@@ -0,0 +1,8 @@
1
+ http://hp.com/driver.exe
2
+ http://hp.com
3
+
4
+ Mouse-driver from HP
5
+
6
+ 1 windows
7
+ 2 drivers
8
+ 2 mouse
@@ -0,0 +1,7 @@
1
+ http://linuxmint.org/linuxmint-17.iso
2
+ http://linuxmint.org
3
+
4
+ Linuxmint 17 ISO
5
+
6
+ 1 linux
7
+ 2 iso
@@ -0,0 +1 @@
1
+ This is a test-file
@@ -0,0 +1 @@
1
+ This is a test-file with some more text...
@@ -0,0 +1 @@
1
+ a small driver-file
@@ -0,0 +1,3 @@
1
+ </div>
2
+ </body>
3
+ </html>
@@ -0,0 +1,8 @@
1
+ <!DOCTYPE html>
2
+ <html lang="fr">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title></title>
6
+ </head>
7
+ <body>
8
+ <div class="main">
@@ -0,0 +1,5 @@
1
+ SIZE=10G
2
+ 1 windows
3
+ 2 windows antivirus
4
+ 8 medias
5
+ 9 windows avg iso
@@ -0,0 +1,124 @@
1
+ require 'test/unit'
2
+
3
+ class TC_Activity < Test::Unit::TestCase
4
+
5
+ def setup
6
+ Entities.delete_all_data
7
+ dputs(1) { 'Resetting SQLite' }
8
+ SQLite.dbs_close_all
9
+ FileUtils.cp('db.testGestion', 'data/compta.db')
10
+ SQLite.dbs_open_load_migrate
11
+ ConfigBase.store({functions:%w(accounting library)})
12
+ ConfigBases.init_load
13
+
14
+ @library = Activities.create(name: 'library', cost: 3_000,
15
+ payment_period: %w(yearly), start_type: %w(period_overlap),
16
+ card_filename: %w( carte_etudiant.odg ),
17
+ tags: [:library])
18
+ @internet = Activities.create(name: 'internet', cost: 10_000,
19
+ payment_period: %w(monthly), start_type: %w(payment),
20
+ card_filename: %w( carte_etudiant.odg),
21
+ tags: [:internet])
22
+ @library_plus = Activities.create(name: 'library_internet', cost: 20_000,
23
+ payment_period: %w(monthly), start_type: %w(payment),
24
+ card_filename: %w( carte_etudiant.odg),
25
+ tags: [:internet, :library])
26
+
27
+ @admin = Persons.create(login_name: 'admin', permissions: %w(admin))
28
+ @secretary = Persons.create(login_name: 'secretary', permissions: %w(secretary))
29
+ @accountant = Persons.create(login_name: 'accountant', permissions: %w(accountant))
30
+ @student_1 = Persons.create(login_name: 'student1', permissions: %w(student))
31
+ @student_2 = Persons.create(login_name: 'student2', permissions: %w(student))
32
+
33
+ ConfigBase.account_activities = Accounts.create_path('Root::Income::Activities')
34
+ end
35
+
36
+ def teardown
37
+ end
38
+
39
+ def test_period
40
+ # Friday 10th of October 2014
41
+ d = Date.new(2014, 10, 10)
42
+ d_week = Date.new(2014, 10, 5)
43
+ d_month = Date.new(2014, 10)
44
+ d_year = Date.new(2014)
45
+ assert_equal [d, d], ActivityPayments.get_period(d, :daily, 0)
46
+ assert_equal [d-1, d], ActivityPayments.get_period(d, :daily, 1)
47
+ assert_equal [d_week, d_week + 6], ActivityPayments.get_period(d, :weekly, 0)
48
+ assert_equal [d_week, d_week + 6], ActivityPayments.get_period(d, :weekly, 1)
49
+ assert_equal [d, d_week + 13], ActivityPayments.get_period(d, :weekly, 2)
50
+ assert_equal [d_month, d_month.next_month - 1],
51
+ ActivityPayments.get_period(d, :monthly, 0)
52
+ assert_equal [d_month, d_month.next_month - 1],
53
+ ActivityPayments.get_period(d, :monthly, 1)
54
+ assert_equal [d_month, d_month.next_month - 1],
55
+ ActivityPayments.get_period(d, :monthly, 2)
56
+ assert_equal [d_month, d_month.next_month - 1],
57
+ ActivityPayments.get_period(d, :monthly, 3)
58
+ assert_equal [d, d_month.next_month(2) - 1],
59
+ ActivityPayments.get_period(d, :monthly, 4)
60
+ assert_equal [d_year, d_year.next_year - 1],
61
+ ActivityPayments.get_period(d, :yearly, 0)
62
+ assert_equal [d_year, d_year.next_year - 1],
63
+ ActivityPayments.get_period(d, :yearly, 1)
64
+ assert_equal [d_year, d_year.next_year - 1],
65
+ ActivityPayments.get_period(d, :yearly, 2)
66
+ assert_equal [d, d_year.next_year(2) - 1],
67
+ ActivityPayments.get_period(d, :yearly, 3)
68
+ end
69
+
70
+ def test_add_payment
71
+ d = Date.new(2014, 10, 10)
72
+ d_week = Date.new(2014, 10, 5)
73
+ d_month = Date.new(2014, 10)
74
+ d_year = Date.new(2014)
75
+
76
+ pay1 = ActivityPayments.pay(@library, @student_1, @secretary, d)
77
+ pay2 = ActivityPayments.pay(@internet, @student_1, @secretary, d)
78
+ pay3 = ActivityPayments.pay(@internet, @student_2, @secretary, d)
79
+
80
+ assert_equal [@library, @internet],
81
+ ActivityPayments.active_for(@student_1, d).collect { |ap|
82
+ ap.activity }
83
+ assert_equal [@internet],
84
+ ActivityPayments.active_for(@student_2, d).collect { |ap|
85
+ ap.activity }
86
+ assert_equal [], ActivityPayments.active_for(@student_2, d.yesterday)
87
+ assert_equal [nil, nil], @library.start_end(@student_2, d)
88
+ assert_equal [d_year, d_year.next_year - 1], @library.start_end(@student_1, d)
89
+ end
90
+
91
+ def test_rm_payment
92
+ d = Date.new(2014, 10, 10)
93
+ d_year = Date.new(2014)
94
+
95
+ ActivityPayments.pay(@internet, @student_1, @secretary, d.months_ago(1))
96
+ pay = ActivityPayments.pay(@internet, @student_1, @secretary, d)
97
+
98
+ assert_equal d, @internet.start_end(@student_1, d)[0]
99
+ pay.delete
100
+ assert_equal [nil, nil], @internet.start_end(@student_1, d)
101
+ ActivityPayments.pay(@internet, @student_1, @secretary, d)
102
+ assert_equal d, @internet.start_end(@student_1, d)[0]
103
+ end
104
+
105
+ def test_print
106
+ pay1 = ActivityPayments.pay(@library, @student_1, @secretary)
107
+ assert pay1.print
108
+ end
109
+
110
+ def test_tags
111
+ assert_equal [@internet, @library_plus], Activities.tagged(:internet)
112
+ assert_equal [@library, @library_plus], Activities.tagged(:library)
113
+ assert_equal [@library_plus], Activities.tagged(:library, :internet)
114
+ assert_equal [], Activities.tagged(:club)
115
+
116
+ assert_equal [], Activities.tagged_users( :library )
117
+
118
+ d = Date.new(2014, 10, 10)
119
+ pay1 = ActivityPayments.pay(@library, @student_1, @secretary, d)
120
+ pay2 = ActivityPayments.pay(@internet, @student_1, @secretary, d)
121
+ pay3 = ActivityPayments.pay(@internet, @student_2, @secretary, d)
122
+ assert_equal [@student_1], Activities.tagged_users( :library, Date.new(2014) )
123
+ end
124
+ end
data/Test/ge_chat.rb ADDED
@@ -0,0 +1,106 @@
1
+ require 'test/unit'
2
+
3
+ class TC_Chat < Test::Unit::TestCase
4
+
5
+ def setup
6
+ Entities.delete_all_data
7
+ @admin = Persons.create(login_name: 'admin', permissions: %w(admin))
8
+ @center1 = Persons.create(login_name: 'center1', permissions: %w(center),
9
+ password: '123')
10
+ @clogin1 = {center: {login: 'center1', pass: '123'}}
11
+ @center2 = Persons.create(login_name: 'center2', permissions: %w(center),
12
+ password: '123')
13
+ @clogin2 = {center: {login: 'center2', pass: '123'}}
14
+ @secretary = Persons.create(login_name: 'secretary', permissions: %w(secretary))
15
+ @accountant = Persons.create(login_name: 'accountant', permissions: %w(accountant))
16
+ @student_1 = Persons.create(login_name: 'student1', permissions: %w(student))
17
+ @student_2 = Persons.create(login_name: 'student2', permissions: %w(student))
18
+
19
+ ConfigBase.add_function(:course_server)
20
+ ConfigBase.server_url = 'localhost:3302/icc'
21
+ end
22
+
23
+ def teardown
24
+ end
25
+
26
+ def with_server
27
+ ConfigBase.block_size = 4096
28
+
29
+ @port = 3302
30
+ @url = "http://localhost:#{@port}/icc"
31
+ @main = Thread.new {
32
+ QooxView::startWeb(@port)
33
+ }
34
+ dputs(1) { "Starting at port #{@port}" }
35
+ sleep 1
36
+
37
+ yield @port, @url, @main
38
+
39
+ @main.kill.join
40
+ end
41
+
42
+ def test_push
43
+ ChatMsgs.icc_msg_push(center: {login: 'center1', pass: ''})
44
+ assert_equal '', ChatMsgs.show_list
45
+ @center1.permissions = []
46
+ ChatMsgs.icc_msg_push(@clogin1.merge(person: 'foo', msg: 'hi there'))
47
+ assert_equal '', ChatMsgs.show_list
48
+
49
+ @center1.permissions = %w(center)
50
+ ChatMsgs.icc_msg_push(@clogin1.merge(person: 'foo', msg: 'hi there'))
51
+ assert_match( / - foo@center1: hi there$/, ChatMsgs.show_list)
52
+ end
53
+
54
+ def chat_format(r)
55
+ r.select { |k| k == :msg || k == :center || k == :login }
56
+ end
57
+
58
+ def test_pull
59
+ assert ChatMsgs.icc_msg_pull(center: {login: 'center1', pass: ''}) =~ /^Error:/
60
+ @center1.permissions = []
61
+ assert ChatMsgs.icc_msg_pull(@clogin1) =~ /^Error:/
62
+ @center1.permissions = %w(center)
63
+ assert !(ChatMsgs.icc_msg_pull(@clogin1) =~ /^Error:/)
64
+
65
+ assert_equal [], ChatMsgs.icc_msg_pull(@clogin2)
66
+ ChatMsgs.icc_msg_push(@clogin1.merge({person: 'foo', msg: 'hello1'}))
67
+ assert_equal({msg: 'hello1', center: 'center1', login: 'foo'},
68
+ chat_format(ChatMsgs.icc_msg_pull(@clogin2).first))
69
+ end
70
+
71
+ def test_pull_multi
72
+ assert_equal [], ChatMsgs.icc_msg_push(@clogin1.merge({person: 'foo', msg: 'hello1'}))
73
+ ret = ChatMsgs.icc_msg_push(@clogin2.merge({person: 'foo', msg: 'hello2'}))
74
+ assert_equal({msg: 'hello1', center: 'center1', login: 'foo'},
75
+ chat_format(ret.first))
76
+ assert_equal({msg: 'hello2', center: 'center2', login: 'foo'},
77
+ chat_format(ChatMsgs.icc_msg_pull(@clogin1).first))
78
+ end
79
+
80
+ def test_time_storage
81
+ ChatMsgs.icc_msg_push(@clogin1.merge({person: 'foo', msg: 'hello1'}))
82
+ assert_equal({msg: 'hello1', center: 'center1', login: 'foo'},
83
+ chat_format(ChatMsgs.icc_msg_pull(@clogin2).first))
84
+ assert_equal [], ChatMsgs.icc_msg_pull(@clogin2)
85
+ assert ChatMsgs.show_list
86
+
87
+ ChatMsgs.icc_msg_push(@clogin1.merge({person: 'foo', msg: 'hello1'}))
88
+ ChatMsgs.search_all_.first.time = ChatMsgs.search_all_.first.time.inspect
89
+ assert_equal({msg: 'hello1', center: 'center1', login: 'foo'},
90
+ chat_format(ChatMsgs.icc_msg_pull(@clogin2).first))
91
+ assert_equal [], ChatMsgs.icc_msg_pull(@clogin2)
92
+ assert ChatMsgs.show_list
93
+ end
94
+
95
+ def center_hash
96
+ return {} unless center = Persons.center
97
+ {center: {login: center.login_name, pass: center.password_plain}}
98
+ end
99
+
100
+ def test_new_msg_send
101
+ ChatMsgs.new_msg_send('foo', 'hello')
102
+ assert_equal( {:msg=> 'hello', :center=>[nil], :login=> 'foo'},
103
+ chat_format(ChatMsgs.search_all.first.to_hash))
104
+ end
105
+
106
+ end
data/Test/ge_compta.rb ADDED
@@ -0,0 +1,67 @@
1
+ require 'test/unit'
2
+ #require 'FileUtils'
3
+
4
+
5
+ class TC_Compta < Test::Unit::TestCase
6
+
7
+ def setup
8
+ # Permission.add( 'default', '.*' )
9
+ Permission.add( 'student', '.*' )
10
+ Permission.add( 'teacher', '.*' )
11
+ Permission.add( 'secretary', 'Cashbox.*')
12
+ # Entities.delete_all_data()
13
+
14
+ dputs(1){ 'Resetting SQLite' }
15
+ SQLite.dbs_close_all
16
+ FileUtils.cp( 'db.testGestion', 'data/compta.db')
17
+ SQLite.dbs_open_load_migrate
18
+
19
+ @admin = Entities.Persons.create( :login_name => 'admin', :password => 'super123',
20
+ :permissions => %w(default teacher), :first_name => 'Admin', :family_name => 'The')
21
+ @secretaire = Entities.Persons.create( :login_name => 'secretaire', :password => 'super',
22
+ :permissions => %w(default teacher secretary), :first_name => 'Le', :family_name => 'Secretaire')
23
+ @surf = Entities.Persons.create( :login_name => 'surf', :password => 'super',
24
+ :permissions => ['default'], :first_name => 'Internet', :family_name => 'Surfer')
25
+ @net = Entities.Courses.create( :name => 'net_1001')
26
+ @base = Entities.Courses.create( :name => 'base_1004')
27
+ @maint = Entities.Courses.create( :name => 'maint_1204', :start => '19.01.2012', :end => '18.02.2012',
28
+ :dow => 'lu-ve', :teacher => @secretaire )
29
+ @maint.students = %w( admin surf )
30
+ @base.students = %w( admin2 surf )
31
+ @maint_t = Entities.CourseTypes.create( :name => 'maint', :duration => 72,
32
+ :desciption => 'maintenance', :contents => 'lots of work',
33
+ :file_diploma => ['base_gestion.odt'], :output => 'certificate',
34
+ :diploma_type => ['simple'])
35
+ @maint_2 = Courses.create( :name => 'maint_1210', :start => '1.10.2012',
36
+ :end => '1.1.2013', :sign => '2.1.2012', :teacher => @secretaire,
37
+ :contents => 'lots of work', :description => 'maintenance',
38
+ :duration => 72, :responsible => @secretaire,
39
+ :ctype => @maint_t )
40
+
41
+ @it_101_t = CourseTypes.create( :name => 'it-101', :diploma_type => ['accredited'],
42
+ :output => %w( label ), :file_diploma => %w( label.odg ),
43
+ :contents => 'it-101', :description => 'windows, word, excel')
44
+ @it_101 = Courses.create_ctype( @it_101_t, '1203')
45
+ @it_101.data_set_hash( :responsible => @secretaire, :teacher => @surf,
46
+ :start => '1.11.2012', :end => '1.2.2013', :sign => '10.2.2013',
47
+ :students => %w( secretaire surf ) )
48
+ @center = Persons.create( :login_name => 'foo', :permissions => ['center'],
49
+ :address => 'B.P. 1234', :town => 'Sansibar',
50
+ :phone => '+23599999999', :email => 'profeda@gmail.com')
51
+ @center.password = @center.password_plain = '1234'
52
+
53
+ Sessions.create( @admin, 'default')
54
+
55
+ end
56
+
57
+ def teardown
58
+ permissions_init
59
+ end
60
+
61
+ def test_account_due
62
+ assert_equal nil, @secretaire.account_due
63
+ dputs(1){"#{@secretaire}"}
64
+ ConfigBase.add_function(:cashbox)
65
+ assert_not_equal nil, @secretaire.account_due
66
+ end
67
+ end
@@ -0,0 +1,54 @@
1
+ require 'test/unit'
2
+
3
+
4
+ class TC_Configbase < Test::Unit::TestCase
5
+ def setup
6
+ Entities.load_all
7
+ end
8
+
9
+ def teardown
10
+ end
11
+
12
+ def test_migration_5
13
+ Entities.delete_all_data
14
+
15
+ FileUtils.mkdir_p 'data2'
16
+ IO.write 'data2/MigrationVersions.csv',
17
+ '{"migrationversion_id":1,"class_name":"ConfigBases","version":4}' +
18
+ "\n"
19
+ IO.write 'data2/ConfigBases.csv',
20
+ '{"configbase_id":1,"functions":[]}' +
21
+ "\n"
22
+ Entities.load_all
23
+ check = [
24
+ [ConfigBase.account_cash, 'Root::Cash', -1],
25
+ [ConfigBase.account_lending, 'Root::Lending', -1],
26
+ [ConfigBase.account_services, 'Root::Income::Internet', 1]]
27
+ check.each { |acc, path, mult|
28
+ assert_equal path, acc.get_path
29
+ assert_equal mult, acc.multiplier
30
+ }
31
+ end
32
+
33
+ def test_delete_all
34
+ Entities.delete_all_data
35
+ assert ConfigBase.account_cash
36
+ end
37
+
38
+ def test_accounting
39
+ Entities.delete_all_data
40
+ Permission.add('cybermanager', 'CashboxCredit,FlagAddInternet,' +
41
+ 'FlagPersonAdd,CashboxService,InternetMobile,' +
42
+ 'CashboxActivity', '')
43
+ sec = Persons.create_person('secretary')
44
+ user = Persons.create_person('foo')
45
+ ConfigBase.add_function(:cashbox)
46
+ ConfigBase.add_function(:internet_cyber)
47
+ act = Activities.create(name: 'internet', cost: 1000, payment_period: [:daily],
48
+ start_type: [:payment], tags: [:internet])
49
+ sec.permissions += [:cybermanager]
50
+ d = Date.today()
51
+ ap = ActivityPayments.pay(act, user, sec, d)
52
+ assert_not_equal nil, ap
53
+ end
54
+ end