Skip to content

Commit 83ec25d

Browse files
authored
GOATS-980: Refactor source profile to better handle unsupported types. (#485)
- Make sedProfileTypeSelect optional in SourceProfileSerializer. - Update format_gpp to return None if sedProfileTypeSelect is not provided. - Add test to ensure invalid sedProfileTypeSelect values are rejected. - Add CSS class for smaller accordion body with overflow. - Adjust SourceProfileEditor to handle null sedType gracefully. - Display warning with accordion for unsupported source profile types in the UI.
1 parent e9ccc91 commit 83ec25d

8 files changed

Lines changed: 291 additions & 150 deletions

File tree

docs/changes/485.change.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Refactored Source Profile to handle unsupported profiles and SEDs, and clean up SED rendering logic. Users can now view raw data for unsupported types.

src/goats_tom/serializers/gpp/source_profile/source_profile.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ class SourceProfileType(str, Enum):
2828

2929
class SourceProfileSerializer(_BaseGPPSerializer):
3030
sedProfileTypeSelect = serializers.ChoiceField(
31-
choices=[e.value for e in SourceProfileType], required=True, allow_blank=False
31+
choices=[e.value for e in SourceProfileType],
32+
required=False,
33+
allow_blank=False,
34+
allow_null=True,
3235
)
3336
sedTypeSelect = serializers.ChoiceField(
3437
choices=[e.value for e in SEDType],
@@ -80,7 +83,11 @@ def format_gpp(self) -> dict[str, Any] | None:
8083
dict[str, Any] | None
8184
The formatted source profile data, or ``None`` if no data was provided.
8285
"""
83-
profile_type = self.validated_data["sedProfileTypeSelect"]
86+
profile_type = self.validated_data.get("sedProfileTypeSelect")
87+
if not profile_type:
88+
# Nothing to format.
89+
return None
90+
8491
band_normalized: dict[str, Any] = {}
8592

8693
if self.sed is not None:

src/goats_tom/static/css/cores/halfmoon.goats.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,11 @@ select.form-control[multiple] {
482482
overflow-y: auto;
483483
}
484484

485+
.accordion-body-sm-overflow {
486+
max-height: 250px;
487+
overflow-y: auto;
488+
}
489+
485490
.custom-tooltip {
486491
overflow-y: auto;
487492
max-height: 400px;

src/goats_tom/static/js/gpp/fields.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ const SHARED_FIELDS = [
181181
},
182182
// Source profile section.
183183
{
184-
path: "targetEnvironment.firstScienceTarget.sourceProfile.point.bandNormalized.sed",
184+
path: "targetEnvironment.firstScienceTarget.sourceProfile",
185185
handler: "handleSourceProfile",
186186
},
187187
// Brightnesses section.

src/goats_tom/static/js/gpp/observation_form.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class ObservationForm {
9191
const div = Utils.createElement("div", "mt-3");
9292
new SourceProfileEditor(div, {
9393
data: raw ?? {},
94-
readOnly: this.#readOnly,
94+
debug: true,
9595
});
9696
return [div];
9797
},

src/goats_tom/static/js/gpp/program_observations_panel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class ProgramObservationsPanel {
7979
*/
8080
setDebug(flag) {
8181
this.#debug = flag;
82-
this.#logDebug("Debug logging enabled.");
82+
this.#logDebug(`Setting debug to ${flag}`);
8383
}
8484

8585
/**

0 commit comments

Comments
 (0)