Skip to content

Initial POC for a facility that uses redirects#1357

Merged
Fingel merged 16 commits intodevfrom
redirect-facility
Jan 21, 2026
Merged

Initial POC for a facility that uses redirects#1357
Fingel merged 16 commits intodevfrom
redirect-facility

Conversation

@Fingel
Copy link
Copy Markdown
Contributor

@Fingel Fingel commented Nov 20, 2025

This is how this flow works:

User is at the TOM:

  1. The facility class constructs a URL that points to the OCS. This URL contains query parameters that correspond to the chosen Target's attributes.
  2. The facility class also constructs a callback url, which points to the internal tom_observations:callback view. This callback url contains query parameters for the facility class name, the target id, but leaves the observation id blank (this is to be provided by the observation portal)
  3. The facility class simply presents a the combined link to the OCS (with the callback url appended as a query parameter). User clicks on the link to the OCS.

Now at the OCS:

  1. The OCS presents the observation create form, and pre-fills in the target fields based on the query params.
  2. The user submits the observation.
  3. Instead of doing whatever the OCS does, it redirects to the callback url created in the previous step 2 with the newly created observation_id appended.

Now back at the TOM:

  1. The callback url creates an ObservationRecord object from the query parameters passed in from the OCS: target_id, facility, and observation_id.
  2. The user is sent to the ObservationRecord detail view of the newly created observation record. There is no distinction between records created using the built in OCS form or those created via the redirect flow.

@Fingel Fingel linked an issue Nov 20, 2025 that may be closed by this pull request
@jchate6 jchate6 moved this to Needs Review in TOM Toolkit Nov 20, 2025
@jchate6 jchate6 requested a review from rachel3834 November 21, 2025 18:45
@jchate6
Copy link
Copy Markdown
Contributor

jchate6 commented Dec 1, 2025

@Fingel is there a branch of the OCS that this relies on to work?

The redirection to the OCS looks good, but I'm guessing this relies on OCS changes to be fully functional. It would be nice to have something running locally before merging this.

@Fingel
Copy link
Copy Markdown
Contributor Author

Fingel commented Dec 3, 2025

OCS PR here: LCOGT/observation-portal-frontend#130

@jchate6
Copy link
Copy Markdown
Contributor

jchate6 commented Dec 4, 2025

Screencast-2025-12-03-13_02.mp4

Copy link
Copy Markdown
Contributor

@jchate6 jchate6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. I love the simplicity.

Let's add some small notes for ourselves in the ReadtheDocs about what's expected from a redirect facility on the TOM side and on the Facility side to make this work.

Specifically what the facility should expect and what they need to pass back.

Comment thread tom_observations/facility.py
}
return urllib.parse.urlencode(set_fields)

def observation_portal_uri(self) -> str:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to url?

Comment thread tom_observations/views.py
Comment thread tom_observations/views.py
user = request.user
if not all([facility, target_id, observation_id]):
messages.error(self.request, 'Missing required parameters: facility, target_id, observation_id')
return redirect(reverse('tom_observations:list'))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be nice to redirect back to target detail page if target_id exists

Comment thread tom_observations/views.py
Comment thread tom_observations/views.py
@Fingel
Copy link
Copy Markdown
Contributor Author

Fingel commented Jan 15, 2026

I added a couple paragraphs about the Redirect Facility to the sphinx docs. I'm reluctant to add anything more specific as the implementation might change.

Comment thread docs/observing/customize_ocs_facility.rst
@jchate6
Copy link
Copy Markdown
Contributor

jchate6 commented Jan 15, 2026

I added a couple paragraphs about the Redirect Facility to the sphinx docs. I'm reluctant to add anything more specific as the implementation might change.

I think that's exactly the right level of detail.

@Fingel Fingel merged commit dfb72d8 into dev Jan 21, 2026
26 checks passed
@github-project-automation github-project-automation Bot moved this from Needs Review to Merged (to dev) in TOM Toolkit Jan 21, 2026
@jchate6 jchate6 moved this from Merged (to dev) to Released in TOM Toolkit Jan 23, 2026
@jchate6 jchate6 deleted the redirect-facility branch March 27, 2026 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Integrate LCO observing portal into the TOMToolkit workflow

2 participants