Changeset 9592 for src/django_gheat/gheat
- Timestamp:
- Aug 28, 2011, 1:00:28 PM (13 years ago)
- Location:
- src/django_gheat/gheat
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/django_gheat/gheat/admin.py
r9590 r9592 5 5 list_display = ['ssid','mac', 'organization'] 6 6 search_fields = ['ssid', 'mac', 'organization'] 7 ordering = ['ssid'] 7 8 admin.site.register(Accespoint, AccespointAdmin) 8 9 … … 18 19 admin.site.register(Node, NodeAdmin) 19 20 21 class OrganizationAdmin(admin.ModelAdmin): 22 list_display = ['name'] 23 ordering = ['name'] 24 admin.site.register(Organization, OrganizationAdmin) 25 20 26 admin.site.register(Apparatuur) 21 27 admin.site.register(Gebruiker) -
src/django_gheat/gheat/management/commands/import_droidstumbler.py
r9579 r9592 43 43 return count 44 44 45 organizations = dict(Organization.objects.all().values_list('name','id')) 46 def get_organization_id_by_ssid(ssid): 47 name = Organization.get_name_by_ssid(ssid) 48 if not name: 49 return 'NULL' 50 else: 51 return int(organizations[name]) 45 52 46 53 def import_droidstumbler(filename, meetrondje): … … 96 103 ssid, encryption = ap_pool[bssid] 97 104 # Special trick in SSID ts avoid escaping in later stage 98 item = str((bssid.upper(),ssid.replace('%','%%'),encryption, Accespoint.get_organization(ssid)))105 item = str((bssid.upper(),ssid.replace('%','%%'),encryption,get_organization_id_by_ssid(ssid))) 99 106 sql_values.append(item) 100 counters['ap_added'] = bulk_sql('gheat_accespoint (`mac`, `ssid`, `encryptie`, `organization `)',sql_values)107 counters['ap_added'] = bulk_sql('gheat_accespoint (`mac`, `ssid`, `encryptie`, `organization_id`)',sql_values) 101 108 102 109 # Build mapping for meting import -
src/django_gheat/gheat/management/commands/import_kismet.py
r9579 r9592 19 19 from collections import defaultdict 20 20 21 from import_droidstumbler import bulk_sql 21 from import_droidstumbler import bulk_sql,get_organization_id_by_ssid 22 22 23 23 logger = logging.getLogger(__name__) … … 76 76 ssid, encryption = ap_pool[bssid] 77 77 # Special trick in SSID ts avoid escaping in later stage 78 item = str((bssid.upper(),ssid.replace('%','%%'),encryption, Accespoint.get_organization(ssid)))78 item = str((bssid.upper(),ssid.replace('%','%%'),encryption,get_organization_id_by_ssid(ssid))) 79 79 sql_values.append(item) 80 counters['ap_added'] = bulk_sql('gheat_accespoint (`mac`, `ssid`, `encryptie`, `organization `)',sql_values)80 counters['ap_added'] = bulk_sql('gheat_accespoint (`mac`, `ssid`, `encryptie`, `organization_id`)',sql_values) 81 81 82 82 # Determine which Wireless Clients to add -
src/django_gheat/gheat/models.py
r9590 r9592 58 58 59 59 60 ORGANIZATION_CHOICES = ( 61 ('WirelessLeiden', 'Wireless Leiden'), 62 ) 60 class Organization(models.Model): 61 fullname = models.CharField(max_length=100,unique=True) 62 name = models.CharField(max_length=100,unique=True) 63 def __unicode__(self): 64 return self.fullname 65 66 @staticmethod 67 def get_name_by_ssid(ssid): 68 """ Try to determine the organization via the SSID """ 69 name = None 70 if ssid.startswith('ap') and ssid.endswith('wleiden.net'): 71 name = 'WirelessLeiden' 72 elif ssid.startswith('ap') and 'WirelessLeiden' in ssid: 73 name = 'WirelessLeiden' 74 return name 63 75 64 76 class Node(models.Model): … … 66 78 latitude = models.FloatField(null=True,blank=True) 67 79 longitude = models.FloatField(null=True,blank=True) 68 organization = models.CharField(max_length="50",choices=ORGANIZATION_CHOICES,null=True,blank=True) 80 organization = models.ForeignKey(Organization,null=True, blank=True) 81 class Meta: 82 unique_together = ('name', 'organization') 83 84 def __unicode__(self): 85 return "%s - %s" % (self.name, self.organization) 69 86 70 87 class Accespoint(models.Model): 71 88 mac = models.CharField(max_length=17) 72 89 ssid = models.CharField(max_length=64) 73 organization = models. CharField(max_length="50",choices=ORGANIZATION_CHOICES,null=True,blank=True)90 organization = models.ForeignKey(Organization,null=True, blank=True) 74 91 encryptie = models.BooleanField() 75 92 class Meta: … … 78 95 return "%s - %s" % (self.mac, self.ssid) 79 96 80 @staticmethod81 def get_organization(ssid):82 """ Try to determine the organization via the SSID """83 organization = ''84 if ssid.startswith('ap') and ssid.endswith('wleiden.net'):85 organization = 'WirelessLeiden'86 elif ssid.startswith('ap') and 'WirelessLeiden' in ssid:87 organization = 'WirelessLeiden'88 return organization89 97 90 98 def save(self, *args, **kwargs):
Note:
See TracChangeset
for help on using the changeset viewer.