Skip to content

Commit

Permalink
Fix to allow creation of machine objects via api
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamgilbert committed Jul 17, 2015
1 parent a3a7034 commit c08b39b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
8 changes: 4 additions & 4 deletions api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ class Meta:
exclude = ('id', 'machine')

class MachineSerializer(serializers.ModelSerializer):
facts = FactSerializer(many=True)
conditions = ConditionSerializer(many=True)
pending_apple_updates = PendingAppleUpdateSerializer(many=True)
pending_updates = PendingUpdateSerializer(many=True)
facts = FactSerializer(many=True, required=False)
conditions = ConditionSerializer(many=True, required=False)
pending_apple_updates = PendingAppleUpdateSerializer(many=True, required=False)
pending_updates = PendingUpdateSerializer(many=True, required=False)
#machine_group = MachineGroupSerializer()
class Meta:
model = Machine
Expand Down
24 changes: 24 additions & 0 deletions server/migrations/0005_auto_20150717_1827.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


class Migration(migrations.Migration):

dependencies = [
('server', '0004_auto_20150623_1623'),
]

operations = [
migrations.AlterField(
model_name='machine',
name='manifest',
field=models.CharField(max_length=256, null=True, blank=True),
),
migrations.AlterField(
model_name='machine',
name='operating_system',
field=models.CharField(max_length=256, null=True, blank=True),
),
]
6 changes: 3 additions & 3 deletions server/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ class Machine(models.Model):
machine_group = models.ForeignKey(MachineGroup)
serial = models.CharField(max_length=100, unique=True)
hostname = models.CharField(max_length=256, null=True, blank=True)
operating_system = models.CharField(max_length=256)
operating_system = models.CharField(max_length=256, null=True, blank=True)
memory = models.CharField(max_length=256, null=True, blank=True)
memory_kb = models.IntegerField(default=0)
munki_version = models.CharField(max_length=256, null=True, blank=True)
manifest = models.CharField(max_length=256)
manifest = models.CharField(max_length=256, null=True, blank=True)
hd_space = models.CharField(max_length=256, null=True, blank=True)
hd_total = models.CharField(max_length=256, null=True, blank=True)
hd_percent = models.CharField(max_length=256, null=True, blank=True)
Expand Down Expand Up @@ -181,7 +181,7 @@ def __unicode__(self):
return self.hostname
class Meta:
ordering = ['hostname']
def save(self):
def save(self, *args, **kwargs):
self.serial = self.serial.replace('/', '')
super(Machine, self).save()

Expand Down

0 comments on commit c08b39b

Please sign in to comment.