Customizing a Hazard-Specific Call to Action - Hazard Services
Jobsheet Display Portlet
Purpose:
This slight variation of customizing a CTA and handles the simpler form of automatically added, hazard-specific calls to action.Tasks:
AT-A-GLANCE:
- What? Change the quoted string returned by the simpe cta_BZ_W method, in an override of callsToActionAndImpacts.py
- No HID Selections. These CTAs have no direct selections on the HID - they are only triggered if "Automatically Generated CTAs" is selected.
Follow the steps below for more detailed guidance.
*** OTHER CONFIGURATIONS WITH IDENTICAL WORKFLOW *** The methodology in this jobsheet can be mirrored for any hazard-specific CTA in CallsToActionAndImpacts.py (e.g. cta_WC_A, cta_IS_default, end more) which also returns basic CTA strings. |
- [OPTIONAL] Create a hazard for for your area to review the current, hazard-specific CTA
- Launch Hazard Services in your desired perspective (e.g. GFE)
- Draw a hazard in your area using the freehand polygon or other method
- Select a category (e.g. Winter) and hazard (e.g. BZ.W)
- Leave the "Automatically Generated CTAs" checkbox under "Calls to Action" selected, then click "Preview" to generate a product
- Look at the "Calls to Action" text field (near the bottom) and review the text being used
- If baseline, the BZ.W-specific CTA should appear as "Travel should be restricted to emergencies only. If you must travel, have a winter survival kit with you. If you get stranded, stay with your vehicle." This jobsheet will change that text.
- Note: You'll notice an additional sentence appended after these automatic CTAs, which is your default localCTA (e.g. "The latest road conditions..."). This text is independently managed via LocalVariables.py
- Switch to the Localization Perspective by clicking on the "Open Perspective" icon at the top-right of your CAVE window, and choosing "Localization"
- In the Localization Perspective, navigate to the Utilities sub-directory under the Hazard Services folder.
- Double click on CallsToActionAndImpacts.py to show the available versions
- Create a user override version if none exists (user override is best practice for testing changes):
- If there is only a BASE version: right click on BASE and select Create Override File, then select User
- If there is another version (e.g. SITE) you wish to use: right click on that file and select Copy To, then select User (this lets you work on an updated SITE version to replace the original when you're finished)
- Double click on the USER version of CallsToActionAndImpacts.py to open it for editing
- Open a reference copy of the existing CallsToActionAndImpacts.py file, which will be used for comparing to and copying existing code for overrides.
- It's typically best to open the BASE version because most methods have not already been overridden in a higher-level override
- In the reference file you opened, scroll or search to find the method which defines your CTA
- For the BZ.W-specific CTA, find the "cta_BZ_W" method (whose first line appears as "def cta_BZ_W(self):" in CallsToActionAndImpacts.py)
- Searching this file for text you know to be in the CTA phrase is another trick for finding the corresponding CTA method
- Once found, select the entire CTA method by clicking and dragging from (and including) the "def cta_BZ_W(self):" line which begins the function, all the way to (and including) the last line of the function which has the "return" statement.
- These methods are very simple, so you will usually only be copying a few lines
- Copy the selected contents by right-clicking and selecting "Copy" from the pop-up menu, or by hitting CTRL-C on your keyboard
- Switch back to the USER override you were working on
- Paste the copied CTA method into your USER override on a blank line after the "class..." and "pass" lines, by right-clicking and selecting "Paste" from the pop-up menu, or by hitting CTRL-V on your keyboard
- If you already have overrides in your USER file, just paste the copied method anywhere after the existing overrides
- In the USER copy of the CTA method you just pasted in, edit the quoted text with your desired change.
- For the BZ.W cta, your new CTA method may look like this (changes in bold):
def cta_BZ_W(self): return ("Travel should be restricted to emergencies only. If you must travel, " "have a winter survival kit with you. Notify a friend or family member of " "your travel plans. If you get stranded, stay with your vehicle.")
- For readability, feel free to use multiple lines to type this message, but if so be sure to close and reopen the quotation marks on each line. All text in the parentheses will be joined when the product is created.
- For the BZ.W cta, your new CTA method may look like this (changes in bold):
- When finished, save the file by hitting Ctrl+S, or selecting Save from the File menu
- If a "File Version Conflict" is encountered, click OK to accept merge
- In the two-panel "Merge" tab that opens, make no changes, once again save the file by hitting Ctrl+s, then close the "Merge" tab
- When a "File Changed" message appears, click Yes.
- This behavior will only be encountered each time a new override file that did not exist before is created and saved
- [OPTIONAL, RECOMMENDED] Verify your CTA has changed by re-generating a product for some hazard
- Switch back to GFE (or whichever localization you were previously using) to once again view Hazard Services
- Dismiss any open Product Editor window, and then click Preview in the HID for your BZ.W hazard to re-launch the Product Editor
- Make sure to leave the checkbox selected for "Automatically Generated CTAs (derived from grids)"
- Scroll down and observe the UPDATED text of the "Calls to Action" text
- Your updated CTA phrase should appear in the first one or two sentences of the text box
- Recall: You'll see the additional, separately managed localCTA (e.g. "For the latest road conditions...") appended after the hazard-specific CTA. That statement is managed in LocalVariables.py
-
Task Complete!