51 lines
1.9 KiB
Python
51 lines
1.9 KiB
Python
# plugins/submission/forms.py
|
||
|
||
from flask_wtf import FlaskForm
|
||
from wtforms import (
|
||
StringField,
|
||
FloatField,
|
||
SelectField,
|
||
IntegerField,
|
||
TextAreaField,
|
||
MultipleFileField,
|
||
SubmitField
|
||
)
|
||
from wtforms.validators import Optional, NumberRange, Length, DataRequired
|
||
|
||
class SubmissionForm(FlaskForm):
|
||
submission_type = SelectField(
|
||
"Submission Type",
|
||
choices=[
|
||
("market_price", "Market Price"),
|
||
("name_correction", "Name Correction"),
|
||
("new_plant", "New Plant Suggestion"),
|
||
("mutation", "Mutation Discovery"),
|
||
("vendor_rating", "Vendor Rating/Review"),
|
||
("vendor_alias", "Vendor Alias Submission"),
|
||
],
|
||
validators=[DataRequired()]
|
||
)
|
||
|
||
# Make plant_name Optional; route logic enforces when necessary
|
||
plant_name = StringField("Common Name", validators=[Optional(), Length(max=100)])
|
||
scientific_name = StringField("Scientific Name", validators=[Optional(), Length(max=120)])
|
||
notes = TextAreaField("Notes", validators=[Optional()])
|
||
|
||
# Market Price fields
|
||
price = FloatField("Price", validators=[Optional()])
|
||
source = StringField("Source/Vendor (e.g. Etsy, eBay)", validators=[Optional(), Length(max=255)])
|
||
|
||
# Vendor Rating / Review fields
|
||
vendor_name = StringField("Vendor Name", validators=[Optional(), Length(max=255)])
|
||
rating = IntegerField("Rating (1–5)", validators=[Optional(), NumberRange(min=1, max=5)])
|
||
|
||
# Vendor Alias Submission fields
|
||
old_vendor = StringField("Existing Vendor Name", validators=[Optional(), Length(max=255)])
|
||
new_vendor = StringField("New Vendor Name (Alias)", validators=[Optional(), Length(max=255)])
|
||
alias_reason = TextAreaField("Reason for Alias", validators=[Optional()])
|
||
|
||
# Images (max 10)
|
||
images = MultipleFileField("Upload Images (max 10)", validators=[Optional()])
|
||
|
||
submit = SubmitField("Submit")
|