Changeset 9664
- Timestamp:
- Sep 5, 2011, 5:05:20 PM (13 years ago)
- Location:
- src/django_gheat/gheat
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/django_gheat/gheat/dataimport/__init__.py
r9640 r9664 113 113 sql_values = [] 114 114 for (bssid,lat,lon),signals in meting_pool.iteritems(): 115 final_signal = max(signals) 115 116 if clients.has_key(bssid): 116 117 counters['meting_ignored'] += len(signals) … … 118 119 counters['meting_failed'] += len(signals) 119 120 bssid_failed[bssid] += len(signals) 121 elif final_signal < MIN_SIGNAL or final_signal > MAX_SIGNAL: 122 counters['meting_failed'] += len(signals) 120 123 else: 121 124 item = str((int(meetrondje.id),mac2id[bssid],float(lat),\ -
src/django_gheat/gheat/models.py
r9663 r9664 3 3 from django.core import validators 4 4 from django.db import models 5 6 MIN_SIGNAL = 0 7 MAX_SIGNAL = 100 8 9 10 # http://stackoverflow.com/questions/849142/how-to-limit-the-maximum-value-of-a-numeric-field-in-a-django-model/849426#849426 11 class IntegerRangeField(models.IntegerField): 12 def __init__(self, verbose_name=None, name=None, min_value=None, max_value=None, **kwargs): 13 self.min_value, self.max_value = min_value, max_value 14 models.IntegerField.__init__(self, verbose_name, name, **kwargs) 15 def formfield(self, **kwargs): 16 defaults = {'min_value': self.min_value, 'max_value':self.max_value} 17 defaults.update(kwargs) 18 return super(IntegerRangeField, self).formfield(**defaults) 5 19 6 20 … … 110 124 latitude = models.FloatField() 111 125 longitude = models.FloatField() 112 signaal = models.IntegerField(max_length=3)126 signaal = IntegerRangeField(max_length=3,min_value=MIN_SIGNAL,max_value=MAX_SIGNAL) 113 127 def __unicode__(self): 114 128 return "%s @ %.5f,%.5f : %s" % (self.accespoint.ssid, float(self.latitude), float(self.longitude), self.signaal)
Note:
See TracChangeset
for help on using the changeset viewer.