Closed aislinnpearson closed 2 years ago
The machine name for these flags can be restriction_{name}
Following discussion with @paul121 we agreed that although flags are a short term solution, there should be a better way of assigning these kinds of restrictions in FarmOS. I've created a second issue for this here (#238) so that we don't lose track of the issue once this one is closed.
The machine name for these flags can be restriction_{name}
I actually prefixed these with plot_restriction_{name}
since they are all specific to plots.
Since there were so many I created a little script to create the flags and then export config using drush. Tthis might be useful in the future:
drush scr flag_create.php
drush cex --destination flag-create
<?php
// flag_create.php
// Array of flags keyed by id suffix.
$flags = [
// Pesticide and input.
'fungicide' => 'Fungicide restrictions (F)',
'insecticide' => 'Insecticide restrictions (I)',
'herbicide' => 'Herbicide restrictions (H)',
'nematicide' => 'Nematicide restrictions (N)',
'molluscicides' => 'Molluscicides restrictions (M)',
'plant_growth_regulator' => 'Plant growth regulator restrictions (PGR)',
// Watering.
'irrigation' => 'Irrigation/watering restrictions (W)',
// Nutrient.
'nitrogen' => 'Nitrogen restrictions (N)',
'potassium' => 'Potassium restrictions (P)',
'phosphorous' => 'Phosphorous restrictions (K)',
'sulphur' => 'Sulphur restrictions (S)',
'magnesium' => 'Magnesium restrictions (Mg)',
'liming' => 'Liming restrictions (pH)',
'micronutrient' => 'Micronutrient restrictions (mn)',
// Drilling.
'drilling_date' => 'Drilling date restrictions (dd)',
'seed_rate' => 'Seed rate restrictions (sr)',
'variety' => 'Variety restrictions (var)',
'seed_treatments' => 'Seed treatments restrictions (st)',
// Other.
'physical' => 'Physical obstructions (obst)',
'gm_material' => 'GM Material (GM)',
'pre_harvest_sampling'=> 'Pre-harvest Sampling (Pre)',
'post_harvest_sampling' => 'Post-harvest Sampling (Post)',
];
// Create or delete all flags.
$create = TRUE;
foreach ($flags as $id => $label) {
$flag_id = "plot_restriction_$id";
if ($create) {
$flag = \Drupal\farm_flag\Entity\FarmFlag::create([
'id' => $flag_id,
'label' => $label,
'entity_types' => [
'asset' => ['plot'],
],
'dependencies' => [
'enforced' => [
'module' => ['farm_rothamsted_experiment'],
],
],
]);
$flag->save();
}
elseif ($flag = \Drupal\farm_flag\Entity\FarmFlag::load($flag_id)) {
$flag->delete();
}
}
These restrictions would ideally also show up on the quick forms when selecting plots, but perhaps with an abbreviation (ideas for which are in brackets next to the type of restriction, but I'm open to alternatives as I don't think they are all that great)
Opening a new issue for this #241
When submitting a new experiment, it is common for the scientists to set restrictions on inputs and other management attributes. The restrictions usually apply to the whole experiment, but occasionally they relate only to certain plots (for example, only the bean plots in a rotation experiment).
Restriction types include:
Pesticide and Input Restrictions
Watering Restrictions:
Nutrient Restrictions
Drilling Restrictions:
Other useful flag types might include:
Ideally these would eventually link to a cropping plan for the experiments (see #230), but for now I think being able to flag specific plots would be ideal. These restrictions would ideally also show up on the quick forms when selecting plots, but perhaps with an abbreviation (ideas for which are in brackets next to the type of restriction, but I'm open to alternatives as I don't think they are all that great)