-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
finished the project, now it just needs comments
- Loading branch information
Showing
14 changed files
with
699 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,92 @@ | ||
from flask_wtf import FlaskForm | ||
from wtforms import IntegerField, StringField, SubmitField | ||
from wtforms.validators import InputRequired, NumberRange | ||
from wtforms import ( | ||
IntegerField, | ||
PasswordField, | ||
StringField, | ||
SubmitField, | ||
TextAreaField, | ||
URLField, | ||
) | ||
|
||
from wtforms.validators import ( | ||
InputRequired, | ||
Email, | ||
EqualTo, | ||
Length, | ||
NumberRange, | ||
) | ||
|
||
|
||
class LoginForm(FlaskForm): | ||
email = StringField("Email", validators=[InputRequired(), Email()]) | ||
password = PasswordField("Password", validators=[InputRequired()]) | ||
submit = SubmitField("Login") | ||
|
||
|
||
class RegisterForm(FlaskForm): | ||
email = StringField("Email", validators=[InputRequired(), Email()]) | ||
|
||
password = PasswordField( | ||
"Password", | ||
validators=[ | ||
InputRequired(), | ||
Length( | ||
min=4, | ||
max=20, | ||
message="Your password must be between 4 and 20 characters long.", | ||
), | ||
], | ||
) | ||
|
||
confirm_password = PasswordField( | ||
"Confirm Password", | ||
validators=[ | ||
InputRequired(), | ||
EqualTo( | ||
"password", | ||
message="This password did not match the one in the password field.", | ||
), | ||
], | ||
) | ||
|
||
submit = SubmitField("Register") | ||
|
||
|
||
class MovieForm(FlaskForm): | ||
title = StringField("Title", validators=[InputRequired()]) | ||
director = StringField("Director", validators=[InputRequired()]) | ||
|
||
year = IntegerField("Year", validators=[InputRequired(), | ||
NumberRange(min=1878, message="Please enter a year in YYYY format")]) | ||
year = IntegerField( | ||
"Year", | ||
validators=[ | ||
InputRequired(), | ||
NumberRange(min=1878, message="Please enter a year in the format YYYY."), | ||
], | ||
) | ||
|
||
submit = SubmitField("Add Movie") | ||
|
||
|
||
class StringListField(TextAreaField): | ||
def _value(self): | ||
if self.data: | ||
return "\n".join(self.data) | ||
else: | ||
return "" | ||
|
||
def process_formdata(self, valuelist): | ||
# checks valuelist contains at least 1 element, and the first element isn't falsy (i.e. empty string) | ||
if valuelist and valuelist[0]: | ||
self.data = [line.strip() for line in valuelist[0].split("\n")] | ||
else: | ||
self.data = [] | ||
|
||
|
||
class ExtendedMovieForm(MovieForm): | ||
cast = StringListField("Cast") | ||
series = StringListField("Series") | ||
tags = StringListField("Tags") | ||
description = TextAreaField("Description") | ||
video_link = URLField("Video link") | ||
|
||
submit = SubmitField("Submit") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.