Changeset 9818
- Timestamp:
- Dec 23, 2011, 8:28:57 AM (13 years ago)
- Location:
- src/django_gheat/gheat
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/django_gheat/gheat/admin.py
r9747 r9818 3 3 4 4 class AccespointAdmin(admin.ModelAdmin): 5 list_display = ['ssid',' mac', 'organization']5 list_display = ['ssid','type', 'mac', 'organization'] 6 6 search_fields = ['ssid', 'mac', 'organization'] 7 7 ordering = ['ssid'] -
src/django_gheat/gheat/dataimport/__init__.py
r9668 r9818 44 44 try: 45 45 # Make sure the special NULL is preserved 46 sql = "INSERT INTO %s VALUES %s" % (sql_table, ','.join(sql_values).replace(" 'NULL'",'NULL'))46 sql = "INSERT INTO %s VALUES %s" % (sql_table, ','.join(sql_values).replace("None",'NULL').replace("'NULL'",'NULL')) 47 47 count = cursor.execute(sql) 48 48 transaction.commit_unless_managed() … … 85 85 for bssid in bssid_list_insert: 86 86 ssid, encryption = ap_pool[bssid] 87 type = Accespoint.get_type_by_ssid(ssid) 87 88 # Special trick in SSID ts avoid escaping in later stage 88 89 item = str((bssid.upper(),ssid.replace('%','%%'),encryption, 90 Accespoint.get_type_by_ssid(ssid), 89 91 get_organization_id_by_ssid(ssid))) 90 92 sql_values.append(item) 91 93 counters['ap_added'] = bulk_sql('gheat_accespoint (`mac`, `ssid`,\ 92 `encryptie`, ` organization_id`)',sql_values)94 `encryptie`, `type`, `organization_id`)',sql_values) 93 95 return counters 94 96 -
src/django_gheat/gheat/models.py
r9747 r9818 7 7 MAX_SIGNAL = 100 8 8 9 ACCESPOINT_TYPE_CHOICES= ( 10 ('accespoint', 'Acess Point'), 11 ('interlink', 'InterLink'), 12 ) 9 13 10 14 # http://stackoverflow.com/questions/849142/how-to-limit-the-maximum-value-of-a-numeric-field-in-a-django-model/849426#849426 … … 71 75 mac = models.CharField(max_length=17) 72 76 ssid = models.CharField(max_length=64) 77 type = models.CharField(max_length=20, null=True, blank=True, choices=ACCESPOINT_TYPE_CHOICES) 73 78 organization = models.ForeignKey(Organization,null=True, blank=True) 74 79 encryptie = models.BooleanField() … … 78 83 return "%s - %s" % (self.mac, self.ssid) 79 84 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 80 94 81 95 def save(self, *args, **kwargs): 82 self.organization = self.get_organization(self.ssid)83 96 super(Accespoint, self).save(*args, **kwargs) 84 97
Note:
See TracChangeset
for help on using the changeset viewer.