mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 20:59:01 +02:00
forms: clear out comparison recipe/layerbranch if status doesn't accept them
If the cover status for a comparison recipe is Unknown, Not available, or Distro-specific, then we disable the recipe and layerbranch fields in the form (using Javascript), however the form could still be saved and any existing values would persist. Clear out the fields upon saving if they are set under these circumstances. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
parent
fca74f3ac3
commit
a40a5350e4
|
@ -166,6 +166,17 @@ class ClassicRecipeForm(forms.ModelForm):
|
|||
model = ClassicRecipe
|
||||
fields = ('cover_layerbranch', 'cover_pn', 'cover_status', 'cover_verified', 'cover_comment', 'classic_category')
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = super(ClassicRecipeForm, self).clean()
|
||||
cover_pn = cleaned_data.get('cover_pn')
|
||||
cover_layerbranch = cleaned_data.get('cover_layerbranch')
|
||||
if cleaned_data.get('cover_status') in ['U', 'N', 'S']:
|
||||
if cover_layerbranch:
|
||||
cleaned_data['cover_layerbranch'] = None
|
||||
if cover_pn:
|
||||
cleaned_data['cover_pn'] = ''
|
||||
return cleaned_data
|
||||
|
||||
|
||||
class AdvancedRecipeSearchForm(forms.Form):
|
||||
FIELD_CHOICES = (
|
||||
|
|
Loading…
Reference in New Issue
Block a user