Changeset 9579 for src


Ignore:
Timestamp:
Aug 26, 2011, 8:54:24 PM (13 years ago)
Author:
rick
Message:

Map a SSID to an organization to play nice with differnt SSIDs.

Location:
src/django_gheat
Files:
7 edited

Legend:

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

    r9395 r9579  
    22from django.contrib import admin
    33
    4 admin.site.register(Accespoint)
     4class AccespointAdmin(admin.ModelAdmin):
     5  list_display = ['ssid','mac', 'organization']
     6  search_fields = ['ssid', 'mac', 'organization']
     7
     8admin.site.register(Accespoint, AccespointAdmin)
    59admin.site.register(Apparatuur)
    610admin.site.register(Gebruiker)
  • src/django_gheat/gheat/management/commands/import_droidstumbler.py

    r9565 r9579  
    9696      ssid, encryption = ap_pool[bssid]
    9797      # Special trick in SSID ts avoid escaping in later stage
    98       item = str((bssid.upper(),ssid.replace('%','%%'),encryption))
     98      item = str((bssid.upper(),ssid.replace('%','%%'),encryption,Accespoint.get_organization(ssid)))
    9999      sql_values.append(item)
    100     counters['ap_added'] = bulk_sql('gheat_accespoint (`mac`, `ssid`, `encryptie`)',sql_values)
     100    counters['ap_added'] = bulk_sql('gheat_accespoint (`mac`, `ssid`, `encryptie`, `organization`)',sql_values)
    101101
    102102  # Build mapping for meting import
  • src/django_gheat/gheat/management/commands/import_kismet.py

    r9565 r9579  
    7676      ssid, encryption = ap_pool[bssid]
    7777      # Special trick in SSID ts avoid escaping in later stage
    78       item = str((bssid.upper(),ssid.replace('%','%%'),encryption))
     78      item = str((bssid.upper(),ssid.replace('%','%%'),encryption,Accespoint.get_organization(ssid)))
    7979      sql_values.append(item)
    80     counters['ap_added'] = bulk_sql('gheat_accespoint (`mac`, `ssid`, `encryptie`)',sql_values)
     80    counters['ap_added'] = bulk_sql('gheat_accespoint (`mac`, `ssid`, `encryptie`, `organization`)',sql_values)
    8181
    8282  # Determine which Wireless Clients to add
  • src/django_gheat/gheat/models.py

    r9562 r9579  
    5757    return self.mac
    5858
     59
     60ORGANIZATION_CHOICES = (
     61  ('WirelessLeiden', 'Wireless Leiden'),
     62)
     63
    5964class Accespoint(models.Model):
    6065  mac = models.CharField(max_length=17)
    6166  ssid = models.CharField(max_length=64)
     67  organization = models.CharField(max_length="50",choices=ORGANIZATION_CHOICES,null=True,blank=True)
    6268  encryptie = models.BooleanField()
    6369  class Meta:
     
    6571  def __unicode__(self):
    6672    return "%s - %s" % (self.mac, self.ssid)
     73
     74  @staticmethod
     75  def get_organization(ssid):
     76    """ Try to determine the organization via the SSID """
     77    organization = ''
     78    if ssid.startswith('ap') and ssid.endswith('wleiden.net'):
     79      organization = 'WirelessLeiden'
     80    elif ssid.startswith('ap') and 'WirelessLeiden' in ssid:
     81      organization = 'WirelessLeiden'
     82    return organization
     83
     84  def save(self, *args, **kwargs):
     85    self.organization = self.get_organization(self.ssid)
     86    super(Accespoint, self).save(*args, **kwargs)
    6787
    6888class Gebruiker(models.Model):
  • src/django_gheat/wlheatmap/filters.py

    r9577 r9579  
    2020      # Get list if accespoints found in the specific 'Meting', and make this is list.
    2121      wirelessleiden_ssid = Meting.objects.filter(meetrondje=mr,
    22         accespoint__ssid__contains='WirelessLeiden').\
     22        accespoint__organization='WirelessLeiden').\
    2323        values_list('accespoint__ssid',flat=True).\
    2424        order_by('accespoint__ssid').distinct()
  • src/django_gheat/wlheatmap/nodelist.py

    r9244 r9579  
    4040  filter = {}
    4141  filter.update({
    42     'ssid__contains' : 'WirelessLeiden',
     42    'organization' : 'WirelessLeiden',
    4343    'meting__latitude__lt' : maxlat,
    4444    'meting__longitude__lt' : maxlon,
  • src/django_gheat/wlheatmap/templates/js/LayerBase.js

    r9549 r9579  
    168168OpenLayers.Layer.OSM.Overlay2 = OpenLayers.Class(OpenLayers.Layer.OSM, {
    169169    initialize: function(name, options) {
    170         var url = get_balanced_urls('http://', {{ settings.DJANGO_CDN_DOMAINS|safe }}, '{{ settings.DJANGO_PREFIX }}/wlheatmap/tile/${z}/${x},${y}.png?colour=90,90,90');
     170        var url = get_balanced_urls('http://', {{ settings.DJANGO_CDN_DOMAINS|safe }},
     171          '{{ settings.DJANGO_PREFIX }}/wlheatmap/tile/${z}/${x},${y}.png?colour=90,90,90');
    171172        options = OpenLayers.Util.extend({ numZoomLevels: 21 }, options);
    172173        var newArguments = [name, url, options];
     
    182183OpenLayers.Layer.OSM.Overlay3 = OpenLayers.Class(OpenLayers.Layer.OSM, {
    183184    initialize: function(name, options) {
    184         var url = get_balanced_urls('http://', {{ settings.DJANGO_CDN_DOMAINS|safe }}, '{{ settings.DJANGO_PREFIX }}/wlheatmap/tile/${z}/${x},${y}.png?colour=255,0,0&accespoint__ssid__icontains=WirelessLeiden');
     185        var url = get_balanced_urls('http://', {{ settings.DJANGO_CDN_DOMAINS|safe }},
     186          '{{ settings.DJANGO_PREFIX }}/wlheatmap/tile/${z}/${x},${y}.png?colour=255,0,0&accespoint__organization=WirelessLeiden');
    185187        options = OpenLayers.Util.extend({ numZoomLevels: 21 }, options);
    186188        var newArguments = [name, url, options];
     
    196198OpenLayers.Layer.OSM.Overlay4 = OpenLayers.Class(OpenLayers.Layer.OSM, {
    197199  initialize: function(name, options) {
    198     var url = get_balanced_urls('http://', {{ settings.DJANGO_CDN_DOMAINS|safe }}, '{{ settings.DJANGO_PREFIX }}/wlheatmap/tile/${z}/${x},${y}.png?colour=50,150,50&signaal__gte=0&signaal__lte=100');
     200    var url = get_balanced_urls('http://', {{ settings.DJANGO_CDN_DOMAINS|safe }},
     201      '{{ settings.DJANGO_PREFIX }}/wlheatmap/tile/${z}/${x},${y}.png?colour=50,150,50&signaal__gte=0&signaal__lte=100');
    199202    options = OpenLayers.Util.extend({ numZoomLevels: 21 }, options);
    200203    var newArguments = [name, url, options];
Note: See TracChangeset for help on using the changeset viewer.