Skip to content

Commit

Permalink
Add a TODO for extendable fields
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartmac committed Nov 8, 2024
1 parent 06c5ae8 commit 51d866a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions app/forms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from flask_wtf import FlaskForm
from wtforms import TextAreaField, FileField, SubmitField


class FastaForm(FlaskForm):
sequence = TextAreaField('Enter FASTA Sequence')
fasta_file = FileField('Or Upload a FASTA File')
Expand All @@ -10,14 +11,16 @@ class FastaForm(FlaskForm):
def validate(self, extra_validators=None):
# Use the default validate method first
initial_validation = super(FastaForm, self).validate(extra_validators=extra_validators)

# If the initial validation passes and either sequence or fasta_file has data, return True
if initial_validation and (self.sequence.data or self.fasta_file.data):
return True

# If neither field has data, add a form-wide error
if not self.sequence.data and not self.fasta_file.data:
self.sequence.errors.append('Either enter a FASTA sequence or upload a FASTA file.')
return False

return False

# TODO: Implement extendable form with optional fields

0 comments on commit 51d866a

Please sign in to comment.