Ignore:
Timestamp:
Dec 23, 2011, 8:28:57 AM (13 years ago)
Author:
rick
Message:

Type is needed to start playing around with filters based on the function/type of a unit.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/django_gheat/gheat/models.py

    r9747 r9818  
    77MAX_SIGNAL = 100
    88
     9ACCESPOINT_TYPE_CHOICES= (
     10  ('accespoint', 'Acess Point'),
     11  ('interlink', 'InterLink'),
     12)
    913
    1014# http://stackoverflow.com/questions/849142/how-to-limit-the-maximum-value-of-a-numeric-field-in-a-django-model/849426#849426
     
    7175  mac = models.CharField(max_length=17)
    7276  ssid = models.CharField(max_length=64)
     77  type = models.CharField(max_length=20, null=True, blank=True, choices=ACCESPOINT_TYPE_CHOICES)
    7378  organization = models.ForeignKey(Organization,null=True, blank=True)
    7479  encryptie = models.BooleanField()
     
    7883    return "%s - %s" % (self.mac, self.ssid)
    7984
     85  @staticmethod
     86  def get_type_by_ssid(ssid):
     87    if ssid.startswith('ap'):
     88      type = 'accespoint'
     89    elif ssid.startswith('il'):
     90      type = 'interlink'
     91    else:
     92      type = None
     93    return type
    8094
    8195  def save(self, *args, **kwargs):
    82     self.organization = self.get_organization(self.ssid)
    8396    super(Accespoint, self).save(*args, **kwargs)
    8497
Note: See TracChangeset for help on using the changeset viewer.