Skip to content

Commit 9bba0de

Browse files
authored
Merge pull request #215 from dathere/druf_implementation_patch
changed the druf to be backwards compatible and disabled by default
2 parents 8e95b97 + 1cb7242 commit 9bba0de

File tree

13 files changed

+521
-108
lines changed

13 files changed

+521
-108
lines changed

CONFIG.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# DataPusher Plus Configuration
2+
3+
## Optional Features
4+
5+
DataPusher Plus includes some optional features that can be enabled through configuration. These features are disabled by default to ensure compatibility with different CKAN versions.
6+
7+
### IFormRedirect Support
8+
9+
The IFormRedirect interface provides custom redirect behavior after dataset and resource form submissions. This interface is only available in certain CKAN branches and is not yet merged into the main CKAN codebase.
10+
11+
**Note**: IFormRedirect methods are only defined when this feature is enabled, keeping the plugin completely clean when disabled.
12+
13+
**Configuration:**
14+
```ini
15+
# Enable IFormRedirect functionality (default: false)
16+
ckanext.datapusher_plus.enable_form_redirect = true
17+
```
18+
19+
**What it does:**
20+
- **Dynamically adds IFormRedirect methods** only when enabled
21+
- Provides custom redirect URLs after dataset/resource creation or editing
22+
- Redirects to dataset page after dataset metadata submission
23+
- Redirects to resource view after resource editing
24+
- Allows "add another resource" workflow
25+
- **Works best with DRUF** for complete resource-first workflow
26+
27+
**Requirements:**
28+
- CKAN version with IFormRedirect interface support
29+
- If the interface is not available, the feature will be automatically disabled with a warning
30+
- **Recommended**: Enable together with DRUF for optimal resource-first experience
31+
32+
### DRUF (Dataset Resource Upload First) Support
33+
34+
DRUF allows users to upload resources before creating the dataset metadata, providing a resource-first workflow.
35+
36+
**Configuration:**
37+
```ini
38+
# Enable DRUF functionality (default: false)
39+
ckanext.datapusher_plus.enable_druf = true
40+
```
41+
42+
**What it does:**
43+
- Adds a `/resource-first/new` endpoint
44+
- Creates a temporary dataset and redirects to resource upload
45+
- Useful for workflows where users want to upload data files first
46+
- **Overrides templates**: Modifies "Add Dataset" buttons and form stages to support resource-first workflow
47+
48+
**Template Overrides:**
49+
When DRUF is enabled, the following templates are overridden:
50+
- `snippets/add_dataset.html`: Changes "Add Dataset" to redirect to resource upload
51+
- `package/snippets/package_form.html`: Modifies form stages to show "Add data" first
52+
- `scheming/package/snippets/package_form.html`: Modifies scheming form stages
53+
54+
**Requirements:**
55+
- No special CKAN version requirements
56+
- Works with standard CKAN installations
57+
- Compatible with ckanext-scheming
58+
59+
## Example Configuration
60+
61+
Add these lines to your CKAN configuration file (e.g., `/etc/ckan/default/ckan.ini`):
62+
63+
```ini
64+
# Enable DRUF (Dataset Resource Upload First) workflow
65+
ckanext.datapusher_plus.enable_druf = true
66+
67+
# Enable IFormRedirect for better form redirects (recommended with DRUF)
68+
ckanext.datapusher_plus.enable_form_redirect = true
69+
```
70+
71+
**Recommended combinations:**
72+
- **Standard mode**: Both disabled (default) - maintains standard CKAN behavior
73+
- **Resource-first workflow**: Both enabled - complete resource-first experience
74+
- **DRUF only**: Only `enable_druf = true` - resource-first without custom redirects
75+
76+
## Template Organization
77+
78+
DataPusher Plus uses a conditional template loading system to avoid conflicts when optional features are disabled:
79+
80+
- **Base templates** (`templates/`): Always loaded, provides standard DataPusher Plus functionality
81+
- **DRUF templates** (`templates/druf/`): Only loaded when `enable_druf = true`, overrides default dataset creation workflow
82+
83+
This ensures that when DRUF is disabled, your CKAN installation maintains completely standard behavior without any template modifications.
84+
85+
## Backwards Compatibility
86+
87+
When these features are disabled (default), DataPusher Plus maintains full backwards compatibility with standard CKAN installations. The plugin will automatically detect if required interfaces are available and disable features gracefully if they are not supported.
88+
89+
## Logging
90+
91+
The plugin will log the status of these features:
92+
- Info messages when features are successfully enabled
93+
- Warning messages when features are configured but not available
94+
- Debug messages for DRUF blueprint registration
95+
96+
Check your CKAN logs to verify the status of these optional features.

README.md

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,53 @@ Without an index, it takes 1.3 seconds.
143143
Ok, that's bad, but what makes it worse is that the old table has been deleted already, and Datapusher doesn't tell you what
144144
caused the job to fail! YIKES!!!!
145145

146+
## DRUF: Dataset Resource Upload First Workflow
147+
148+
DataPusher+ supports an optional **DRUF (Dataset Resource Upload First)** workflow that allows users to upload data files before creating dataset metadata. This resource-first approach is particularly useful for:
149+
150+
- **Data-driven workflows**: Where the structure and content of the data informs the metadata
151+
- **Exploratory data publishing**: When you want to examine the data before writing descriptions
152+
- **Simplified workflows**: Reducing the cognitive load of filling out metadata forms upfront
153+
154+
### How DRUF Works
155+
156+
When DRUF is enabled, the dataset creation workflow is modified:
157+
158+
1. **"Add Dataset" buttons** redirect to a resource upload page instead of the metadata form
159+
2. **Temporary datasets** are automatically created with placeholder metadata
160+
3. **Resource upload happens first**, allowing DataPusher+ to analyze the data
161+
4. **Metadata forms** are enhanced with data-driven suggestions based on the uploaded content
162+
5. **Form redirects** guide users through a logical resource-first workflow
163+
164+
### Enabling DRUF
165+
166+
- To enable DRUF you need [`DRUF compatable ckan version`](https://github.com/ckan/ckan/tree/7778-iformredirect)
167+
- You need to have scheming extension enabled and use the example DRUF compatable schema included in the dp+ extension.
168+
169+
Add the following configuration to your CKAN config file (e.g., `/etc/ckan/default/ckan.ini`):
170+
171+
172+
```ini
173+
# Enable DRUF (Dataset Resource Upload First) workflow
174+
ckanext.datapusher_plus.enable_druf = true
175+
ckanext.datapusher_plus.enable_form_redirect = true
176+
```
177+
178+
179+
### Backwards Compatibility
180+
181+
DRUF is completely optional and disabled by default. When disabled:
182+
- Standard CKAN dataset creation workflow is preserved
183+
- No template modifications are applied
184+
- Full backwards compatibility with existing CKAN installations
185+
186+
146187
## Requirements:
147188
* CKAN 2.10+
148189
* Python 3.10+
149190
* tested and developed on Ubuntu 22.04.5
150191
* [`ckan.datastore.sqlsearch.enabled`](https://docs.ckan.org/en/2.10/maintaining/datastore.html#ckanext.datastore.logic.action.datastore_search_sql) set to `true` if you want to use the `temporal_resolution` and `guess_accrual_periodicity` Formula helpers
192+
* ckanext-scheming extension
151193

152194
## Development Installation
153195

@@ -259,14 +301,10 @@ Add `datapusher_plus` to the plugins in your CKAN configuration file
259301
```ini
260302
ckan.plugins = <other plugins> datapusher_plus
261303
```
262-
263-
**Note on DRUF :**
264-
DRUF is enabled by default when using `datapusher_plus`. If you wish to **disable** DRUF behavior, ensure that the `scheming_datasets` plugin is listed **before** `datapusher_plus` in the plugin list:
265-
266304
Use a DP+ extended scheming schema:
267305

268306
```ini
269-
scheming.dataset_schemas = ckanext.datapusher_plus:dataset_schema.yaml
307+
scheming.dataset_schemas = ckanext.datapusher_plus:dataset-druf.yaml
270308
```
271309

272310
Configure DP+ numerous settings. See [config.py](ckanext/datapusher_plus/config.py) for details.

ckanext/datapusher_plus/dataset-druf.yaml

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -68,55 +68,14 @@ dataset_fields:
6868
- field_name: end_date
6969
label: Automatic Update End Date
7070
form_snippet: date.html
71-
validators: ignore_missing check_end_date
71+
validators: ignore_missing
7272
help_text: If this dataset has an Update Type of Automatic and Automatic Updates should stop at some point, please indicate the end date at which Automatic Updates should stop. If not, leave this field blank.
7373
help_inline: true
7474

75-
- field_name: update_frequency
76-
label: Update Frequency
77-
#required: True
78-
form_include_blank_choice: true
79-
preset: select
80-
choices:
81-
- label: Real-time
82-
value: real-time
83-
- label: 15 minutes or less
84-
value: 15 minutes or less
85-
- label: Hourly
86-
value: hourly
87-
- label: Daily
88-
value: daily
89-
- label: Weekly
90-
value: weekly
91-
- label: Monthly
92-
value: monthly
93-
- label: Quarterly
94-
value: quarterly
95-
- label: Every 6 months
96-
value: every 6 months
97-
- label: Annually
98-
value: annually
99-
- label: As needed
100-
value: as needed
101-
- label: Never
102-
value: never
103-
- label: Other
104-
value: other
105-
10675
- field_name: next_update
10776
label: Next Update
10877
form_snippet: date.html
10978

110-
field_name: caveats_usage
111-
label: Caveats and Usage
112-
form_snippet: markdown.html
113-
help_text: this help is going to be displayed inline.
114-
help_inline: true
115-
116-
- field_name: tag_string
117-
label: Tags
118-
preset: tag_string_autocomplete_hidden
119-
form_placeholder: eg. economy, mental health, government
12079

12180
- field_name: dpp_suggestions
12281
label: DPP Suggestions

0 commit comments

Comments
 (0)