Commit 860eb6afa352a4d898910296ed3905ec4fa207fb

Authored by Alexis Koralewski
1 parent 7147202c
Exists in dev

Adding 3 full sequences in initial fixture, fixing view / edit page of sequences…

…, displaying new messages to explain errors/warnings
CHANGELOG
  1 +26-04-2022 (AKo): v0.4.4.1
  2 + - Adding 3 full sequences to debris scientific program in initial fixture
  3 + - Fixing view / edit page of sequences (new messages to explain errors/warnings)
  4 +
1 5 25-04-2022 (AKo): v0.4.4.0
2 6 - Adding PhpMyAdmin to docker-compose
3 7 - Renaming "common" tables with a simplified name
... ...
VERSION
1   -0.4.3.0
  1 +0.4.4.1
2 2 \ No newline at end of file
... ...
src/core/pyros_django/misc/fixtures/initial_fixture_TZ.json
... ... @@ -166,24 +166,24 @@
166 166 }
167 167 },
168 168 {
169   - "model":"common.ScienceTheme",
170   - "pk":1,
171   - "fields":{
172   - "name":"Solar System"
  169 + "model": "common.ScienceTheme",
  170 + "pk": 1,
  171 + "fields": {
  172 + "name": "Solar System"
173 173 }
174 174 },
175 175 {
176   - "model":"common.ScienceTheme",
177   - "pk":2,
178   - "fields":{
179   - "name":"Galatic"
  176 + "model": "common.ScienceTheme",
  177 + "pk": 2,
  178 + "fields": {
  179 + "name": "Galatic"
180 180 }
181 181 },
182 182 {
183   - "model":"common.ScienceTheme",
184   - "pk":3,
185   - "fields":{
186   - "name":"Extra Galatic"
  183 + "model": "common.ScienceTheme",
  184 + "pk": 3,
  185 + "fields": {
  186 + "name": "Extra Galatic"
187 187 }
188 188 },
189 189 {
... ... @@ -202,9 +202,9 @@
202 202 "institute": 1,
203 203 "description_short": "",
204 204 "description_long": "",
205   - "sp_pi":2,
  205 + "sp_pi": 2,
206 206 "science_theme": 1,
207   - "is_auto_validated":true
  207 + "is_auto_validated": true
208 208 }
209 209 },
210 210 {
... ... @@ -213,9 +213,9 @@
213 213 "fields": {
214 214 "period": 1,
215 215 "scientific_program": 1,
216   - "status":"Accepted",
217   - "public_visibility":"Name",
218   - "is_valid":"Accepted"
  216 + "status": "Accepted",
  217 + "public_visibility": "Name",
  218 + "is_valid": "Accepted"
219 219 }
220 220 },
221 221 {
... ... @@ -1113,5 +1113,247 @@
1113 1113 "bypass": false,
1114 1114 "plc_timeout_seconds": 10
1115 1115 }
  1116 + },
  1117 + {
  1118 + "model": "common.sequence",
  1119 + "pk": 1,
  1120 + "fields": {
  1121 + "start_expo_pref": "IMMEDIATE",
  1122 + "pyros_user": 2,
  1123 + "scientific_program": 1,
  1124 + "name": "seq_20220218T158246",
  1125 + "desc": null,
  1126 + "created": "2022-02-18T15:07:36.334Z",
  1127 + "updated": "2022-02-21T12:40:50.275Z",
  1128 + "is_alert": false,
  1129 + "status": "DRAFT",
  1130 + "target_coords": "RADEC 0H10M -15D",
  1131 + "with_drift": false,
  1132 + "priority": null,
  1133 + "analysis_method": null,
  1134 + "moon_min": null,
  1135 + "alt_min": null,
  1136 + "type": null,
  1137 + "img_current": null,
  1138 + "img_total": null,
  1139 + "not_obs": false,
  1140 + "obsolete": false,
  1141 + "processing": false,
  1142 + "flag": null,
  1143 + "period": 1,
  1144 + "start_date": "2022-02-18T15:07:36Z",
  1145 + "end_date": "2022-02-18T15:07:36.333Z",
  1146 + "jd1": "0E-8",
  1147 + "jd2": "0E-8",
  1148 + "tolerance_before": "1s",
  1149 + "tolerance_after": "1min",
  1150 + "duration": "-1.00000000",
  1151 + "overhead": "0E-8",
  1152 + "submitted": false,
  1153 + "config_attributes": {
  1154 + "layout": "OpticalChannel",
  1155 + "target": "RADEC 0H10M -15D",
  1156 + "conformation": "WIDE",
  1157 + "tolerance_after": "1min",
  1158 + "tolerance_before": "1s"
  1159 + },
  1160 + "ra": null,
  1161 + "dec": null,
  1162 + "complete": true
  1163 + }
  1164 + },
  1165 + {
  1166 + "model": "common.sequence",
  1167 + "pk": 2,
  1168 + "fields": {
  1169 + "start_expo_pref": "IMMEDIATE",
  1170 + "pyros_user": 2,
  1171 + "scientific_program": 1,
  1172 + "name": "seq_20220218T150731",
  1173 + "desc": null,
  1174 + "created": "2022-02-21T12:43:05.768Z",
  1175 + "updated": "2022-02-21T12:43:06.872Z",
  1176 + "is_alert": false,
  1177 + "status": "TBP",
  1178 + "target_coords": null,
  1179 + "with_drift": false,
  1180 + "priority": null,
  1181 + "analysis_method": null,
  1182 + "moon_min": null,
  1183 + "alt_min": null,
  1184 + "type": null,
  1185 + "img_current": null,
  1186 + "img_total": null,
  1187 + "not_obs": false,
  1188 + "obsolete": false,
  1189 + "processing": false,
  1190 + "flag": null,
  1191 + "period": 1,
  1192 + "start_date": "2022-02-21T20:07:36Z",
  1193 + "end_date": "2022-02-21T12:43:05.767Z",
  1194 + "jd1": "0E-8",
  1195 + "jd2": "0E-8",
  1196 + "tolerance_before": "1s",
  1197 + "tolerance_after": "1min",
  1198 + "duration": "-1.00000000",
  1199 + "overhead": "0E-8",
  1200 + "submitted": false,
  1201 + "config_attributes": {
  1202 + "layout": "OpticalChannel",
  1203 + "target": "RADEC 0H10M -15D",
  1204 + "conformation": "WIDE"
  1205 + },
  1206 + "ra": null,
  1207 + "dec": null,
  1208 + "complete": true
  1209 + }
  1210 + },
  1211 + {
  1212 + "model": "common.sequence",
  1213 + "pk": 3,
  1214 + "fields": {
  1215 + "start_expo_pref": "IMMEDIATE",
  1216 + "pyros_user": 2,
  1217 + "scientific_program": 1,
  1218 + "name": "seq_20220218T150732",
  1219 + "desc": null,
  1220 + "created": "2022-02-21T12:44:28.423Z",
  1221 + "updated": "2022-02-21T12:44:29.556Z",
  1222 + "is_alert": false,
  1223 + "status": "TBP",
  1224 + "target_coords": null,
  1225 + "with_drift": false,
  1226 + "priority": null,
  1227 + "analysis_method": null,
  1228 + "moon_min": null,
  1229 + "alt_min": null,
  1230 + "type": null,
  1231 + "img_current": null,
  1232 + "img_total": null,
  1233 + "not_obs": false,
  1234 + "obsolete": false,
  1235 + "processing": false,
  1236 + "flag": null,
  1237 + "period": 1,
  1238 + "start_date": "2022-02-21T20:07:36Z",
  1239 + "end_date": "2022-02-21T12:44:28.422Z",
  1240 + "jd1": "0E-8",
  1241 + "jd2": "0E-8",
  1242 + "tolerance_before": "1s",
  1243 + "tolerance_after": "1min",
  1244 + "duration": "-1.00000000",
  1245 + "overhead": "0E-8",
  1246 + "submitted": false,
  1247 + "config_attributes": {
  1248 + "layout": "OpticalChannel",
  1249 + "target": "RADEC 0H10M -15D",
  1250 + "conformation": "WIDE"
  1251 + },
  1252 + "ra": null,
  1253 + "dec": null,
  1254 + "complete": true
  1255 + }
  1256 + },
  1257 + {
  1258 + "model": "common.album",
  1259 + "pk": 1,
  1260 + "fields": {
  1261 + "sequence": 1,
  1262 + "name": "OpticalChannel",
  1263 + "desc": "Album with one channel",
  1264 + "created": "2022-02-18T15:07:43.164Z",
  1265 + "updated": "2022-02-21T12:40:50.149Z",
  1266 + "complete": true
  1267 + }
  1268 + },
  1269 + {
  1270 + "model": "common.album",
  1271 + "pk": 2,
  1272 + "fields": {
  1273 + "sequence": 2,
  1274 + "name": "OpticalChannel",
  1275 + "desc": null,
  1276 + "created": "2022-02-21T12:43:06.477Z",
  1277 + "updated": "2022-02-21T12:43:06.477Z",
  1278 + "complete": true
  1279 + }
  1280 + },
  1281 + {
  1282 + "model": "common.album",
  1283 + "pk": 3,
  1284 + "fields": {
  1285 + "sequence": 3,
  1286 + "name": "OpticalChannel",
  1287 + "desc": null,
  1288 + "created": "2022-02-21T12:44:29.265Z",
  1289 + "updated": "2022-02-21T12:44:29.265Z",
  1290 + "complete": true
  1291 + }
  1292 + },
  1293 + {
  1294 + "model": "common.plan",
  1295 + "pk": 1,
  1296 + "fields": {
  1297 + "album": 1,
  1298 + "created": "2022-02-18T15:07:51.078Z",
  1299 + "updated": "2022-02-21T12:40:49.978Z",
  1300 + "duration": 0.0,
  1301 + "nb_images": 1,
  1302 + "config_attributes": {
  1303 + "binnings": {
  1304 + "binxy": [
  1305 + 1,
  1306 + 1
  1307 + ],
  1308 + "readouttime": 6
  1309 + },
  1310 + "exposuretime": 1.0
  1311 + },
  1312 + "complete": true
  1313 + }
  1314 + },
  1315 + {
  1316 + "model": "common.plan",
  1317 + "pk": 2,
  1318 + "fields": {
  1319 + "album": 2,
  1320 + "created": "2022-02-21T12:43:06.670Z",
  1321 + "updated": "2022-02-21T12:43:06.794Z",
  1322 + "duration": 0.0,
  1323 + "nb_images": 1,
  1324 + "config_attributes": {
  1325 + "binnings": {
  1326 + "binxy": [
  1327 + 1,
  1328 + 1
  1329 + ],
  1330 + "readouttime": 6
  1331 + },
  1332 + "exposuretime": 1.0
  1333 + },
  1334 + "complete": true
  1335 + }
  1336 + },
  1337 + {
  1338 + "model": "common.plan",
  1339 + "pk": 3,
  1340 + "fields": {
  1341 + "album": 3,
  1342 + "created": "2022-02-21T12:44:29.361Z",
  1343 + "updated": "2022-02-21T12:44:29.468Z",
  1344 + "duration": 0.0,
  1345 + "nb_images": 1,
  1346 + "config_attributes": {
  1347 + "binnings": {
  1348 + "binxy": [
  1349 + 1,
  1350 + 1
  1351 + ],
  1352 + "readouttime": 6
  1353 + },
  1354 + "exposuretime": 1.0
  1355 + },
  1356 + "complete": true
  1357 + }
1116 1358 }
1117 1359 ]
1118 1360 \ No newline at end of file
... ...
src/core/pyros_django/pyros/settings.py
... ... @@ -439,7 +439,7 @@ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
439 439  
440 440 python_version = subprocess.run( "python --version | cut -d ' ' -f 2 | cut -d '.' -f 1,2",shell=True,stdout=subprocess.PIPE,universal_newlines=True)
441 441 python_version = python_version.stdout
442   -day = "2022-04-15"
  442 +day = "2022-04-26"
443 443 django_version_major,django_version_minor = django.VERSION[:2][0],django.VERSION[:2][1]
444 444 pyros_version = read_version_number_from_file(f"{BASE_DIR}/../../../VERSION")
445 445 #TODO: create function to read VERSION file
... ...
src/core/pyros_django/routine_manager/forms.py
... ... @@ -145,9 +145,10 @@ class SequenceForm(forms.ModelForm):
145 145 if seq.config_attributes != None and seq.config_attributes.get("layout",None) != None:
146 146 initial_choice = seq.config_attributes["layout"]
147 147 self.fields["layout"] = forms.ChoiceField(choices=layouts_choices,label="Layout",widget=RadioSelect,initial=initial_choice,help_text=layout_help_text)
148   - for field in self.fields.values():
  148 + for key in self.fields.keys():
149 149 if readonly == True:
150   - field.widget.attrs['readonly'] = True
  150 + self.fields[key].widget.attrs['disabled'] = True
  151 + self.fields[key].widget.attrs['readonly'] = True
151 152 self.order_fields(["scientific_program","name","start_date","tolerance_before","tolerance_after","start_expo_pref"])
152 153  
153 154 def save(self):
... ... @@ -357,9 +358,10 @@ class PlanForm(forms.ModelForm):
357 358 else:
358 359 # type is str or anything else
359 360 self.fields[main_key] = forms.CharField(initial=initial_value,label=label_str,help_text=help_text)
360   - for field in self.fields.values():
  361 + for key in self.fields.keys():
361 362 if readonly == True:
362   - field.widget.attrs['readonly'] = True
  363 + self.fields[key].widget.attrs['disabled'] = True
  364 + self.fields[key].widget.attrs['readonly'] = True
363 365  
364 366 def clean_nb_images(self):
365 367 '''
... ...
src/core/pyros_django/routine_manager/views.py
... ... @@ -217,7 +217,7 @@ def action_sequence(request, seq_id, action, status=0, message=""):
217 217 return render(request, "routine_manager/view_sequence.html", locals())
218 218 elif action == "view":
219 219 form = SequenceForm(instance=seq, data_from_config=config.getEditableAttributesOfMount(
220   - config.unit_name), layouts=config.get_layouts(config.unit_name), sp_list=sp_list)
  220 + config.unit_name), layouts=config.get_layouts(config.unit_name), sp_list=sp_list, readonly=True)
221 221 edit = False
222 222 return render(request, "routine_manager/view_sequence.html", locals())
223 223 elif action == "delete":
... ... @@ -259,11 +259,16 @@ def sequence_validate(request, seq_id):
259 259 return redirect(action_sequence, seq_id, "delete")
260 260 elif action == "check_validity":
261 261 seq.save()
262   - check_sequence_validity(seq)
  262 + is_seq_valid = check_sequence_validity(seq)
263 263 for album in Album.objects.filter(sequence=seq):
264 264 for plan in Plan.objects.filter(album=album):
265 265 check_plan_validity(plan)
266   -
  266 + message = ""
  267 + if is_seq_valid == True:
  268 + message = f"The sequence is valid and can be submitted."
  269 + else:
  270 + message = f"The sequence isn't valid. Check if your sequence have at least one album with one plan."
  271 + messages.add_message(request, messages.INFO, message)
267 272 return redirect(action_sequence, seq_id, "edit")
268 273 elif form.is_valid():
269 274 seq = form.save()
... ... @@ -294,7 +299,7 @@ def sequence_validate(request, seq_id):
294 299 messages.add_message(request, messages.INFO, message)
295 300 log.info(
296 301 f"User {request.user} did action submit sequence {seq} for period {seq.period} ")
297   - return redirect(action_sequence, seq_id=seq_id, action="edit", status=1, message="Sequence submitted")
  302 + return redirect(sequences_list)
298 303 else:
299 304 message = "Can't submit sequence because it's incomplete (Need at least 1 album with 1 plan)"
300 305 messages.add_message(request, messages.ERROR, message)
... ...