A web framework for aspiring media terrorists – PRE-ALPHA – DO NOT DEPLOY!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

fill.py 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. import math
  2. import random
  3. import example
  4. u = example.poobrains.auth.User.load('root')
  5. g = example.poobrains.auth.Group.load('administrators')
  6. def news():
  7. for i in range(0, 100):
  8. n = example.News()
  9. n.name = "test-%d" % i
  10. n.title = "Test #%d" % i
  11. n.text = "Blargh."
  12. n.owner = u
  13. n.group = g
  14. n.save()
  15. print("Saved News test-%d" % i)
  16. def datasets():
  17. sine = example.poobrains.svg.Dataset()
  18. sine.owner = u
  19. sine.group = g
  20. sine.name = 'sine'
  21. sine.title = 'Give me a sine'
  22. sine.description = 'And Eris spoke "Okay, I guess."'
  23. sine.label_x = 'Sine X'
  24. sine.label_y = 'Sine Y'
  25. sine.save()
  26. fucksgiven = example.poobrains.svg.Dataset()
  27. fucksgiven.owner = u
  28. fucksgiven.group = g
  29. fucksgiven.name = 'fucksgiven'
  30. fucksgiven.title = 'Fucks given'
  31. fucksgiven.description = "Fucks given over time"
  32. fucksgiven.label_x = "Time"
  33. fucksgiven.label_y = "Fucks given"
  34. fucksgiven.save()
  35. sine_steps = 33
  36. for i in range(0,sine_steps):
  37. dp = example.poobrains.svg.Datapoint()
  38. dp.dataset = sine
  39. dp.owner = u
  40. dp.group = g
  41. dp.x = i
  42. dp.y = math.sin(i/float(sine_steps-1) * 2 * math.pi)
  43. dp.save(force_insert=True)
  44. fuck = example.poobrains.svg.Datapoint()
  45. fuck.dataset = fucksgiven
  46. fuck.owner = u
  47. fuck.group = g
  48. fuck.x = i
  49. fuck.y = random.randint(-100,100) / 100.0
  50. if fuck.y < 0:
  51. fuck.error_upper = abs(fuck.y)
  52. else:
  53. fuck.error_lower = abs(fuck.y)
  54. fuck.save(force_insert=True)
  55. cont_a = example.poobrains.svg.Dataset()
  56. cont_a.owner = u
  57. cont_a.group = g
  58. cont_a.name = 'cont_a'
  59. cont_a.title = 'Continued thingie A'
  60. cont_a.description = "The first of a two part plot thingamabob"
  61. cont_a.label_x = "Florp"
  62. cont_a.label_y = "Plonk"
  63. cont_a.save()
  64. for i in range(-23, 6):
  65. dp = example.poobrains.svg.Datapoint()
  66. dp.dataset = cont_a
  67. dp.owner = u
  68. dp.group = g
  69. dp.x = i
  70. dp.y = random.random()
  71. dp.save(force_insert=True)
  72. cont_b = example.poobrains.svg.Dataset()
  73. cont_b.owner = u
  74. cont_b.group = g
  75. cont_b.name = 'cont_b'
  76. cont_b.title = 'Continued thingie B'
  77. cont_b.description = "The **second** part of a two part plot thingamabob"
  78. cont_b.label_x = "Florp"
  79. cont_b.label_y = "Plonk"
  80. cont_b.save()
  81. for i in range(2, 24):
  82. dp = example.poobrains.svg.Datapoint()
  83. dp.dataset = cont_b
  84. dp.owner = u
  85. dp.group = g
  86. dp.x = i
  87. dp.y = random.random()
  88. dp.save(force_insert=True)
  89. def map():
  90. m = example.poobrains.svg.MapDataset()
  91. m.owner = u
  92. m.group = g
  93. m.name = 'grid'
  94. m.title = 'Grid'
  95. m.description = 'Markers every 30 degrees. Automatically created from fill.py.'
  96. m.bbox_left = -180
  97. m.bbox_right = 180
  98. m.bbox_top = 75
  99. m.bbox_bottom = -75
  100. m.save()
  101. for lat in range(-75, 76, 15):
  102. for lon in range(-180, 181, 15):
  103. dp = example.poobrains.svg.MapDatapoint()
  104. dp.owner = u
  105. dp.group = g
  106. dp.dataset = m
  107. dp.title = 'Zee test at %d / %d' % (lat, lon)
  108. dp.description = 'Test marker on map at %d %d' % (lat, lon)
  109. dp.latitude = lat
  110. dp.longitude = lon
  111. dp.save(force_insert=True)
  112. places = example.poobrains.svg.MapDataset()
  113. places.owner = u
  114. places.group = g
  115. places.name = 'places'
  116. places.title = 'Some Places'
  117. places.description = 'Sample MapDataset from fill.py'
  118. places.bbox_left = -180
  119. places.bbox_right = 180
  120. places.bbox_top = 75
  121. places.bbox_bottom = -75
  122. places.save()
  123. dp = example.poobrains.svg.MapDatapoint()
  124. dp.owner = u
  125. dp.group = g
  126. dp.dataset = places
  127. dp.latitude = 0
  128. dp.longitude = 0
  129. dp.title = 'Center'
  130. dp.description = 'Center of the map at 0,0. Near the african west coast.'
  131. dp.save(force_insert=True)
  132. dp = example.poobrains.svg.MapDatapoint()
  133. dp.owner = u
  134. dp.group = g
  135. dp.dataset = places
  136. dp.latitude = 51.34897
  137. dp.longitude = 12.37115
  138. dp.title = 'Leipzig'
  139. dp.description = 'Where 34C3 will be'
  140. dp.save(force_insert=True)
  141. dp = example.poobrains.svg.MapDatapoint()
  142. dp.owner = u
  143. dp.group = g
  144. dp.dataset = places
  145. dp.latitude = 8.0817
  146. dp.longitude = 77.5497
  147. dp.title = 'Kanyakumari'
  148. dp.description = 'Southernmost town of mainland India'
  149. dp.save(force_insert=True)
  150. dp = example.poobrains.svg.MapDatapoint()
  151. dp.owner = u
  152. dp.group = g
  153. dp.dataset = places
  154. dp.latitude = -41.86385
  155. dp.longitude = 146.73089
  156. dp.title = 'Great Lake'
  157. dp.description = '"Great Lake" in Tansania (or rather a tiny island on it)'
  158. dp.save(force_insert=True)
  159. if __name__ == '__main__':
  160. news()
  161. datasets()
  162. map()