[9006] | 1 | from django.db import models
|
---|
| 2 | from gheat import managers
|
---|
[9026] | 3 | import datetime
|
---|
[9006] | 4 |
|
---|
[9026] | 5 | class Accespoint(models.Model):
|
---|
[9053] | 6 | mac = models.CharField(max_length=17)
|
---|
| 7 | ssid = models.CharField(max_length=64)
|
---|
| 8 | encryptie = models.BooleanField()
|
---|
| 9 | def __unicode__(self):
|
---|
| 10 | return "%s - %s" % (self.mac, self.ssid)
|
---|
[9006] | 11 |
|
---|
[9026] | 12 | class Gebruiker(models.Model):
|
---|
[9053] | 13 | naam = models.CharField(max_length=64)
|
---|
| 14 | email = models.CharField(max_length=64)
|
---|
| 15 | def __unicode__(self):
|
---|
| 16 | return "%s - %s" % (self.naam, self.email)
|
---|
[9026] | 17 |
|
---|
[9041] | 18 | class Apparatuur(models.Model):
|
---|
[9053] | 19 | antenne = models.CharField(max_length=64)
|
---|
| 20 | kaart = models.CharField(max_length=64)
|
---|
| 21 | def __unicode__(self):
|
---|
| 22 | return "%s - %s" % (self.antenne, self.kaart)
|
---|
[9026] | 23 |
|
---|
[9041] | 24 | class MeetRondje(models.Model):
|
---|
[9053] | 25 | datum = models.DateTimeField()
|
---|
[9097] | 26 | naam = models.CharField(max_length=64)
|
---|
[9053] | 27 | gebruiker = models.ForeignKey(Gebruiker)
|
---|
| 28 | apparatuur = models.ForeignKey(Apparatuur)
|
---|
| 29 | def __unicode__(self):
|
---|
[9054] | 30 | return "%s - %s" % (self.gebruiker.naam, self.naam)
|
---|
[9041] | 31 |
|
---|
[9026] | 32 | class Meting(models.Model):
|
---|
[9053] | 33 | meetrondje = models.ForeignKey(MeetRondje)
|
---|
| 34 | accespoint = models.ForeignKey(Accespoint)
|
---|
| 35 | latitude = models.FloatField(name='Latitude', db_column='lat')
|
---|
| 36 | longitude = models.FloatField(name='Longitude', db_column='lng')
|
---|
| 37 | signaal = models.IntegerField(max_length=3)
|
---|
| 38 | objects = managers.MetingManager()
|
---|
[9054] | 39 | def __unicode__(self):
|
---|
[9164] | 40 | return "%s @ %.5f,%.5f : %s" % (self.accespoint.ssid, float(self.latitude), float(self.longitude), self.signaal)
|
---|
[9179] | 41 | class Meta:
|
---|
| 42 | # This implies that you cannot have multiple messurements on the same
|
---|
| 43 | # location for a single 'run', thus the data needs cleaned before to make
|
---|
| 44 | # this properly hold.
|
---|
| 45 | unique_together = ('meetrondje', 'accespoint', 'latitude', 'longitude'),
|
---|
[9097] | 46 |
|
---|
[9102] | 47 | class Node(models.Model):
|
---|
[9097] | 48 | naam = models.CharField(max_length=64)
|
---|
| 49 | ssid = models.CharField(max_length=64)
|
---|
| 50 | latitude = models.FloatField(name='Latitude', db_column='lat')
|
---|
| 51 | longitude = models.FloatField(name='Longitude', db_column='lon')
|
---|
| 52 | def __unicode__(self):
|
---|
| 53 | return "%s - %s - %s - %s" % (self.naam, self.ssid, self.latitude, self.longitude)
|
---|