Skip to content
This repository has been archived by the owner on Sep 16, 2022. It is now read-only.

Commit

Permalink
Remove model-decoded.
Browse files Browse the repository at this point in the history
  • Loading branch information
a-martynovich committed Sep 27, 2019
1 parent 029df68 commit fffbd42
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 43 deletions.
40 changes: 1 addition & 39 deletions backend/device_registry/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,50 +320,12 @@ class DeviceInfo(models.Model):
detected_mirai = models.BooleanField(default=False, blank=True)
device_metadata = JSONField(blank=True, default=dict)

RASPBERRY_MODEL_MAP = {
'0002': 'Model B Rev 1',
'0003': 'Model B Rev 1',
'0004': 'Model B Rev 2',
'0005': 'Model B Rev 2',
'0006': 'Model B Rev 2',
'0007': 'Model A',
'0008': 'Model A',
'0009': 'Model A',
'000d': 'Model B Rev 2',
'000e': 'Model B Rev 2',
'000f': 'Model B Rev 2',
'0010': 'Model B+',
'0013': 'Model B+',
'900032': 'Model B+',
'0011': 'Compute Module',
'0014': 'Compute Module',
'0012': 'Model A+',
'0015': 'Model A+',
'a01041': '2 Model B v1.1',
'a21041': '2 Model B v1.1',
'a22042': '2 Model B v1.2',
'900092': 'Zero v1.2',
'900093': 'Zero v1.3',
'9000c1': 'Zero W',
'a02082': '3 Model B',
'a22082': '3 Model B',
'a32082': '3 Model B',
'a52082': '3 Model B',
'a22083': '3 Model B',
'a020d3': '3 Model B+',
'a03111': '4 Model B',
'b03111': '4 Model B',
'c03111': '4 Model B'
}

def __str__(self):
return self.device.device_id

def get_model(self):
model = None
if self.device_manufacturer == 'Raspberry Pi':
model = self.device_model
return model
return self.device_model

def get_hardware_type(self):
if self.device_manufacturer == 'Raspberry Pi':
Expand Down
4 changes: 1 addition & 3 deletions backend/device_registry/tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,7 @@ def test_fixed_issues(self):

def test_get_model(self):
model = self.device_info0.device_model
self.device_info0.device_model = '000d'
self.assertEqual(self.device_info0.get_model(), 'Model B Rev 2')
self.device_info0.device_model = '000D' # case insensitive
self.device_info0.device_model = 'Model B Rev 2'
self.assertEqual(self.device_info0.get_model(), 'Model B Rev 2')
self.device_info0.device_model = model

Expand Down
2 changes: 1 addition & 1 deletion backend/device_registry/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ def test_get(self):
'test': 'value',
'device_id': 'device0.d.wott-dev.local',
'manufacturer': 'Raspberry Pi',
'model': '900092',
'model': 'Zero v1.2',
'model-decoded': 'Zero v1.2',
'device-name': 'the-device-name'
})
Expand Down

0 comments on commit fffbd42

Please sign in to comment.