Skip to content
Snippets Groups Projects

WIP: Support group based restriction

Merged Andrea Callia D'Iddio requested to merge support-group-based-restriction into master
All threads resolved!
4 files
+ 27
4
Compare changes
  • Side-by-side
  • Inline
Files
4
+ 7
1
from flask_wtf import FlaskForm
from wtforms import BooleanField, StringField, TextAreaField
from wtforms import BooleanField, SelectField, StringField, TextAreaField
from wtforms.validators import DataRequired, ValidationError
@@ -8,9 +8,15 @@ class ProjectForm(FlaskForm):
description = TextAreaField("Description", validators=[DataRequired()])
is_student_proposal = BooleanField("Student Proposal", default=False)
on_behalf = StringField("from", default=None)
category = SelectField("Category", coerce=str)
def validate_on_behalf(self, field):
if self.is_student_proposal.data and not field.data:
raise ValidationError(
"Student proposer cannot be empty if project is marked as student proposal."
)
def validate_category(self, field):
if field == self.category and field.data == "":
self.category.errors += "Please choose a category for the project."
raise ValidationError("Please choose a category for the project.")
Loading