##// END OF EJS Templates
template attribute added to RadarSys Models...
Miguel Urco -
r47:f6d4e6a94b9f
parent child
Show More
@@ -31,7 +31,7 class CampaignForm(forms.ModelForm):
31 31
32 32 class Meta:
33 33 model = Campaign
34 fields = ['name', 'start_date', 'end_date', 'tags', 'description', 'template']
34 exclude = ['']
35 35
36 36 class ExperimentForm(forms.ModelForm):
37 37 def __init__(self, *args, **kwargs):
@@ -43,7 +43,7 class ExperimentForm(forms.ModelForm):
43 43
44 44 class Meta:
45 45 model = Experiment
46 fields = ['campaign', 'name', 'start_time', 'end_time']
46 exclude = ['']
47 47
48 48 class LocationForm(forms.ModelForm):
49 49 class Meta:
@@ -58,7 +58,7 class DeviceForm(forms.ModelForm):
58 58 class ConfigurationForm(forms.ModelForm):
59 59 class Meta:
60 60 model = Configuration
61 fields = ['experiment', 'device']
61 exclude = ['type', 'created_date', 'programmed_date', 'parameters']
62 62
63 63 class DeviceTypeForm(forms.Form):
64 64 device_type = forms.ChoiceField(choices=add_empty_choice(DeviceType.objects.all().order_by('name').values_list('id', 'name')))
@@ -31,6 +31,15 DEV_TYPES = (
31 31 ('abs', 'Automatic Beam Switching'),
32 32 )
33 33
34 DEV_PORTS = {
35 'rc' : 2000,
36 'dds' : 2000,
37 'jars' : 2000,
38 'usrp' : 2000,
39 'cgs' : 8080,
40 'abs' : 8080
41 }
42
34 43 # Create your models here.
35 44
36 45 class Location(models.Model):
@@ -72,14 +81,20 class Device(models.Model):
72 81 def __unicode__(self):
73 82 return u'%s | %s' % (self.name, self.ip_address)
74 83
84 def get_status(self):
85
86 return self.status
87
88
75 89 class Campaign(models.Model):
76 90
91 template = models.BooleanField(default=False)
92
77 93 name = models.CharField(max_length=40, unique=True)
78 94 start_date = models.DateTimeField(blank=True, null=True)
79 95 end_date = models.DateTimeField(blank=True, null=True)
80 96 tags = models.CharField(max_length=40)
81 97 description = models.TextField(blank=True, null=True)
82 template = models.BooleanField(default=False)
83 98
84 99 class Meta:
85 100 db_table = 'db_campaigns'
@@ -89,6 +104,8 class Campaign(models.Model):
89 104
90 105 class Experiment(models.Model):
91 106
107 template = models.BooleanField(default=False)
108
92 109 campaign = models.ForeignKey(Campaign)
93 110 name = models.CharField(max_length=40, default='')
94 111 start_time = models.TimeField(default='00:00:00')
@@ -102,14 +119,15 class Experiment(models.Model):
102 119
103 120 class Configuration(PolymorphicModel):
104 121
122 template = models.BooleanField(default=False)
123
124 name = models.CharField(verbose_name="Configuration Name", max_length=40, default='')
125
105 126 experiment = models.ForeignKey(Experiment)
106 127 device = models.ForeignKey(Device)
107 128
108 status = models.PositiveSmallIntegerField(default=0, choices=CONF_STATES)
109 129 type = models.PositiveSmallIntegerField(default=0, choices=CONF_TYPES)
110 130
111 name = models.CharField(max_length=40, default='')
112
113 131 created_date = models.DateTimeField(auto_now_add=True)
114 132 programmed_date = models.DateTimeField(auto_now=True)
115 133
@@ -122,8 +140,8 class Configuration(PolymorphicModel):
122 140 return u'[%s - %s]: %s' % (self.experiment.campaign.name,
123 141 self.experiment.name,
124 142 self.device.name)
125 def get_absolute_url(self):
126 143
144 def get_absolute_url(self):
127 145 return reverse('url_%s_conf' % self.device.device_type.name, args=[str(self.id)])
128 146
129 147 def get_absolute_url_edit(self):
@@ -22,7 +22,6 def value(instance, key):
22 22
23 23 item = instance
24 24 for my_key in key.split("__"):
25 print "TP Value", item, my_key
26 25 item = attr(item, my_key)
27 26
28 27 print item
@@ -448,7 +448,7 def dev_conf(request, id_conf):
448 448
449 449 kwargs = {}
450 450 kwargs['dev_conf'] = dev_conf
451 kwargs['dev_conf_keys'] = ['experiment', 'device']
451 kwargs['dev_conf_keys'] = ['name', 'experiment', 'device']
452 452
453 453 kwargs['title'] = 'Configuration'
454 454 kwargs['suptitle'] = 'Details'
@@ -466,20 +466,15 def dev_conf_new(request, id_exp=0):
466 466 form = ConfigurationForm(initial={'experiment':id_exp})
467 467
468 468 if request.method == 'POST':
469 form = ConfigurationForm(request.POST)
470
471 if form.is_valid():
472 469 experiment = Experiment.objects.get(pk=request.POST['experiment'])
473 470 device = Device.objects.get(pk=request.POST['device'])
474 471
475 exp_devices = Device.objects.filter(configuration__experiment=experiment,
476 configuration__type=0)
472 DevConfForm = CONF_FORMS[device.device_type.name]
477 473
478 if device.id not in exp_devices.values('id',):
474 form = DevConfForm(request.POST, initial={'experiment':experiment.id})
479 475
480 DevConfModel = CONF_MODELS[device.device_type.name]
481 conf = DevConfModel(experiment=experiment, device=device)
482 conf.save()
476 if form.is_valid():
477 dev_conf = form.save()
483 478
484 479 return redirect('url_experiment', id_exp=experiment.id)
485 480
General Comments 0
You need to be logged in to leave comments. Login now