/eve_db/models/map.py

https://github.com/keiouu/django-eve-db · Python · 368 lines · 293 code · 44 blank · 31 comment · 2 complexity · 1e7050e00193761c43a55befd35b0b2c MD5 · raw file

  1. """
  2. Map-related models.
  3. """
  4. from django.db import models
  5. class MapUniverse(models.Model):
  6. """
  7. CCP Table: mapUniverse
  8. CCP Primary key: "universeID" int(11)
  9. """
  10. id = models.IntegerField(unique=True, primary_key=True)
  11. name = models.CharField(max_length=255, blank=True)
  12. x = models.FloatField(blank=True, null=True)
  13. x_min = models.FloatField(blank=True, null=True)
  14. x_max = models.FloatField(blank=True, null=True)
  15. y = models.FloatField(blank=True, null=True)
  16. y_min = models.FloatField(blank=True, null=True)
  17. y_max = models.FloatField(blank=True, null=True)
  18. z = models.FloatField(blank=True, null=True)
  19. z_min = models.FloatField(blank=True, null=True)
  20. z_max = models.FloatField(blank=True, null=True)
  21. x = models.FloatField(blank=True, null=True)
  22. radius = models.FloatField(blank=True, null=True)
  23. class Meta:
  24. app_label = 'eve_db'
  25. ordering = ['id']
  26. verbose_name = 'Universe'
  27. verbose_name_plural = 'Universes'
  28. def __unicode__(self):
  29. return self.name
  30. def __str__(self):
  31. return self.__unicode__()
  32. class MapRegion(models.Model):
  33. """
  34. CCP Table: mapRegions
  35. CCP Primary key: "regionID" int(11)
  36. """
  37. id = models.IntegerField(unique=True, primary_key=True)
  38. name = models.CharField(max_length=255, blank=True)
  39. faction = models.ForeignKey('ChrFaction', blank=True, null=True)
  40. x = models.FloatField(blank=True, null=True)
  41. x_min = models.FloatField(blank=True, null=True)
  42. x_max = models.FloatField(blank=True, null=True)
  43. y = models.FloatField(blank=True, null=True)
  44. y_min = models.FloatField(blank=True, null=True)
  45. y_max = models.FloatField(blank=True, null=True)
  46. z = models.FloatField(blank=True, null=True)
  47. z_min = models.FloatField(blank=True, null=True)
  48. z_max = models.FloatField(blank=True, null=True)
  49. x = models.FloatField(blank=True, null=True)
  50. radius = models.FloatField(blank=True, null=True)
  51. class Meta:
  52. app_label = 'eve_db'
  53. ordering = ['id']
  54. verbose_name = 'Region'
  55. verbose_name_plural = 'Regions'
  56. def __unicode__(self):
  57. return self.name
  58. def __str__(self):
  59. return self.__unicode__()
  60. class MapRegionJump(models.Model):
  61. """
  62. CCP Table: mapRegionJumps
  63. CCP Primary key: ("fromRegionID" int(11), "toRegionID" int(11))
  64. """
  65. from_region = models.ForeignKey(MapRegion,
  66. related_name='region_jumps_from_region_set')
  67. to_region = models.ForeignKey(MapRegion,
  68. related_name='region_jumps_to_region_set')
  69. class Meta:
  70. app_label = 'eve_db'
  71. ordering = ['id']
  72. verbose_name = 'Region Jump'
  73. verbose_name_plural = 'Region Jumps'
  74. unique_together = ('from_region', 'to_region')
  75. def __unicode__(self):
  76. return "%s -> %s" % (self.from_region.name,
  77. self.to_region.name)
  78. def __str__(self):
  79. return self.__unicode__()
  80. class MapConstellation(models.Model):
  81. """
  82. Represents a constellation. Note that all sovereignty data is subject
  83. to change, and is held in an external model. django-eve-api has a few
  84. of these for your convenience.
  85. CCP Table: mapConstellations
  86. CCP Primary key: "constellationID" int(11)
  87. """
  88. id = models.IntegerField(unique=True, primary_key=True)
  89. name = models.CharField(max_length=255, blank=True)
  90. region = models.ForeignKey(MapRegion, blank=True, null=True)
  91. x = models.FloatField(blank=True, null=True)
  92. x_min = models.FloatField(blank=True, null=True)
  93. x_max = models.FloatField(blank=True, null=True)
  94. y = models.FloatField(blank=True, null=True)
  95. y_min = models.FloatField(blank=True, null=True)
  96. y_max = models.FloatField(blank=True, null=True)
  97. z = models.FloatField(blank=True, null=True)
  98. z_min = models.FloatField(blank=True, null=True)
  99. z_max = models.FloatField(blank=True, null=True)
  100. x = models.FloatField(blank=True, null=True)
  101. radius = models.FloatField(blank=True, null=True)
  102. alliance = models.ForeignKey('eve_api.ApiPlayerAlliance', blank=True, null=True)
  103. faction = models.ForeignKey('ChrFaction', blank=True, null=True)
  104. sovereignty_start_time = models.DateTimeField(blank=True, null=True)
  105. sovereignty_grace_start_time = models.DateTimeField(blank=True, null=True)
  106. class Meta:
  107. app_label = 'eve_db'
  108. ordering = ['id']
  109. verbose_name = 'Constellation'
  110. verbose_name_plural = 'Constellations'
  111. def __unicode__(self):
  112. return self.name
  113. def __str__(self):
  114. return self.__unicode__()
  115. class MapConstellationJump(models.Model):
  116. """
  117. CCP Table: mapConstellationJumps
  118. CCP Primary key: ("fromConstellationID" int(11), "toConstellationID" int(11))
  119. """
  120. from_region = models.ForeignKey(MapRegion,
  121. related_name='constellation_jumps_from_region_set')
  122. from_constellation = models.ForeignKey(MapConstellation,
  123. related_name='constellation_jumps_from_constellation_set')
  124. to_region = models.ForeignKey(MapRegion,
  125. related_name='constellation_jumps_to_region_set')
  126. to_constellation = models.ForeignKey(MapConstellation,
  127. related_name='constellation_jumps_to_constellation_set')
  128. class Meta:
  129. app_label = 'eve_db'
  130. ordering = ['id']
  131. verbose_name = 'Constellation Jump'
  132. verbose_name_plural = 'Constellation Jumps'
  133. unique_together = ('from_constellation', 'to_constellation')
  134. def __unicode__(self):
  135. return "%s -> %s" % (self.from_constellation.name,
  136. self.to_constellation.name)
  137. def __str__(self):
  138. return self.__unicode__()
  139. class MapSolarSystem(models.Model):
  140. """
  141. CCP Table: mapSolarSystems
  142. CCP Primary key: "solarSystemID" int(11)
  143. """
  144. id = models.IntegerField(unique=True, primary_key=True)
  145. region = models.ForeignKey(MapRegion, blank=True, null=True)
  146. name = models.CharField(max_length=255, blank=True, null=True)
  147. constellation = models.ForeignKey(MapConstellation, blank=True, null=True)
  148. x = models.FloatField(blank=True, null=True)
  149. x_min = models.FloatField(blank=True, null=True)
  150. x_max = models.FloatField(blank=True, null=True)
  151. y = models.FloatField(blank=True, null=True)
  152. y_min = models.FloatField(blank=True, null=True)
  153. y_max = models.FloatField(blank=True, null=True)
  154. z = models.FloatField(blank=True, null=True)
  155. z_min = models.FloatField(blank=True, null=True)
  156. z_max = models.FloatField(blank=True, null=True)
  157. luminosity = models.FloatField(blank=True, null=True)
  158. is_border_system = models.BooleanField(default=False)
  159. is_fringe_system = models.BooleanField(default=False)
  160. is_corridor_system = models.BooleanField(default=False)
  161. is_hub_system = models.BooleanField(default=False)
  162. is_international = models.BooleanField(default=False)
  163. has_interregional_link = models.BooleanField(default=False)
  164. has_interconstellational_link = models.BooleanField(default=False)
  165. security_level = models.FloatField(blank=True, null=True)
  166. faction = models.ForeignKey('ChrFaction', blank=True, null=True,
  167. related_name='solarsystem_set')
  168. radius = models.FloatField(blank=True, null=True)
  169. sun_type = models.ForeignKey('InvType', blank=True, null=True)
  170. security_class = models.CharField(max_length=5, blank=True)
  171. alliance = models.ForeignKey('eve_api.ApiPlayerAlliance', blank=True, null=True)
  172. sovereignty_level = models.IntegerField(blank=True, null=True)
  173. sovereignty_start_time = models.DateTimeField(blank=True, null=True)
  174. class Meta:
  175. app_label = 'eve_db'
  176. ordering = ['id']
  177. verbose_name = 'Solar System'
  178. verbose_name_plural = 'Solar Systems'
  179. def __unicode__(self):
  180. if self.name:
  181. return self.name
  182. else:
  183. return "Solar System #%d" % self.id
  184. def __str__(self):
  185. return self.__unicode__()
  186. class MapSolarSystemJump(models.Model):
  187. """
  188. CCP Table: mapSolarSystemJumps
  189. CCP Primary key: ("fromSolarSystemID" int(11), "toSolarSystemID" int(11))
  190. """
  191. from_region = models.ForeignKey(MapRegion, blank=True, null=True,
  192. related_name='solar_system_jumps_from_region_set')
  193. from_constellation = models.ForeignKey(MapConstellation, blank=True,
  194. null=True,
  195. related_name='solar_system_jumps_from_constellation_set')
  196. from_solar_system = models.ForeignKey(MapSolarSystem,
  197. related_name='solar_system_jumps_from_solar_system_set')
  198. to_region = models.ForeignKey(MapRegion, blank=True, null=True,
  199. related_name='solar_system_jumps_to_region_set')
  200. to_constellation = models.ForeignKey(MapConstellation, blank=True,
  201. null=True,
  202. related_name='solar_system_jumps_to_constellation_set')
  203. to_solar_system = models.ForeignKey(MapSolarSystem,
  204. related_name='solar_system_jumps_to_solar_system_set')
  205. class Meta:
  206. app_label = 'eve_db'
  207. ordering = ['id']
  208. verbose_name = 'Solar System Jump'
  209. verbose_name_plural = 'Solar System Jumps'
  210. unique_together = ('from_solar_system', 'to_solar_system')
  211. def __unicode__(self):
  212. return "%s -> %s" % (self.from_solar_system.name,
  213. self.to_solar_system.name)
  214. def __str__(self):
  215. return self.__unicode__()
  216. class MapJump(models.Model):
  217. """
  218. Jumps between stargates.
  219. CCP Table: mapJumps
  220. CCP Primary key: "stargateID" int(11)
  221. """
  222. origin_gate = models.ForeignKey('MapDenormalize',
  223. unique=True, primary_key=True,
  224. related_name='stargate_jump_origin_set')
  225. destination_gate = models.ForeignKey('MapDenormalize',
  226. related_name='stargate_jump_destination_set')
  227. class Meta:
  228. app_label = 'eve_db'
  229. ordering = ['origin_gate']
  230. verbose_name = 'Stargate Jump'
  231. verbose_name_plural = 'Stargate Jumps'
  232. def __unicode__(self):
  233. return "%s -> %s" % (self.origin_gate, self.destination_gate)
  234. def __str__(self):
  235. return self.__unicode__()
  236. class MapCelestialStatistic(models.Model):
  237. """
  238. CCP Table: mapCelestialStatistics
  239. CCP Primary key: "celestialID" int(11)
  240. """
  241. celestial = models.ForeignKey('MapDenormalize', unique=True, primary_key=True)
  242. temperature = models.FloatField(blank=True, null=True)
  243. spectral_class = models.CharField(max_length=255, blank=True)
  244. luminosity = models.FloatField(blank=True, null=True)
  245. age = models.FloatField(blank=True, null=True)
  246. life = models.FloatField(blank=True, null=True)
  247. orbit_radius = models.FloatField(blank=True, null=True)
  248. eccentricity = models.FloatField(blank=True, null=True)
  249. mass_dust = models.FloatField(blank=True, null=True)
  250. mass_gas = models.FloatField(blank=True, null=True)
  251. is_fragmented = models.BooleanField(default=False)
  252. density = models.FloatField(blank=True, null=True)
  253. surface_gravity = models.FloatField(blank=True, null=True)
  254. escape_velocity = models.FloatField(blank=True, null=True)
  255. orbit_period = models.FloatField(blank=True, null=True)
  256. rotation_rate = models.FloatField(blank=True, null=True)
  257. is_locked = models.BooleanField(default=False)
  258. pressure = models.FloatField(blank=True, null=True)
  259. radius = models.FloatField(blank=True, null=True)
  260. mass = models.FloatField(blank=True, null=True)
  261. class Meta:
  262. app_label = 'eve_db'
  263. ordering = ['celestial']
  264. verbose_name = 'Celestial Statistic'
  265. verbose_name_plural = 'Celestial Statistics'
  266. def __unicode__(self):
  267. return "%s stats" % self.celestial.name
  268. def __str__(self):
  269. return self.__unicode__()
  270. class MapDenormalize(models.Model):
  271. """
  272. CCP Table: mapDenormalize
  273. CCP Primary key: "itemID" int(11)
  274. """
  275. id = models.IntegerField(unique=True, primary_key=True)
  276. type = models.ForeignKey('InvType', blank=True, null=True)
  277. group = models.ForeignKey('InvGroup', blank=True, null=True)
  278. solar_system = models.ForeignKey(MapSolarSystem, blank=True, null=True)
  279. constellation = models.ForeignKey(MapConstellation, blank=True, null=True)
  280. region = models.ForeignKey(MapRegion, blank=True, null=True)
  281. orbit_id = models.IntegerField(blank=True, null=True)
  282. x = models.FloatField(blank=True, null=True)
  283. y = models.FloatField(blank=True, null=True)
  284. z = models.FloatField(blank=True, null=True)
  285. radius = models.FloatField(blank=True, null=True)
  286. name = models.CharField(max_length=100, blank=True, null=True)
  287. security = models.FloatField(blank=True, null=True)
  288. celestial_index = models.IntegerField(blank=True, null=True)
  289. orbit_index = models.IntegerField(blank=True, null=True)
  290. class Meta:
  291. app_label = 'eve_db'
  292. ordering = ['id']
  293. verbose_name = 'Denormalize'
  294. verbose_name_plural = 'Denormalizations'
  295. def __unicode__(self):
  296. return self.name
  297. def __str__(self):
  298. return self.__unicode__()
  299. class MapLandmark(models.Model):
  300. """
  301. CCP Table: mapLandmarks
  302. CCP Primary key: "landmarkID" smallint(6)
  303. """
  304. id = models.IntegerField(unique=True, primary_key=True)
  305. name = models.CharField(max_length=255, blank=True)
  306. description = models.TextField(blank=True)
  307. solar_system = models.ForeignKey('MapSolarSystem', blank=True, null=True)
  308. x = models.FloatField(blank=True, null=True)
  309. y = models.FloatField(blank=True, null=True)
  310. z = models.FloatField(blank=True, null=True)
  311. radius = models.FloatField(blank=True, null=True)
  312. icon = models.ForeignKey('EveIcon', blank=True, null=True)
  313. importance = models.IntegerField(blank=True, null=True)
  314. class Meta:
  315. app_label = 'eve_db'
  316. ordering = ['id']
  317. verbose_name = 'Landmark'
  318. verbose_name_plural = 'Landmarks'
  319. def __unicode__(self):
  320. return self.name
  321. def __str__(self):
  322. return self.__unicode__()